llvm.org GIT mirror llvm / 2ef4e25
Add printing the LC_SUB_LIBRARY load command with llvm-objdump’s -private-headers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224607 91177308-0d34-0410-b5e6-96231b3b80d8 Kevin Enderby 5 years ago
6 changed file(s) with 40 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
371371 getSubFrameworkCommand(const LoadCommandInfo &L) const;
372372 MachO::sub_umbrella_command
373373 getSubUmbrellaCommand(const LoadCommandInfo &L) const;
374 MachO::sub_library_command
375 getSubLibraryCommand(const LoadCommandInfo &L) const;
374376
375377 MachO::any_relocation_info getRelocation(DataRefImpl Rel) const;
376378 MachO::data_in_code_entry getDice(DataRefImpl Rel) const;
11181118 sys::swapByteOrder(s.sub_umbrella);
11191119 }
11201120
1121 inline void swapStruct(sub_library_command &s) {
1122 sys::swapByteOrder(s.cmd);
1123 sys::swapByteOrder(s.cmdsize);
1124 sys::swapByteOrder(s.sub_library);
1125 }
1126
11211127 inline void swapStruct(dylinker_command &d) {
11221128 sys::swapByteOrder(d.cmd);
11231129 sys::swapByteOrder(d.cmdsize);
23212321 return getStruct(this, L.Ptr);
23222322 }
23232323
2324 MachO::sub_library_command
2325 MachOObjectFile::getSubLibraryCommand(const LoadCommandInfo &L) const {
2326 return getStruct(this, L.Ptr);
2327 }
2328
23242329 MachO::any_relocation_info
23252330 MachOObjectFile::getRelocation(DataRefImpl Rel) const {
23262331 DataRefImpl Sec;
88 // RUN: | FileCheck %s -check-prefix=SUB_FRAME
99 // RUN: llvm-objdump -p %p/Inputs/dylibSubUmbrella.macho-x86_64 \
1010 // RUN: | FileCheck %s -check-prefix=SUB_UMB
11 // RUN: llvm-objdump -p %p/Inputs/dylibSubLibrary.macho-x86_64 \
12 // RUN: | FileCheck %s -check-prefix=SUB_LIB
1113
1214 CHECK: Mach header
1315 CHECK: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
392394 SUB_UMB: cmd LC_SUB_UMBRELLA
393395 SUB_UMB: cmdsize 16
394396 SUB_UMB: sub_umbrella Foo (offset 12)
397
398 SUB_LIB: Load command 5
399 SUB_LIB: cmd LC_SUB_LIBRARY
400 SUB_LIB: cmdsize 20
401 SUB_LIB: sub_library libfoo (offset 12)
37053705 }
37063706 }
37073707
3708 static void PrintSubLibraryCommand(MachO::sub_library_command sub,
3709 const char *Ptr) {
3710 outs() << " cmd LC_SUB_LIBRARY\n";
3711 outs() << " cmdsize " << sub.cmdsize;
3712 if (sub.cmdsize < sizeof(struct MachO::sub_library_command))
3713 outs() << " Incorrect size\n";
3714 else
3715 outs() << "\n";
3716 if (sub.sub_library < sub.cmdsize) {
3717 const char *P = Ptr + sub.sub_library;
3718 outs() << " sub_library " << P << " (offset " << sub.sub_library << ")\n";
3719 } else {
3720 outs() << " sub_library ?(bad offset " << sub.sub_library << ")\n";
3721 }
3722 }
3723
3724
37083725 static void PrintDylibCommand(MachO::dylib_command dl, const char *Ptr) {
37093726 if (dl.cmd == MachO::LC_ID_DYLIB)
37103727 outs() << " cmd LC_ID_DYLIB\n";
38673884 } else if (Command.C.cmd == MachO::LC_SUB_UMBRELLA) {
38683885 MachO::sub_umbrella_command Sf = Obj->getSubUmbrellaCommand(Command);
38693886 PrintSubUmbrellaCommand(Sf, Command.Ptr);
3887 } else if (Command.C.cmd == MachO::LC_SUB_LIBRARY) {
3888 MachO::sub_library_command Sl = Obj->getSubLibraryCommand(Command);
3889 PrintSubLibraryCommand(Sl, Command.Ptr);
38703890 } else if (Command.C.cmd == MachO::LC_LOAD_DYLIB ||
38713891 Command.C.cmd == MachO::LC_ID_DYLIB ||
38723892 Command.C.cmd == MachO::LC_LOAD_WEAK_DYLIB ||