From 604a34e086da0f08c46e56fb64a48bf4ab77b316 Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Thu, 18 Dec 2014 23:13:26 +0000 Subject: [PATCH] =?utf8?q?Add=20printing=20the=20LC=5FSUB=5FUMBRELLA=20loa?= =?utf8?q?d=20command=20with=20llvm-objdump=E2=80=99s=20-private-headers.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224548 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/MachO.h | 2 ++ include/llvm/Support/MachO.h | 6 ++++++ lib/Object/MachOObjectFile.cpp | 5 +++++ .../X86/Inputs/dylibSubUmbrella.macho-x86_64 | Bin 0 -> 4220 bytes .../X86/macho-private-headers.test | 7 +++++++ tools/llvm-objdump/MachODump.cpp | 19 ++++++++++++++++++ 6 files changed, 39 insertions(+) create mode 100755 test/tools/llvm-objdump/X86/Inputs/dylibSubUmbrella.macho-x86_64 diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h index 2cab6c49898..494b62217f1 100644 --- a/include/llvm/Object/MachO.h +++ b/include/llvm/Object/MachO.h @@ -370,6 +370,8 @@ public: getEncryptionInfoCommand64(const LoadCommandInfo &L) const; MachO::sub_framework_command getSubFrameworkCommand(const LoadCommandInfo &L) const; + MachO::sub_umbrella_command + getSubUmbrellaCommand(const LoadCommandInfo &L) const; MachO::any_relocation_info getRelocation(DataRefImpl Rel) const; MachO::data_in_code_entry getDice(DataRefImpl Rel) const; diff --git a/include/llvm/Support/MachO.h b/include/llvm/Support/MachO.h index e2af2d9fc76..4a1c059e28d 100644 --- a/include/llvm/Support/MachO.h +++ b/include/llvm/Support/MachO.h @@ -1113,6 +1113,12 @@ namespace llvm { sys::swapByteOrder(s.umbrella); } + inline void swapStruct(sub_umbrella_command &s) { + sys::swapByteOrder(s.cmd); + sys::swapByteOrder(s.cmdsize); + sys::swapByteOrder(s.sub_umbrella); + }; + inline void swapStruct(dylinker_command &d) { sys::swapByteOrder(d.cmd); sys::swapByteOrder(d.cmdsize); diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp index a5031f17939..fd086af6d52 100644 --- a/lib/Object/MachOObjectFile.cpp +++ b/lib/Object/MachOObjectFile.cpp @@ -2314,6 +2314,11 @@ MachOObjectFile::getSubFrameworkCommand(const LoadCommandInfo &L) const { return getStruct(this, L.Ptr); } +MachO::sub_umbrella_command +MachOObjectFile::getSubUmbrellaCommand(const LoadCommandInfo &L) const { + return getStruct(this, L.Ptr); +} + MachO::any_relocation_info MachOObjectFile::getRelocation(DataRefImpl Rel) const { DataRefImpl Sec; diff --git a/test/tools/llvm-objdump/X86/Inputs/dylibSubUmbrella.macho-x86_64 b/test/tools/llvm-objdump/X86/Inputs/dylibSubUmbrella.macho-x86_64 new file mode 100755 index 0000000000000000000000000000000000000000..1e42a4f4ebbcc0d2a674f037c6d20b8183d4ec98 GIT binary patch literal 4220 zcmeHKJxjw-6unlf6+bE}(!s&O!9kkURk4L)5wWef$TPtdgVw-HKno5+ad7r0+1Y;~ zI4E=w1PALmZ61yO1>c3k{eHPQ+j;(a|DF<&abOad2D)P+_iG|>atkO`FCEtrq-`Nd z;JKd#I8Re5_HW{0Jj{RZ_wpiKr=J*&@qjy%@~tgEscL0^ue4h+-{)ci-p0Glclp*F zumKc+M(xpT$z|Yqt}dRn5uhcrzyZLykHgWNQ)@@D-*T#fr(NB4%Gz!D*P*_MoN^cz znsYhRpe~5A&Yp2XYt(~SIbf=XFr3S-{KJCbNFTW8Gv`BjsIh?jycAgi9dzs zzOmJ$Zt@ibC`sW@-Sn-u3|Iy%1C{~HfMvikU>UFsSOzQumVy7lK;z-1^Ok$f_WJ!! zH+S+x&76n8q!y?4M@YFjuus&GP*M+UKJjKCtwY%|^<>PrjHxRqa8XUDVM_5(egLc$ BMy>z= literal 0 HcmV?d00001 diff --git a/test/tools/llvm-objdump/X86/macho-private-headers.test b/test/tools/llvm-objdump/X86/macho-private-headers.test index bbb90863fa8..c2023527bab 100644 --- a/test/tools/llvm-objdump/X86/macho-private-headers.test +++ b/test/tools/llvm-objdump/X86/macho-private-headers.test @@ -7,6 +7,8 @@ // RUN: | FileCheck %s -check-prefix=LD_OPT // RUN: llvm-objdump -p %p/Inputs/dylibSubFramework.macho-x86_64 \ // RUN: | FileCheck %s -check-prefix=SUB_FRAME +// RUN: llvm-objdump -p %p/Inputs/dylibSubUmbrella.macho-x86_64 \ +// RUN: | FileCheck %s -check-prefix=SUB_UMB CHECK: Mach header CHECK: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags @@ -386,3 +388,8 @@ SUB_FRAME: Load command 10 SUB_FRAME: cmd LC_SUB_FRAMEWORK SUB_FRAME: cmdsize 16 SUB_FRAME: umbrella Bar (offset 12) + +SUB_UMB: Load command 5 +SUB_UMB: cmd LC_SUB_UMBRELLA +SUB_UMB: cmdsize 16 +SUB_UMB: sub_umbrella Foo (offset 12) diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp index f5feeed3171..c2a825fa8b9 100644 --- a/tools/llvm-objdump/MachODump.cpp +++ b/tools/llvm-objdump/MachODump.cpp @@ -3690,6 +3690,22 @@ static void PrintSubFrameworkCommand(MachO::sub_framework_command sub, } } +static void PrintSubUmbrellaCommand(MachO::sub_umbrella_command sub, + const char *Ptr) { + outs() << " cmd LC_SUB_UMBRELLA\n"; + outs() << " cmdsize " << sub.cmdsize; + if (sub.cmdsize < sizeof(struct MachO::sub_umbrella_command)) + outs() << " Incorrect size\n"; + else + outs() << "\n"; + if (sub.sub_umbrella < sub.cmdsize) { + const char *P = Ptr + sub.sub_umbrella; + outs() << " sub_umbrella " << P << " (offset " << sub.sub_umbrella << ")\n"; + } else { + outs() << " sub_umbrella ?(bad offset " << sub.sub_umbrella << ")\n"; + } +} + static void PrintDylibCommand(MachO::dylib_command dl, const char *Ptr) { if (dl.cmd == MachO::LC_ID_DYLIB) outs() << " cmd LC_ID_DYLIB\n"; @@ -3849,6 +3865,9 @@ static void PrintLoadCommands(const MachOObjectFile *Obj, uint32_t ncmds, } else if (Command.C.cmd == MachO::LC_SUB_FRAMEWORK) { MachO::sub_framework_command Sf = Obj->getSubFrameworkCommand(Command); PrintSubFrameworkCommand(Sf, Command.Ptr); + } else if (Command.C.cmd == MachO::LC_SUB_UMBRELLA) { + MachO::sub_umbrella_command Sf = Obj->getSubUmbrellaCommand(Command); + PrintSubUmbrellaCommand(Sf, Command.Ptr); } else if (Command.C.cmd == MachO::LC_LOAD_DYLIB || Command.C.cmd == MachO::LC_ID_DYLIB || Command.C.cmd == MachO::LC_LOAD_WEAK_DYLIB || -- 2.34.1