mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 12:19:53 +00:00
Change the output of llvm-nm and llvm-size for Mach-O universal files (aka
fat files) to print “ (for architecture XYZ)” for fat files with more than one architecture to be like what the darwin tools do for fat files. Also clean up the Mach-O printing of archive membernames in llvm-nm to use the darwin form of "libx.a(foo.o)". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211316 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0b5745abd8
commit
c28016e413
@ -18,6 +18,7 @@
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/Object/Binary.h"
|
||||
#include "llvm/Object/Archive.h"
|
||||
#include "llvm/Object/MachO.h"
|
||||
#include "llvm/Support/ErrorOr.h"
|
||||
#include "llvm/Support/MachO.h"
|
||||
|
||||
@ -52,6 +53,9 @@ public:
|
||||
|
||||
ObjectForArch getNext() const { return ObjectForArch(Parent, Index + 1); }
|
||||
uint32_t getCPUType() const { return Header.cputype; }
|
||||
std::string getArchTypeName() const {
|
||||
return Triple::getArchTypeName(MachOObjectFile::getArch(Header.cputype));
|
||||
}
|
||||
|
||||
std::error_code getAsObjectFile(std::unique_ptr<ObjectFile> &Result) const;
|
||||
|
||||
|
@ -72,9 +72,7 @@ std::error_code MachOUniversalBinary::ObjectForArch::getAsObjectFile(
|
||||
if (Parent) {
|
||||
StringRef ParentData = Parent->getData();
|
||||
StringRef ObjectData = ParentData.substr(Header.offset, Header.size);
|
||||
std::string ObjectName =
|
||||
Parent->getFileName().str() + ":" +
|
||||
Triple::getArchTypeName(MachOObjectFile::getArch(Header.cputype));
|
||||
std::string ObjectName = Parent->getFileName().str();
|
||||
MemoryBuffer *ObjBuffer = MemoryBuffer::getMemBuffer(
|
||||
ObjectData, ObjectName, false);
|
||||
ErrorOr<ObjectFile *> Obj = ObjectFile::createMachOObjectFile(ObjBuffer);
|
||||
@ -91,9 +89,7 @@ std::error_code MachOUniversalBinary::ObjectForArch::getAsArchive(
|
||||
if (Parent) {
|
||||
StringRef ParentData = Parent->getData();
|
||||
StringRef ObjectData = ParentData.substr(Header.offset, Header.size);
|
||||
std::string ObjectName =
|
||||
Parent->getFileName().str() + ":" +
|
||||
Triple::getArchTypeName(MachOObjectFile::getArch(Header.cputype));
|
||||
std::string ObjectName = Parent->getFileName().str();
|
||||
MemoryBuffer *ObjBuffer = MemoryBuffer::getMemBuffer(
|
||||
ObjectData, ObjectName, false);
|
||||
ErrorOr<Archive *> Obj = Archive::create(ObjBuffer);
|
||||
|
@ -3,17 +3,17 @@ RUN: | FileCheck %s -check-prefix CHECK-OBJ
|
||||
RUN: llvm-nm %p/Inputs/macho-universal-archive.x86_64.i386 \
|
||||
RUN: | FileCheck %s -check-prefix CHECK-AR
|
||||
|
||||
CHECK-OBJ: macho-universal.x86_64.i386:x86_64
|
||||
CHECK-OBJ: macho-universal.x86_64.i386 (for architecture x86_64):
|
||||
CHECK-OBJ: 0000000100000f60 T _main
|
||||
CHECK-OBJ: macho-universal.x86_64.i386:i386
|
||||
CHECK-OBJ: macho-universal.x86_64.i386 (for architecture i386):
|
||||
CHECK-OBJ: 00001fa0 T _main
|
||||
|
||||
CHECK-AR: macho-universal-archive.x86_64.i386:x86_64:hello.o:
|
||||
CHECK-AR: macho-universal-archive.x86_64.i386(hello.o) (for architecture x86_64):
|
||||
CHECK-AR: 0000000000000068 s EH_frame0
|
||||
CHECK-AR: 000000000000003b s L_.str
|
||||
CHECK-AR: 0000000000000000 T _main
|
||||
CHECK-AR: 0000000000000080 S _main.eh
|
||||
CHECK-AR: U _printf
|
||||
CHECK-AR: macho-universal-archive.x86_64.i386:i386:foo.o:
|
||||
CHECK-AR: macho-universal-archive.x86_64.i386(foo.o) (for architecture i386):
|
||||
CHECK-AR: 00000008 S _bar
|
||||
CHECK-AR: 00000000 T _foo
|
||||
|
@ -71,9 +71,9 @@ mxl: Segment __LINKEDIT: 0x1000 (vmaddr 0x100002000 fileoff 8192)
|
||||
mxl: total 0x100003000
|
||||
|
||||
u: __TEXT __DATA __OBJC others dec hex
|
||||
u: 4096 0 0 4294971392 4294975488 100002000 {{.*}}/macho-universal.x86_64.i386:x86_64
|
||||
u: 4096 0 0 8192 12288 3000 {{.*}}/macho-universal.x86_64.i386:i386
|
||||
u: 4096 0 0 4294971392 4294975488 100002000 {{.*}}/macho-universal.x86_64.i386 (for architecture x86_64)
|
||||
u: 4096 0 0 8192 12288 3000 {{.*}}/macho-universal.x86_64.i386 (for architecture i386)
|
||||
|
||||
uAR: __TEXT __DATA __OBJC others dec hex
|
||||
uAR: 136 0 0 32 168 a8 {{.*}}/macho-universal-archive.x86_64.i386:x86_64(hello.o)
|
||||
uAR: 5 4 0 0 9 9 {{.*}}/macho-universal-archive.x86_64.i386:i386(foo.o)
|
||||
uAR: 136 0 0 32 168 a8 {{.*}}/macho-universal-archive.x86_64.i386(hello.o) (for architecture x86_64)
|
||||
uAR: 5 4 0 0 9 9 {{.*}}/macho-universal-archive.x86_64.i386(foo.o) (for architecture i386)
|
||||
|
@ -752,20 +752,28 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
||||
if (ChildOrErr.getError())
|
||||
continue;
|
||||
if (SymbolicFile *O = dyn_cast<SymbolicFile>(&*ChildOrErr.get())) {
|
||||
outs() << O->getFileName() << ":\n";
|
||||
if (isa<MachOObjectFile>(O)) {
|
||||
outs() << Filename << "(" << O->getFileName() << ")";
|
||||
} else
|
||||
outs() << O->getFileName();
|
||||
outs() << ":\n";
|
||||
dumpSymbolNamesFromObject(O);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (MachOUniversalBinary *UB = dyn_cast<MachOUniversalBinary>(Bin.get())) {
|
||||
bool moreThanOneArch = UB->getNumberOfObjects() > 1;
|
||||
for (MachOUniversalBinary::object_iterator I = UB->begin_objects(),
|
||||
E = UB->end_objects();
|
||||
I != E; ++I) {
|
||||
std::unique_ptr<ObjectFile> Obj;
|
||||
std::unique_ptr<Archive> A;
|
||||
if (!I->getAsObjectFile(Obj)) {
|
||||
outs() << Obj->getFileName() << ":\n";
|
||||
outs() << Obj->getFileName();
|
||||
if (isa<MachOObjectFile>(Obj.get()) && moreThanOneArch)
|
||||
outs() << " (for architecture " << I->getArchTypeName() << ")";
|
||||
outs() << ":\n";
|
||||
dumpSymbolNamesFromObject(Obj.get());
|
||||
}
|
||||
else if (!I->getAsArchive(A)) {
|
||||
@ -776,8 +784,14 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
||||
if (ChildOrErr.getError())
|
||||
continue;
|
||||
if (SymbolicFile *O = dyn_cast<SymbolicFile>(&*ChildOrErr.get())) {
|
||||
outs() << A->getFileName() << ":";
|
||||
outs() << O->getFileName() << ":\n";
|
||||
outs() << A->getFileName();
|
||||
if (isa<MachOObjectFile>(O)) {
|
||||
outs() << "(" << O->getFileName() << ")";
|
||||
if (moreThanOneArch)
|
||||
outs() << " (for architecture " << I->getArchTypeName() << ")";
|
||||
} else
|
||||
outs() << ":" << O->getFileName();
|
||||
outs() << ":\n";
|
||||
dumpSymbolNamesFromObject(O);
|
||||
}
|
||||
}
|
||||
|
@ -469,13 +469,20 @@ static void PrintFileSectionSizes(StringRef file) {
|
||||
std::unique_ptr<Archive> UA;
|
||||
if (!I->getAsObjectFile(UO)) {
|
||||
if (ObjectFile *o = dyn_cast<ObjectFile>(&*UO.get())) {
|
||||
MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o);
|
||||
if (OutputFormat == sysv)
|
||||
outs() << o->getFileName() << " :\n";
|
||||
else if(MachO && OutputFormat == darwin) {
|
||||
if (moreThanOneFile || moreThanOneArch)
|
||||
outs() << o->getFileName() << " (for architecture "
|
||||
<< I->getArchTypeName() << "):";
|
||||
outs() << "\n";
|
||||
}
|
||||
PrintObjectSectionSizes(o);
|
||||
if (OutputFormat == berkeley) {
|
||||
MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o);
|
||||
if (!MachO || moreThanOneFile || moreThanOneArch)
|
||||
outs() << o->getFileName();
|
||||
outs() << o->getFileName() << " (for architecture "
|
||||
<< I->getArchTypeName() << ")";
|
||||
outs() << "\n";
|
||||
}
|
||||
}
|
||||
@ -495,11 +502,15 @@ static void PrintFileSectionSizes(StringRef file) {
|
||||
outs() << o->getFileName() << " (ex " << UA->getFileName()
|
||||
<< "):\n";
|
||||
else if(MachO && OutputFormat == darwin)
|
||||
outs() << UA->getFileName() << "(" << o->getFileName() << "):\n";
|
||||
outs() << UA->getFileName() << "(" << o->getFileName() << ")"
|
||||
<< " (for architecture " << I->getArchTypeName()
|
||||
<< "):\n";
|
||||
PrintObjectSectionSizes(o);
|
||||
if (OutputFormat == berkeley) {
|
||||
if (MachO)
|
||||
outs() << UA->getFileName() << "(" << o->getFileName() << ")\n";
|
||||
outs() << UA->getFileName() << "(" << o->getFileName() << ")"
|
||||
<< " (for architecture " << I->getArchTypeName()
|
||||
<< ")\n";
|
||||
else
|
||||
outs() << o->getFileName() << " (ex " << UA->getFileName()
|
||||
<< ")\n";
|
||||
|
Loading…
Reference in New Issue
Block a user