Add printing the LC_SUB_CLIENT load command with llvm-objdump’s -private-headers.

llvm-svn: 224616
This commit is contained in:
Kevin Enderby 2014-12-19 21:06:24 +00:00
parent 0e5c068592
commit 186eac3c0c
6 changed files with 38 additions and 0 deletions

View File

@ -374,6 +374,8 @@ public:
getSubUmbrellaCommand(const LoadCommandInfo &L) const; getSubUmbrellaCommand(const LoadCommandInfo &L) const;
MachO::sub_library_command MachO::sub_library_command
getSubLibraryCommand(const LoadCommandInfo &L) const; getSubLibraryCommand(const LoadCommandInfo &L) const;
MachO::sub_client_command
getSubClientCommand(const LoadCommandInfo &L) const;
MachO::any_relocation_info getRelocation(DataRefImpl Rel) const; MachO::any_relocation_info getRelocation(DataRefImpl Rel) const;
MachO::data_in_code_entry getDice(DataRefImpl Rel) const; MachO::data_in_code_entry getDice(DataRefImpl Rel) const;

View File

@ -1125,6 +1125,12 @@ namespace llvm {
sys::swapByteOrder(s.sub_library); sys::swapByteOrder(s.sub_library);
} }
inline void swapStruct(sub_client_command &s) {
sys::swapByteOrder(s.cmd);
sys::swapByteOrder(s.cmdsize);
sys::swapByteOrder(s.client);
}
inline void swapStruct(dylinker_command &d) { inline void swapStruct(dylinker_command &d) {
sys::swapByteOrder(d.cmd); sys::swapByteOrder(d.cmd);
sys::swapByteOrder(d.cmdsize); sys::swapByteOrder(d.cmdsize);

View File

@ -2327,6 +2327,11 @@ MachOObjectFile::getSubLibraryCommand(const LoadCommandInfo &L) const {
return getStruct<MachO::sub_library_command>(this, L.Ptr); return getStruct<MachO::sub_library_command>(this, L.Ptr);
} }
MachO::sub_client_command
MachOObjectFile::getSubClientCommand(const LoadCommandInfo &L) const {
return getStruct<MachO::sub_client_command>(this, L.Ptr);
}
MachO::any_relocation_info MachO::any_relocation_info
MachOObjectFile::getRelocation(DataRefImpl Rel) const { MachOObjectFile::getRelocation(DataRefImpl Rel) const {
DataRefImpl Sec; DataRefImpl Sec;

View File

@ -11,6 +11,8 @@
// RUN: | FileCheck %s -check-prefix=SUB_UMB // RUN: | FileCheck %s -check-prefix=SUB_UMB
// RUN: llvm-objdump -p %p/Inputs/dylibSubLibrary.macho-x86_64 \ // RUN: llvm-objdump -p %p/Inputs/dylibSubLibrary.macho-x86_64 \
// RUN: | FileCheck %s -check-prefix=SUB_LIB // RUN: | FileCheck %s -check-prefix=SUB_LIB
// RUN: llvm-objdump -p %p/Inputs/dylibSubClient.macho-x86_64 \
// RUN: | FileCheck %s -check-prefix=SUB_CLI
CHECK: Mach header CHECK: Mach header
CHECK: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags CHECK: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
@ -400,3 +402,8 @@ SUB_LIB: Load command 5
SUB_LIB: cmd LC_SUB_LIBRARY SUB_LIB: cmd LC_SUB_LIBRARY
SUB_LIB: cmdsize 20 SUB_LIB: cmdsize 20
SUB_LIB: sub_library libfoo (offset 12) SUB_LIB: sub_library libfoo (offset 12)
SUB_CLI: Load command 10
SUB_CLI: cmd LC_SUB_CLIENT
SUB_CLI: cmdsize 16
SUB_CLI: client bar (offset 12)

View File

@ -3722,6 +3722,21 @@ static void PrintSubLibraryCommand(MachO::sub_library_command sub,
} }
} }
static void PrintSubClientCommand(MachO::sub_client_command sub,
const char *Ptr) {
outs() << " cmd LC_SUB_CLIENT\n";
outs() << " cmdsize " << sub.cmdsize;
if (sub.cmdsize < sizeof(struct MachO::sub_client_command))
outs() << " Incorrect size\n";
else
outs() << "\n";
if (sub.client < sub.cmdsize) {
const char *P = Ptr + sub.client;
outs() << " client " << P << " (offset " << sub.client << ")\n";
} else {
outs() << " client ?(bad offset " << sub.client << ")\n";
}
}
static void PrintDylibCommand(MachO::dylib_command dl, const char *Ptr) { static void PrintDylibCommand(MachO::dylib_command dl, const char *Ptr) {
if (dl.cmd == MachO::LC_ID_DYLIB) if (dl.cmd == MachO::LC_ID_DYLIB)
@ -3888,6 +3903,9 @@ static void PrintLoadCommands(const MachOObjectFile *Obj, uint32_t ncmds,
} else if (Command.C.cmd == MachO::LC_SUB_LIBRARY) { } else if (Command.C.cmd == MachO::LC_SUB_LIBRARY) {
MachO::sub_library_command Sl = Obj->getSubLibraryCommand(Command); MachO::sub_library_command Sl = Obj->getSubLibraryCommand(Command);
PrintSubLibraryCommand(Sl, Command.Ptr); PrintSubLibraryCommand(Sl, Command.Ptr);
} else if (Command.C.cmd == MachO::LC_SUB_CLIENT) {
MachO::sub_client_command Sc = Obj->getSubClientCommand(Command);
PrintSubClientCommand(Sc, Command.Ptr);
} else if (Command.C.cmd == MachO::LC_LOAD_DYLIB || } else if (Command.C.cmd == MachO::LC_LOAD_DYLIB ||
Command.C.cmd == MachO::LC_ID_DYLIB || Command.C.cmd == MachO::LC_ID_DYLIB ||
Command.C.cmd == MachO::LC_LOAD_WEAK_DYLIB || Command.C.cmd == MachO::LC_LOAD_WEAK_DYLIB ||