mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-16 14:31:59 +00:00
Add binary archive support to llvm-nm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140627 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a51d7d97b0
commit
9142ae2cf8
BIN
test/Object/TestObjectFiles/archive-test.a-bitcode
Normal file
BIN
test/Object/TestObjectFiles/archive-test.a-bitcode
Normal file
Binary file not shown.
BIN
test/Object/TestObjectFiles/archive-test.a-coff-i386
Normal file
BIN
test/Object/TestObjectFiles/archive-test.a-coff-i386
Normal file
Binary file not shown.
17
test/Object/nm-archive.test
Normal file
17
test/Object/nm-archive.test
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
RUN: llvm-nm %p/TestObjectFiles/archive-test.a-coff-i386 \
|
||||||
|
RUN: | FileCheck %s -check-prefix COFF
|
||||||
|
RUN: llvm-nm %p/TestObjectFiles/archive-test.a-bitcode \
|
||||||
|
RUN: | FileCheck %s -check-prefix BITCODE
|
||||||
|
|
||||||
|
|
||||||
|
COFF: trivial-object-test.coff-i386:
|
||||||
|
COFF-NEXT: 00000000 d .data
|
||||||
|
COFF-NEXT: 00000000 t .text
|
||||||
|
COFF-NEXT: 00000000 d L_.str
|
||||||
|
COFF-NEXT: U _SomeOtherFunction
|
||||||
|
COFF-NEXT: 00000000 T _main
|
||||||
|
COFF-NEXT: U _puts
|
||||||
|
|
||||||
|
BITCODE: U SomeOtherFunction
|
||||||
|
BITCODE-NEXT: T main
|
||||||
|
BITCODE-NEXT: U puts
|
@ -20,6 +20,7 @@
|
|||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Bitcode/ReaderWriter.h"
|
#include "llvm/Bitcode/ReaderWriter.h"
|
||||||
#include "llvm/Bitcode/Archive.h"
|
#include "llvm/Bitcode/Archive.h"
|
||||||
|
#include "llvm/Object/Archive.h"
|
||||||
#include "llvm/Object/ObjectFile.h"
|
#include "llvm/Object/ObjectFile.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/FileSystem.h"
|
#include "llvm/Support/FileSystem.h"
|
||||||
@ -318,18 +319,34 @@ static void DumpSymbolNamesFromFile(std::string &Filename) {
|
|||||||
errs() << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
|
errs() << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
|
||||||
|
|
||||||
} else if (aPath.isArchive()) {
|
} else if (aPath.isArchive()) {
|
||||||
std::string ErrMsg;
|
OwningPtr<Binary> arch;
|
||||||
Archive* archive = Archive::OpenAndLoad(sys::Path(Filename), Context,
|
if (error_code ec = object::createBinary(aPath.str(), arch)) {
|
||||||
&ErrorMessage);
|
errs() << ToolName << ": " << Filename << ": " << ec.message() << ".\n";
|
||||||
if (!archive)
|
|
||||||
errs() << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
|
|
||||||
std::vector<Module *> Modules;
|
|
||||||
if (archive->getAllModules(Modules, &ErrorMessage)) {
|
|
||||||
errs() << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MultipleFiles = true;
|
if (object::Archive *a = dyn_cast<object::Archive>(arch.get())) {
|
||||||
std::for_each (Modules.begin(), Modules.end(), DumpSymbolNamesFromModule);
|
for (object::Archive::child_iterator i = a->begin_children(),
|
||||||
|
e = a->end_children(); i != e; ++i) {
|
||||||
|
OwningPtr<Binary> child;
|
||||||
|
if (error_code ec = i->getAsBinary(child)) {
|
||||||
|
// Try opening it as a bitcode file.
|
||||||
|
MemoryBuffer *buff = i->getBuffer();
|
||||||
|
Module *Result = 0;
|
||||||
|
if (buff)
|
||||||
|
Result = ParseBitcodeFile(buff, Context, &ErrorMessage);
|
||||||
|
|
||||||
|
if (Result) {
|
||||||
|
DumpSymbolNamesFromModule(Result);
|
||||||
|
delete Result;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (object::ObjectFile *o = dyn_cast<ObjectFile>(child.get())) {
|
||||||
|
outs() << o->getFileName() << ":\n";
|
||||||
|
DumpSymbolNamesFromObject(o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (aPath.isObjectFile()) {
|
} else if (aPath.isObjectFile()) {
|
||||||
OwningPtr<Binary> obj;
|
OwningPtr<Binary> obj;
|
||||||
if (error_code ec = object::createBinary(aPath.str(), obj)) {
|
if (error_code ec = object::createBinary(aPath.str(), obj)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user