llvm.org GIT mirror llvm / 5ebdee5
Add printing the LC_ROUTINES load commands with llvm-objdump’s -private-headers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224627 91177308-0d34-0410-b5e6-96231b3b80d8 Kevin Enderby 4 years ago
6 changed file(s) with 94 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
375375 getSubLibraryCommand(const LoadCommandInfo &L) const;
376376 MachO::sub_client_command
377377 getSubClientCommand(const LoadCommandInfo &L) const;
378 MachO::routines_command
379 getRoutinesCommand(const LoadCommandInfo &L) const;
380 MachO::routines_command_64
381 getRoutinesCommand64(const LoadCommandInfo &L) const;
378382
379383 MachO::any_relocation_info getRelocation(DataRefImpl Rel) const;
380384 MachO::data_in_code_entry getDice(DataRefImpl Rel) const;
11301130 sys::swapByteOrder(s.client);
11311131 }
11321132
1133 inline void swapStruct(routines_command &r) {
1134 sys::swapByteOrder(r.cmd);
1135 sys::swapByteOrder(r.cmdsize);
1136 sys::swapByteOrder(r.init_address);
1137 sys::swapByteOrder(r.init_module);
1138 sys::swapByteOrder(r.reserved1);
1139 sys::swapByteOrder(r.reserved2);
1140 sys::swapByteOrder(r.reserved3);
1141 sys::swapByteOrder(r.reserved4);
1142 sys::swapByteOrder(r.reserved5);
1143 sys::swapByteOrder(r.reserved6);
1144 }
1145
1146 inline void swapStruct(routines_command_64 &r) {
1147 sys::swapByteOrder(r.cmd);
1148 sys::swapByteOrder(r.cmdsize);
1149 sys::swapByteOrder(r.init_address);
1150 sys::swapByteOrder(r.init_module);
1151 sys::swapByteOrder(r.reserved1);
1152 sys::swapByteOrder(r.reserved2);
1153 sys::swapByteOrder(r.reserved3);
1154 sys::swapByteOrder(r.reserved4);
1155 sys::swapByteOrder(r.reserved5);
1156 sys::swapByteOrder(r.reserved6);
1157 }
1158
11331159 inline void swapStruct(dylinker_command &d) {
11341160 sys::swapByteOrder(d.cmd);
11351161 sys::swapByteOrder(d.cmdsize);
23312331 return getStruct(this, L.Ptr);
23322332 }
23332333
2334 MachO::routines_command
2335 MachOObjectFile::getRoutinesCommand(const LoadCommandInfo &L) const {
2336 return getStruct(this, L.Ptr);
2337 }
2338
2339 MachO::routines_command_64
2340 MachOObjectFile::getRoutinesCommand64(const LoadCommandInfo &L) const {
2341 return getStruct(this, L.Ptr);
2342 }
2343
23342344 MachO::any_relocation_info
23352345 MachOObjectFile::getRelocation(DataRefImpl Rel) const {
23362346 DataRefImpl Sec;
1212 // RUN: | FileCheck %s -check-prefix=SUB_LIB
1313 // RUN: llvm-objdump -p %p/Inputs/dylibSubClient.macho-x86_64 \
1414 // RUN: | FileCheck %s -check-prefix=SUB_CLI
15 // RUN: llvm-objdump -p %p/Inputs/dylibRoutines.macho-x86_64 \
16 // RUN: | FileCheck %s -check-prefix=ROUTINE
1517
1618 CHECK: Mach header
1719 CHECK: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
406408 SUB_CLI: cmd LC_SUB_CLIENT
407409 SUB_CLI: cmdsize 16
408410 SUB_CLI: client bar (offset 12)
411
412 ROUTINE: Load command 6
413 ROUTINE: cmd LC_ROUTINES_64
414 ROUTINE: cmdsize 72
415 ROUTINE: init_address 0x0000000000000f80
416 ROUTINE: init_module 0
417 ROUTINE: reserved1 0
418 ROUTINE: reserved2 0
419 ROUTINE: reserved3 0
420 ROUTINE: reserved4 0
421 ROUTINE: reserved5 0
422 ROUTINE: reserved6 0
37373737 }
37383738 }
37393739
3740 static void PrintRoutinesCommand(MachO::routines_command r) {
3741 outs() << " cmd LC_ROUTINES\n";
3742 outs() << " cmdsize " << r.cmdsize;
3743 if (r.cmdsize != sizeof(struct MachO::routines_command))
3744 outs() << " Incorrect size\n";
3745 else
3746 outs() << "\n";
3747 outs() << " init_address " << format("0x%08" PRIx32, r.init_address) << "\n";
3748 outs() << " init_module " << r.init_module << "\n";
3749 outs() << " reserved1 " << r.reserved1 << "\n";
3750 outs() << " reserved2 " << r.reserved2 << "\n";
3751 outs() << " reserved3 " << r.reserved3 << "\n";
3752 outs() << " reserved4 " << r.reserved4 << "\n";
3753 outs() << " reserved5 " << r.reserved5 << "\n";
3754 outs() << " reserved6 " << r.reserved6 << "\n";
3755 }
3756
3757 static void PrintRoutinesCommand64(MachO::routines_command_64 r) {
3758 outs() << " cmd LC_ROUTINES_64\n";
3759 outs() << " cmdsize " << r.cmdsize;
3760 if (r.cmdsize != sizeof(struct MachO::routines_command_64))
3761 outs() << " Incorrect size\n";
3762 else
3763 outs() << "\n";
3764 outs() << " init_address " << format("0x%016" PRIx64, r.init_address) << "\n";
3765 outs() << " init_module " << r.init_module << "\n";
3766 outs() << " reserved1 " << r.reserved1 << "\n";
3767 outs() << " reserved2 " << r.reserved2 << "\n";
3768 outs() << " reserved3 " << r.reserved3 << "\n";
3769 outs() << " reserved4 " << r.reserved4 << "\n";
3770 outs() << " reserved5 " << r.reserved5 << "\n";
3771 outs() << " reserved6 " << r.reserved6 << "\n";
3772 }
3773
37403774 static void PrintDylibCommand(MachO::dylib_command dl, const char *Ptr) {
37413775 if (dl.cmd == MachO::LC_ID_DYLIB)
37423776 outs() << " cmd LC_ID_DYLIB\n";
39053939 } else if (Command.C.cmd == MachO::LC_SUB_CLIENT) {
39063940 MachO::sub_client_command Sc = Obj->getSubClientCommand(Command);
39073941 PrintSubClientCommand(Sc, Command.Ptr);
3942 } else if (Command.C.cmd == MachO::LC_ROUTINES) {
3943 MachO::routines_command Rc = Obj->getRoutinesCommand(Command);
3944 PrintRoutinesCommand(Rc);
3945 } else if (Command.C.cmd == MachO::LC_ROUTINES_64) {
3946 MachO::routines_command_64 Rc = Obj->getRoutinesCommand64(Command);
3947 PrintRoutinesCommand64(Rc);
39083948 } else if (Command.C.cmd == MachO::LC_LOAD_DYLIB ||
39093949 Command.C.cmd == MachO::LC_ID_DYLIB ||
39103950 Command.C.cmd == MachO::LC_LOAD_WEAK_DYLIB ||