Skip to content

Commit 693b020

Browse files
committed
[llvm-objdump/mac] Add support for new load commands
Differential Revision: https://reviews.llvm.org/D113733
1 parent 78d6009 commit 693b020

File tree

2 files changed

+252
-1
lines changed

2 files changed

+252
-1
lines changed
Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
# RUN: yaml2obj %s -o %t
2+
# RUN: llvm-objdump -p %t | FileCheck %s
3+
# RUN: llvm-otool -l %t | FileCheck %s
4+
#
5+
# CHECK: LC_DYLD_CHAINED_FIXUPS
6+
# CHECK: LC_DYLD_EXPORTS_TRIE
7+
8+
--- !mach-o
9+
FileHeader:
10+
magic: 0xFEEDFACF
11+
cputype: 0x100000C
12+
cpusubtype: 0x0
13+
filetype: 0x2
14+
ncmds: 16
15+
sizeofcmds: 744
16+
flags: 0x200085
17+
reserved: 0x0
18+
LoadCommands:
19+
- cmd: LC_SEGMENT_64
20+
cmdsize: 72
21+
segname: __PAGEZERO
22+
vmaddr: 0
23+
vmsize: 4294967296
24+
fileoff: 0
25+
filesize: 0
26+
maxprot: 0
27+
initprot: 0
28+
nsects: 0
29+
flags: 0
30+
- cmd: LC_SEGMENT_64
31+
cmdsize: 232
32+
segname: __TEXT
33+
vmaddr: 4294967296
34+
vmsize: 16384
35+
fileoff: 0
36+
filesize: 16384
37+
maxprot: 5
38+
initprot: 5
39+
nsects: 2
40+
flags: 0
41+
Sections:
42+
- sectname: __text
43+
segname: __TEXT
44+
addr: 0x100003F98
45+
size: 24
46+
offset: 0x3F98
47+
align: 2
48+
reloff: 0x0
49+
nreloc: 0
50+
flags: 0x80000400
51+
reserved1: 0x0
52+
reserved2: 0x0
53+
reserved3: 0x0
54+
content: C0035FD6FF4300D100008052FF0F00B9FF430091C0035FD6
55+
- sectname: __unwind_info
56+
segname: __TEXT
57+
addr: 0x100003FB0
58+
size: 80
59+
offset: 0x3FB0
60+
align: 2
61+
reloff: 0x0
62+
nreloc: 0
63+
flags: 0x0
64+
reserved1: 0x0
65+
reserved2: 0x0
66+
reserved3: 0x0
67+
content: 010000001C000000000000001C000000000000001C00000002000000983F00003400000034000000B13F00000000000034000000030000000C0002001400020000000001040000000010000200000002
68+
- cmd: LC_SEGMENT_64
69+
cmdsize: 72
70+
segname: __LINKEDIT
71+
vmaddr: 4294983680
72+
vmsize: 16384
73+
fileoff: 16384
74+
filesize: 753
75+
maxprot: 1
76+
initprot: 1
77+
nsects: 0
78+
flags: 0
79+
- cmd: LC_DYLD_CHAINED_FIXUPS
80+
cmdsize: 16
81+
dataoff: 16384
82+
datasize: 56
83+
- cmd: LC_DYLD_EXPORTS_TRIE
84+
cmdsize: 16
85+
dataoff: 16440
86+
datasize: 56
87+
- cmd: LC_SYMTAB
88+
cmdsize: 24
89+
symoff: 16504
90+
nsyms: 15
91+
stroff: 16744
92+
strsize: 120
93+
- cmd: LC_DYSYMTAB
94+
cmdsize: 80
95+
ilocalsym: 0
96+
nlocalsym: 12
97+
iextdefsym: 12
98+
nextdefsym: 3
99+
iundefsym: 15
100+
nundefsym: 0
101+
tocoff: 0
102+
ntoc: 0
103+
modtaboff: 0
104+
nmodtab: 0
105+
extrefsymoff: 0
106+
nextrefsyms: 0
107+
indirectsymoff: 0
108+
nindirectsyms: 0
109+
extreloff: 0
110+
nextrel: 0
111+
locreloff: 0
112+
nlocrel: 0
113+
- cmd: LC_LOAD_DYLINKER
114+
cmdsize: 32
115+
name: 12
116+
Content: '/usr/lib/dyld'
117+
ZeroPadBytes: 7
118+
- cmd: LC_UUID
119+
cmdsize: 24
120+
uuid: F445529E-643C-3A38-8F59-AB64566BCAFF
121+
- cmd: LC_BUILD_VERSION
122+
cmdsize: 32
123+
platform: 1
124+
minos: 786432
125+
sdk: 786432
126+
ntools: 1
127+
Tools:
128+
- tool: 3
129+
version: 46596096
130+
- cmd: LC_SOURCE_VERSION
131+
cmdsize: 16
132+
version: 0
133+
- cmd: LC_MAIN
134+
cmdsize: 24
135+
entryoff: 16284
136+
stacksize: 0
137+
- cmd: LC_LOAD_DYLIB
138+
cmdsize: 56
139+
dylib:
140+
name: 24
141+
timestamp: 2
142+
current_version: 85917696
143+
compatibility_version: 65536
144+
Content: '/usr/lib/libSystem.B.dylib'
145+
ZeroPadBytes: 6
146+
- cmd: LC_FUNCTION_STARTS
147+
cmdsize: 16
148+
dataoff: 16496
149+
datasize: 8
150+
- cmd: LC_DATA_IN_CODE
151+
cmdsize: 16
152+
dataoff: 16504
153+
datasize: 0
154+
- cmd: LC_CODE_SIGNATURE
155+
cmdsize: 16
156+
dataoff: 16864
157+
datasize: 273
158+
LinkEditData:
159+
NameList:
160+
- n_strx: 33
161+
n_type: 0x64
162+
n_sect: 0
163+
n_desc: 0
164+
n_value: 0
165+
- n_strx: 39
166+
n_type: 0x64
167+
n_sect: 0
168+
n_desc: 0
169+
n_value: 0
170+
- n_strx: 46
171+
n_type: 0x66
172+
n_sect: 0
173+
n_desc: 1
174+
n_value: 1636754403
175+
- n_strx: 1
176+
n_type: 0x2E
177+
n_sect: 1
178+
n_desc: 0
179+
n_value: 4294983576
180+
- n_strx: 109
181+
n_type: 0x24
182+
n_sect: 1
183+
n_desc: 0
184+
n_value: 4294983576
185+
- n_strx: 1
186+
n_type: 0x24
187+
n_sect: 0
188+
n_desc: 0
189+
n_value: 4
190+
- n_strx: 1
191+
n_type: 0x4E
192+
n_sect: 1
193+
n_desc: 0
194+
n_value: 4
195+
- n_strx: 1
196+
n_type: 0x2E
197+
n_sect: 1
198+
n_desc: 0
199+
n_value: 4294983580
200+
- n_strx: 114
201+
n_type: 0x24
202+
n_sect: 1
203+
n_desc: 0
204+
n_value: 4294983580
205+
- n_strx: 1
206+
n_type: 0x24
207+
n_sect: 0
208+
n_desc: 0
209+
n_value: 20
210+
- n_strx: 1
211+
n_type: 0x4E
212+
n_sect: 1
213+
n_desc: 0
214+
n_value: 20
215+
- n_strx: 1
216+
n_type: 0x64
217+
n_sect: 1
218+
n_desc: 0
219+
n_value: 0
220+
- n_strx: 2
221+
n_type: 0xF
222+
n_sect: 1
223+
n_desc: 16
224+
n_value: 4294967296
225+
- n_strx: 22
226+
n_type: 0xF
227+
n_sect: 1
228+
n_desc: 0
229+
n_value: 4294983576
230+
- n_strx: 27
231+
n_type: 0xF
232+
n_sect: 1
233+
n_desc: 0
234+
n_value: 4294983580
235+
StringTable:
236+
- ' '
237+
- __mh_execute_header
238+
- _foo
239+
- _main
240+
- '/tmp/'
241+
- main.c
242+
- '/var/folders/gj/wf3swl0x215b2sq1qy84kzkm0000gn/T/main-e32fe7.o'
243+
- _foo
244+
- _main
245+
...

llvm/tools/llvm-objdump/MachODump.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10053,6 +10053,10 @@ static void PrintLinkEditDataCommand(MachO::linkedit_data_command ld,
1005310053
outs() << " cmd LC_DYLIB_CODE_SIGN_DRS\n";
1005410054
else if (ld.cmd == MachO::LC_LINKER_OPTIMIZATION_HINT)
1005510055
outs() << " cmd LC_LINKER_OPTIMIZATION_HINT\n";
10056+
else if (ld.cmd == MachO::LC_DYLD_EXPORTS_TRIE)
10057+
outs() << " cmd LC_DYLD_EXPORTS_TRIE\n";
10058+
else if (ld.cmd == MachO::LC_DYLD_CHAINED_FIXUPS)
10059+
outs() << " cmd LC_DYLD_CHAINED_FIXUPS\n";
1005610060
else
1005710061
outs() << " cmd " << ld.cmd << " (?)\n";
1005810062
outs() << " cmdsize " << ld.cmdsize;
@@ -10196,7 +10200,9 @@ static void PrintLoadCommands(const MachOObjectFile *Obj, uint32_t filetype,
1019610200
Command.C.cmd == MachO::LC_FUNCTION_STARTS ||
1019710201
Command.C.cmd == MachO::LC_DATA_IN_CODE ||
1019810202
Command.C.cmd == MachO::LC_DYLIB_CODE_SIGN_DRS ||
10199-
Command.C.cmd == MachO::LC_LINKER_OPTIMIZATION_HINT) {
10203+
Command.C.cmd == MachO::LC_LINKER_OPTIMIZATION_HINT ||
10204+
Command.C.cmd == MachO::LC_DYLD_EXPORTS_TRIE ||
10205+
Command.C.cmd == MachO::LC_DYLD_CHAINED_FIXUPS) {
1020010206
MachO::linkedit_data_command Ld =
1020110207
Obj->getLinkeditDataLoadCommand(Command);
1020210208
PrintLinkEditDataCommand(Ld, Buf.size());

0 commit comments

Comments
 (0)