1 This README describes a sample invocation of disasm.py whose purpose is to test
2 the low level ARM/Thumb disassembly functionality from llvm using the llvm-mc
3 command line. We invoke gdb on an executable, try to disassemble a function,
4 and then read the memory contents of the disassembled function.
5
6 The byte contents are written into a file named disasm-input.txt and then we
7 invoke llvm-mc -disassemble plus options (set with the -o/--options) on the
8 byte contents.
9
10 See the following for a sample session using this command:
11
12 [16:26:57] johnny:/Volumes/data/Radar/9131529 $ /Volumes/data/lldb/svn/trunk/utils/test/disasm.py -C 'set shlib-path-substitutions /usr /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr /System /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System /Library /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/Library' -O '-arch armv7' -m /Volumes/data/lldb/llvm/Debug+Asserts/bin/llvm-mc -e /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib -f printf --options='-triple=thumb-apple-darwin -debug-only=arm-disassembler'
13 gdb commands: ['set shlib-path-substitutions /usr /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr /System /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System /Library /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/Library']
14 gdb options: -arch armv7
15 executable: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib
16 function: printf
17 llvm-mc: /Volumes/data/lldb/llvm/Debug+Asserts/bin/llvm-mc
18 llvm-mc options: -triple=thumb-apple-darwin -debug-only=arm-disassembler
19 GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:56:02 UTC 2011)
20 Copyright 2004 Free Software Foundation, Inc.
21 GDB is free software, covered by the GNU General Public License, and you are
22 welcome to change it and/or distribute copies of it under certain conditions.
23 Type "show copying" to see the conditions.
24 There is absolutely no warranty for GDB. Type "show warranty" for details.
25 This GDB was configured as "--host=x86_64-apple-darwin --target=arm-apple-darwin".
26 <Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/Library
27 <eloper/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib
28 Reading symbols for shared libraries ................ done
29 Reading symbols from /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib...done.
30 (gdb) disassemble printf
31 Dump of assembler code for function printf:
32 0x0704cdd0 <printf+0>: push {r0, r1, r2, r3}
33 0x0704cdd2 <printf+2>: push {r4, r5, r7, lr}
34 0x0704cdd4 <printf+4>: add r7, sp, #8
35 0x0704cdd6 <printf+6>: sub sp, #4
36 0x0704cdd8 <printf+8>: add r3, sp, #20
37 0x0704cdda <printf+10>: ldr.w r5, [r3], #4
38 0x0704cdde <printf+14>: str r3, [sp, #0]
39 0x0704cde0 <printf+16>: ldr r3, [pc, #52] (0x704ce18 <printf+72>)
40 0x0704cde2 <printf+18>: add r3, pc
41 0x0704cde4 <printf+20>: ldr r0, [r3, #0]
42 0x0704cde6 <printf+22>: ldr r4, [r0, #0]
43 0x0704cde8 <printf+24>: ldr r0, [pc, #48] (0x704ce1c <printf+76>)
44 0x0704cdea <printf+26>: add r0, pc
45 0x0704cdec <printf+28>: ldr r0, [r0, #0]
46 0x0704cdee <printf+30>: ldr r0, [r0, #0]
47 0x0704cdf0 <printf+32>: blx 0x707ba30 <pthread_getspecific>
48 0x0704cdf4 <printf+36>: cbnz r0, 0x704cdfe <printf+46>
49 0x0704cdf6 <printf+38>: ldr r1, [pc, #40] (0x704ce20 <printf+80>)
50 0x0704cdf8 <printf+40>: add r1, pc
51 0x0704cdfa <printf+42>: ldr r1, [r1, #0]
52 0x0704cdfc <printf+44>: b.n 0x704ce00 <printf+48>
53 0x0704cdfe <printf+46>: mov r1, r0
54 0x0704ce00 <printf+48>: mov r0, r4
55 0x0704ce02 <printf+50>: mov r2, r5
56 0x0704ce04 <printf+52>: ldr r3, [sp, #0]
57 0x0704ce06 <printf+54>: bl 0x704ad44 <vfprintf_l>
58 0x0704ce0a <printf+58>: sub.w sp, r7, #8 ; 0x8
59 0x0704ce0e <printf+62>: ldmia.w sp!, {r4, r5, r7, lr}
60 0x0704ce12 <printf+66>: add sp, #16
61 0x0704ce14 <printf+68>: bx lr
62 0x0704ce16 <printf+70>: nop
63 0x0704ce18 <printf+72>: movs r3, #142
64 0x0704ce1a <printf+74>: lsls r5, r0, #0
65 0x0704ce1c <printf+76>: adds r1, #122
66 0x0704ce1e <printf+78>: lsls r5, r0, #0
67 0x0704ce20 <printf+80>: adds r1, #104
68 0x0704ce22 <printf+82>: lsls r5, r0, #0
69 End of assembler dump.
70 (gdb) x /2b 0x0704cdd0
71 0x704cdd0 <printf>: 0x0f 0xb4
72 (gdb) x /2b 0x0704cdd2
73 0x704cdd2 <printf+2>: 0xb0 0xb5
74 (gdb) x /2b 0x0704cdd4
75 0x704cdd4 <printf+4>: 0x02 0xaf
76 (gdb) x /2b 0x0704cdd6
77 0x704cdd6 <printf+6>: 0x81 0xb0
78 (gdb) x /2b 0x0704cdd8
79 0x704cdd8 <printf+8>: 0x05 0xab
80 (gdb) x /4b 0x0704cdda
81 0x704cdda <printf+10>: 0x53 0xf8 0x04 0x5b
82 (gdb) x /2b 0x0704cdde
83 0x704cdde <printf+14>: 0x00 0x93
84 (gdb) x /2b 0x0704cde0
85 0x704cde0 <printf+16>: 0x0d 0x4b
86 (gdb) x /2b 0x0704cde2
87 0x704cde2 <printf+18>: 0x7b 0x44
88 (gdb) x /2b 0x0704cde4
89 0x704cde4 <printf+20>: 0x18 0x68
90 (gdb) x /2b 0x0704cde6
91 0x704cde6 <printf+22>: 0x04 0x68
92 (gdb) x /2b 0x0704cde8
93 0x704cde8 <printf+24>: 0x0c 0x48
94 (gdb) x /2b 0x0704cdea
95 0x704cdea <printf+26>: 0x78 0x44
96 (gdb) x /2b 0x0704cdec
97 0x704cdec <printf+28>: 0x00 0x68
98 (gdb) x /2b 0x0704cdee
99 0x704cdee <printf+30>: 0x00 0x68
100 (gdb) x /4b 0x0704cdf0
101 0x704cdf0 <printf+32>: 0x2e 0xf0 0x1e 0xee
102 (gdb) x /2b 0x0704cdf4
103 0x704cdf4 <printf+36>: 0x18 0xb9
104 (gdb) x /2b 0x0704cdf6
105 0x704cdf6 <printf+38>: 0x0a 0x49
106 (gdb) x /2b 0x0704cdf8
107 0x704cdf8 <printf+40>: 0x79 0x44
108 (gdb) x /2b 0x0704cdfa
109 0x704cdfa <printf+42>: 0x09 0x68
110 (gdb) x /2b 0x0704cdfc
111 0x704cdfc <printf+44>: 0x00 0xe0
112 (gdb) x /2b 0x0704cdfe
113 0x704cdfe <printf+46>: 0x01 0x46
114 (gdb) x /2b 0x0704ce00
115 0x704ce00 <printf+48>: 0x20 0x46
116 (gdb) x /2b 0x0704ce02
117 0x704ce02 <printf+50>: 0x2a 0x46
118 (gdb) x /2b 0x0704ce04
119 0x704ce04 <printf+52>: 0x00 0x9b
120 (gdb) x /4b 0x0704ce06
121 0x704ce06 <printf+54>: 0xfd 0xf7 0x9d 0xff
122 (gdb) x /4b 0x0704ce0a
123 0x704ce0a <printf+58>: 0xa7 0xf1 0x08 0x0d
124 (gdb) x /4b 0x0704ce0e
125 0x704ce0e <printf+62>: 0xbd 0xe8 0xb0 0x40
126 (gdb) x /2b 0x0704ce12
127 0x704ce12 <printf+66>: 0x04 0xb0
128 (gdb) x /2b 0x0704ce14
129 0x704ce14 <printf+68>: 0x70 0x47
130 (gdb) x /2b 0x0704ce16
131 0x704ce16 <printf+70>: 0x00 0xbf
132 (gdb) x /2b 0x0704ce18
133 0x704ce18 <printf+72>: 0x8e 0x23
134 (gdb) x /2b 0x0704ce1a
135 0x704ce1a <printf+74>: 0x05 0x00
136 (gdb) x /2b 0x0704ce1c
137 0x704ce1c <printf+76>: 0x7a 0x31
138 (gdb) x /2b 0x0704ce1e
139 0x704ce1e <printf+78>: 0x05 0x00
140 (gdb) x /2b 0x0704ce20
141 0x704ce20 <printf+80>: 0x68 0x31
142 (gdb) x /2b 0x0704ce22
143 0x704ce22 <printf+82>: 0x05 0x00
144 (gdb) quit
145
146 Executing command: /Volumes/data/lldb/llvm/Debug+Asserts/bin/llvm-mc -disassemble -triple=thumb-apple-darwin -debug-only=arm-disassembler disasm-input.txt
147 Opcode=2305 Name=tPUSH Format=ARM_FORMAT_THUMBFRM(25)
148 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
149 -------------------------------------------------------------------------------------------------
150 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 1: 1| 0: 1: 0: 0| 0: 0: 0: 0| 1: 1: 1: 1|
151 -------------------------------------------------------------------------------------------------
152
153 push {r0, r1, r2, r3}
154 Opcode=2305 Name=tPUSH Format=ARM_FORMAT_THUMBFRM(25)
155 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
156 -------------------------------------------------------------------------------------------------
157 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 1: 1| 0: 1: 0: 1| 1: 0: 1: 1| 0: 0: 0: 0|
158 -------------------------------------------------------------------------------------------------
159
160 push {r4, r5, r7, lr}
161 Opcode=2228 Name=tADDrSPi Format=ARM_FORMAT_THUMBFRM(25)
162 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
163 -------------------------------------------------------------------------------------------------
164 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 1: 0| 1: 1: 1: 1| 0: 0: 0: 0| 0: 0: 1: 0|
165 -------------------------------------------------------------------------------------------------
166
167 add r7, sp, #8
168 Opcode=2328 Name=tSUBspi Format=ARM_FORMAT_THUMBFRM(25)
169 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
170 -------------------------------------------------------------------------------------------------
171 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 1: 1| 0: 0: 0: 0| 1: 0: 0: 0| 0: 0: 0: 1|
172 -------------------------------------------------------------------------------------------------
173
174 sub sp, #4
175 Opcode=2228 Name=tADDrSPi Format=ARM_FORMAT_THUMBFRM(25)
176 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
177 -------------------------------------------------------------------------------------------------
178 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 1: 0| 1: 0: 1: 1| 0: 0: 0: 0| 0: 1: 0: 1|
179 -------------------------------------------------------------------------------------------------
180
181 add r3, sp, #20
182 Opcode=1963 Name=t2LDR_POST Format=ARM_FORMAT_THUMBFRM(25)
183 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
184 -------------------------------------------------------------------------------------------------
185 | 1: 1: 1: 1| 1: 0: 0: 0| 0: 1: 0: 1| 0: 0: 1: 1| 0: 1: 0: 1| 1: 0: 1: 1| 0: 0: 0: 0| 0: 1: 0: 0|
186 -------------------------------------------------------------------------------------------------
187
188 ldr r5, [r3], #4
189 Opcode=2324 Name=tSTRspi Format=ARM_FORMAT_THUMBFRM(25)
190 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
191 -------------------------------------------------------------------------------------------------
192 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 0: 1| 0: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0|
193 -------------------------------------------------------------------------------------------------
194
195 str r3, [sp]
196 Opcode=2275 Name=tLDRpci Format=ARM_FORMAT_THUMBFRM(25)
197 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
198 -------------------------------------------------------------------------------------------------
199 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 1: 0: 1: 1| 0: 0: 0: 0| 1: 1: 0: 1|
200 -------------------------------------------------------------------------------------------------
201
202 ldr.n r3, #52
203 Opcode=2223 Name=tADDhirr Format=ARM_FORMAT_THUMBFRM(25)
204 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
205 -------------------------------------------------------------------------------------------------
206 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 0: 1: 0: 0| 0: 1: 1: 1| 1: 0: 1: 1|
207 -------------------------------------------------------------------------------------------------
208
209 add r3, pc
210 Opcode=2274 Name=tLDRi Format=ARM_FORMAT_THUMBFRM(25)
211 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
212 -------------------------------------------------------------------------------------------------
213 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 1: 0| 1: 0: 0: 0| 0: 0: 0: 1| 1: 0: 0: 0|
214 -------------------------------------------------------------------------------------------------
215
216 ldr r0, [r3]
217 Opcode=2274 Name=tLDRi Format=ARM_FORMAT_THUMBFRM(25)
218 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
219 -------------------------------------------------------------------------------------------------
220 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 1: 0| 1: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0|
221 -------------------------------------------------------------------------------------------------
222
223 ldr r4, [r0]
224 Opcode=2275 Name=tLDRpci Format=ARM_FORMAT_THUMBFRM(25)
225 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
226 -------------------------------------------------------------------------------------------------
227 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 1: 0: 0: 0| 0: 0: 0: 0| 1: 1: 0: 0|
228 -------------------------------------------------------------------------------------------------
229
230 ldr.n r0, #48
231 Opcode=2223 Name=tADDhirr Format=ARM_FORMAT_THUMBFRM(25)
232 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
233 -------------------------------------------------------------------------------------------------
234 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 0: 1: 0: 0| 0: 1: 1: 1| 1: 0: 0: 0|
235 -------------------------------------------------------------------------------------------------
236
237 add r0, pc
238 Opcode=2274 Name=tLDRi Format=ARM_FORMAT_THUMBFRM(25)
239 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
240 -------------------------------------------------------------------------------------------------
241 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 1: 0| 1: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0|
242 -------------------------------------------------------------------------------------------------
243
244 ldr r0, [r0]
245 Opcode=2274 Name=tLDRi Format=ARM_FORMAT_THUMBFRM(25)
246 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
247 -------------------------------------------------------------------------------------------------
248 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 1: 0| 1: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0|
249 -------------------------------------------------------------------------------------------------
250
251 ldr r0, [r0]
252 Opcode=2243 Name=tBLXi_r9 Format=ARM_FORMAT_THUMBFRM(25)
253 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
254 -------------------------------------------------------------------------------------------------
255 | 1: 1: 1: 1| 0: 0: 0: 0| 0: 0: 1: 0| 1: 1: 1: 0| 1: 1: 1: 0| 1: 1: 1: 0| 0: 0: 0: 1| 1: 1: 1: 0|
256 -------------------------------------------------------------------------------------------------
257
258 blx #191548
259 Opcode=2255 Name=tCBNZ Format=ARM_FORMAT_THUMBFRM(25)
260 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
261 -------------------------------------------------------------------------------------------------
262 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 1: 1| 1: 0: 0: 1| 0: 0: 0: 1| 1: 0: 0: 0|
263 -------------------------------------------------------------------------------------------------
264
265 cbnz r0, #6
266 Opcode=2275 Name=tLDRpci Format=ARM_FORMAT_THUMBFRM(25)
267 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
268 -------------------------------------------------------------------------------------------------
269 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 1: 0: 0: 1| 0: 0: 0: 0| 1: 0: 1: 0|
270 -------------------------------------------------------------------------------------------------
271
272 ldr.n r1, #40
273 Opcode=2223 Name=tADDhirr Format=ARM_FORMAT_THUMBFRM(25)
274 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
275 -------------------------------------------------------------------------------------------------
276 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 0: 1: 0: 0| 0: 1: 1: 1| 1: 0: 0: 1|
277 -------------------------------------------------------------------------------------------------
278
279 add r1, pc
280 Opcode=2274 Name=tLDRi Format=ARM_FORMAT_THUMBFRM(25)
281 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
282 -------------------------------------------------------------------------------------------------
283 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 1: 0| 1: 0: 0: 0| 0: 0: 0: 0| 1: 0: 0: 1|
284 -------------------------------------------------------------------------------------------------
285
286 ldr r1, [r1]
287 Opcode=2238 Name=tB Format=ARM_FORMAT_THUMBFRM(25)
288 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
289 -------------------------------------------------------------------------------------------------
290 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 1: 1: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0|
291 -------------------------------------------------------------------------------------------------
292
293 b #0
294 Opcode=2294 Name=tMOVr Format=ARM_FORMAT_THUMBFRM(25)
295 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
296 -------------------------------------------------------------------------------------------------
297 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 0: 1: 1: 0| 0: 0: 0: 0| 0: 0: 0: 1|
298 -------------------------------------------------------------------------------------------------
299
300 mov r1, r0
301 Opcode=2294 Name=tMOVr Format=ARM_FORMAT_THUMBFRM(25)
302 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
303 -------------------------------------------------------------------------------------------------
304 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 0: 1: 1: 0| 0: 0: 1: 0| 0: 0: 0: 0|
305 -------------------------------------------------------------------------------------------------
306
307 mov r0, r4
308 Opcode=2294 Name=tMOVr Format=ARM_FORMAT_THUMBFRM(25)
309 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
310 -------------------------------------------------------------------------------------------------
311 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 0: 1: 1: 0| 0: 0: 1: 0| 1: 0: 1: 0|
312 -------------------------------------------------------------------------------------------------
313
314 mov r2, r5
315 Opcode=2278 Name=tLDRspi Format=ARM_FORMAT_THUMBFRM(25)
316 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
317 -------------------------------------------------------------------------------------------------
318 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 0: 1| 1: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0|
319 -------------------------------------------------------------------------------------------------
320
321 ldr r3, [sp]
322 Opcode=2246 Name=tBLr9 Format=ARM_FORMAT_THUMBFRM(25)
323 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
324 -------------------------------------------------------------------------------------------------
325 | 1: 1: 1: 1| 0: 1: 1: 1| 1: 1: 1: 1| 1: 1: 0: 1| 1: 1: 1: 1| 1: 1: 1: 1| 1: 0: 0: 1| 1: 1: 0: 1|
326 -------------------------------------------------------------------------------------------------
327
328 bl #-8390
329 Opcode=2153 Name=t2SUBri Format=ARM_FORMAT_THUMBFRM(25)
330 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
331 -------------------------------------------------------------------------------------------------
332 | 1: 1: 1: 1| 0: 0: 0: 1| 1: 0: 1: 0| 0: 1: 1: 1| 0: 0: 0: 0| 1: 1: 0: 1| 0: 0: 0: 0| 1: 0: 0: 0|
333 -------------------------------------------------------------------------------------------------
334
335 sub.w sp, r7, #8
336 Opcode=1926 Name=t2LDMIA_UPD Format=ARM_FORMAT_THUMBFRM(25)
337 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
338 -------------------------------------------------------------------------------------------------
339 | 1: 1: 1: 0| 1: 0: 0: 0| 1: 0: 1: 1| 1: 1: 0: 1| 0: 1: 0: 0| 0: 0: 0: 0| 1: 0: 1: 1| 0: 0: 0: 0|
340 -------------------------------------------------------------------------------------------------
341
342 pop.w {r4, r5, r7, lr}
343 Opcode=2230 Name=tADDspi Format=ARM_FORMAT_THUMBFRM(25)
344 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
345 -------------------------------------------------------------------------------------------------
346 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0|
347 -------------------------------------------------------------------------------------------------
348
349 add sp, #16
350 Opcode=2250 Name=tBX_RET Format=ARM_FORMAT_THUMBFRM(25)
351 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
352 -------------------------------------------------------------------------------------------------
353 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 0| 0: 1: 1: 1| 0: 1: 1: 1| 0: 0: 0: 0|
354 -------------------------------------------------------------------------------------------------
355
356 bx lr
357 Opcode=2300 Name=tNOP Format=ARM_FORMAT_THUMBFRM(25)
358 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
359 -------------------------------------------------------------------------------------------------
360 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 1: 0: 1: 1| 1: 1: 1: 1| 0: 0: 0: 0| 0: 0: 0: 0|
361 -------------------------------------------------------------------------------------------------
362
363 nop
364 Opcode=2293 Name=tMOVi8 Format=ARM_FORMAT_THUMBFRM(25)
365 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
366 -------------------------------------------------------------------------------------------------
367 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 0| 0: 0: 1: 1| 1: 0: 0: 0| 1: 1: 1: 0|
368 -------------------------------------------------------------------------------------------------
369
370 movs r3, #142
371 Opcode=2290 Name=tMOVSr Format=ARM_FORMAT_THUMBFRM(25)
372 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
373 -------------------------------------------------------------------------------------------------
374 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 1|
375 -------------------------------------------------------------------------------------------------
376
377 movs r5, r0
378 Opcode=2225 Name=tADDi8 Format=ARM_FORMAT_THUMBFRM(25)
379 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
380 -------------------------------------------------------------------------------------------------
381 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 1| 0: 0: 0: 1| 0: 1: 1: 1| 1: 0: 1: 0|
382 -------------------------------------------------------------------------------------------------
383
384 adds r1, #122
385 Opcode=2290 Name=tMOVSr Format=ARM_FORMAT_THUMBFRM(25)
386 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
387 -------------------------------------------------------------------------------------------------
388 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 1|
389 -------------------------------------------------------------------------------------------------
390
391 movs r5, r0
392 Opcode=2225 Name=tADDi8 Format=ARM_FORMAT_THUMBFRM(25)
393 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
394 -------------------------------------------------------------------------------------------------
395 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 1: 1| 0: 0: 0: 1| 0: 1: 1: 0| 1: 0: 0: 0|
396 -------------------------------------------------------------------------------------------------
397
398 adds r1, #104
399 Opcode=2290 Name=tMOVSr Format=ARM_FORMAT_THUMBFRM(25)
400 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
401 -------------------------------------------------------------------------------------------------
402 | 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 0: 0: 0| 0: 1: 0: 1|
403 -------------------------------------------------------------------------------------------------
404
405 movs r5, r0
406 [16:28:00] johnny:/Volumes/data/Radar/9131529 $
407
1 This README describes a sample invocation of lldb-disasm.py whose purpose is to test
2 the lldb 'disassemble' command.
3
4 This is for the initial checkin of lldb-disasm.py which only reads an executable image and
5 dumps the symbol table from the imgae and its dependent libraries. The output was cut off
6 since it is too large.
7
8 da0603a-dhcp191:9131529 johnny$ /Volumes/data/lldb/svn/trunk/utils/test/lldb-disasm.py -C 'platform create remote-ios' -e /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib
9 lldb commands: ['platform create remote-ios']
10 lldb options: None
11 executable: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib
12 sys.path: ['/Volumes/data/lldb/svn/trunk/utils/test', '/Volumes/data/lldb/svn/trunk/build/Debug/LLDB.framework/Resources/Python', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', '/Library/Python/2.6/site-packages', '/AppleInternal/Library/Python/2.6/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode', '/Volumes/data/lldb/svn/trunk/utils/test/../../test/pexpect-2.4', '/Volumes/data/lldb/svn/trunk/test']
13 /Volumes/data/lldb/svn/trunk/test/lldbutil.py:80: SyntaxWarning: import * only allowed at module level
14 def int_to_bytearray(val, bytesize):
15 /Volumes/data/lldb/svn/trunk/test/lldbutil.py:105: SyntaxWarning: import * only allowed at module level
16 def bytearray_to_int(bytes, bytesize):
17 run command: platform create remote-ios
18 output: Platform: remote-ios
19 Not connected to a remote platform.
20 SDKROOT: "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3 (8F190)"
21
22 run command: file /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib
23 output: Current executable set to '/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib' (armv7).
24
25 run command: image dump symtab
26 output: Dumping symbol table for 18 modules.
27 Symtab, file = /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib, num_symbols = 851:
28 Debug symbol
29 |Synthetic symbol
30 ||Externally Visible
31 |||
32 Index UserID DSX Type File Address/Value Load Address Size Flags Name
33 ------- ------ --- ------------ ------------------ ------------------ ------------------ ---------- ----------------------------------
34 [ 0] 0 Code 0x0000000000001420 0x0000000000000000 0x000e0008 libSystem_initializer
35 [ 1] 1 Code 0x00000000000014c4 0x0000000000000000 0x001e0008 __keymgr_initializer
36 [ 2] 2 Code 0x00000000000014fc 0x0000000000000000 0x000e0008 dwarf2_unwind_dyld_add_image_hook
37 [ 3] 3 Code 0x0000000000001564 0x0000000000000000 0x000e0008 get_or_create_key_element
38 [ 4] 4 Code 0x0000000000001684 0x0000000000000000 0x000e0008 unlock_node
39 [ 5] 5 Code 0x0000000000001930 0x0000000000000000 0x000e0000 RsqrtTable
40 [ 6] 6 Code 0x0000000000001c30 0x0000000000000000 0x000e0000 acosf_crossover
41 [ 7] 7 Code 0x0000000000001c34 0x0000000000000000 0x000e0000 acosf_mid_poly
42 [ 8] 8 Code 0x0000000000001c48 0x0000000000000000 0x000e0000 Pi2_Q30
43 [ 9] 9 Code 0x0000000000001c4c 0x0000000000000000 0x000e0000 Pi_Q30
44 [ 10] 10 Code 0x0000000000001c78 0x0000000000000000 0x000e0000 acosf_approx
45 [ 11] 11 Code 0x0000000000001cec 0x0000000000000000 0x000e0000 acosf_pos_tail_poly
46 [ 12] 12 Code 0x0000000000001d00 0x0000000000000000 0x000e0000 acosf_tail
47 [ 13] 13 Code 0x0000000000001dfc 0x0000000000000000 0x000e0000 acosf_normalize
48 [ 14] 14 Code 0x0000000000001e10 0x0000000000000000 0x000e0000 acosf_round
49 [ 15] 15 Code 0x0000000000001e28 0x0000000000000000 0x000e0000 acosf_encode
50 [ 16] 16 Code 0x0000000000001e30 0x0000000000000000 0x000e0000 acosf_done
51 [ 17] 17 Code 0x0000000000001e38 0x0000000000000000 0x000e0000 acosf_special
52 [ 18] 18 Code 0x0000000000001e68 0x0000000000000000 0x000e0000 acosf_small
53 [ 19] 19 Code 0x0000000000001e9c 0x0000000000000000 0x000e0000 acosf_very_small
54 [ 20] 20 Code 0x0000000000001eb8 0x0000000000000000 0x000e0000 Pif
55 [ 21] 21 Code 0x000000000000220c 0x0000000000000000 0x000e0000 RsqrtTable
56 [ 22] 22 Code 0x000000000000250c 0x0000000000000000 0x000e0000 asinf_crossover
57 [ 23] 23 Code 0x0000000000002510 0x0000000000000000 0x000e0000 asinf_mid_poly
58 [ 24] 24 Code 0x0000000000002524 0x0000000000000000 0x000e0000 Pi2_Q30
59 [ 25] 25 Code 0x0000000000002550 0x0000000000000000 0x000e0000 asinf_approx
60 [ 26] 26 Code 0x00000000000025e4 0x0000000000000000 0x000e0000 asinf_tail_poly
61 [ 27] 27 Code 0x0000000000002600 0x0000000000000000 0x000e0000 asinf_tail
62 [ 28] 28 Code 0x00000000000026e0 0x0000000000000000 0x000e0000 asinf_normalize
63 [ 29] 29 Code 0x00000000000026f4 0x0000000000000000 0x000e0000 asinf_round
64 [ 30] 30 Code 0x000000000000270c 0x0000000000000000 0x000e0000 asinf_encode
65 [ 31] 31 Code 0x0000000000002718 0x0000000000000000 0x000e0000 asinf_done
66 [ 32] 32 Code 0x0000000000002720 0x0000000000000000 0x000e0000 asinf_special
67 [ 33] 33 Code 0x0000000000002754 0x0000000000000000 0x000e0000 asinf_small
68 [ 34] 34 Code 0x0000000000002784 0x0000000000000000 0x000e0000 Pi2f
69 [ 35] 35 Code 0x0000000000005774 0x0000000000000000 0x000e0008 rem_pio2
70 [ 36] 36 Code 0x00000000000076c4 0x0000000000000000 0x000e0008 __kernel_rem_pio2
71 [ 37] 37 Code 0x0000000000008c90 0x0000000000000000 0x000e0008 __kernel_tan
72 [ 38] 38 Code 0x0000000000008ef0 0x0000000000000000 0x000e0008 lgammaApprox
73 [ 39] 39 Code 0x000000000000b3d4 0x0000000000000000 0x000e0000 powf_not_special
74 [ 40] 40 Code 0x000000000000b3dc 0x0000000000000000 0x000e0000 powf_ylgx
75 [ 41] 41 Code 0x000000000000b438 0x0000000000000000 0x000e0000 powf_done
76 [ 42] 42 Code 0x000000000000b43c 0x0000000000000000 0x000e0000 powf_special_y
77 [ 43] 43 Code 0x000000000000b4a8 0x0000000000000000 0x000e0000 powf_special_x
78 [ 44] 44 Code 0x000000000000b4cc 0x0000000000000000 0x000e0000 powf_mzero_minf
79 [ 45] 45 Code 0x000000000000b54c 0x0000000000000000 0x000e0000 powf_y_odd
80 [ 46] 46 Code 0x000000000000b57c 0x0000000000000000 0x000e0000 powf_y_nonint
81 [ 47] 47 Code 0x000000000000b588 0x0000000000000000 0x000e0000 powf_y_even
82 [ 48] 48 Code 0x000000000000b7a8 0x0000000000000000 0x000e0000 powf_log2_reduction
83 [ 49] 49 Code 0x000000000000b7a8 0x0000000000000000 0x000e0000 powf_log2
84 [ 50] 50 Code 0x000000000000b814 0x0000000000000000 0x000e0000 powf_log2_approx
85 [ 51] 51 Code 0x000000000000b88c 0x0000000000000000 0x000e0000 powf_log2_synthesis
86 [ 52] 52 Code 0x000000000000b960 0x0000000000000000 0x000e0000 powf_log2_exactPowerOfTwo
87 [ 53] 53 Code 0x000000000000b980 0x0000000000000000 0x000e0000 powf_log2_near1
88 [ 54] 54 Code 0x000000000000b9ec 0x0000000000000000 0x000e0000 powf_log2_synthesis_near1
89 [ 55] 55 Code 0x000000000000ba04 0x0000000000000000 0x000e0000 Q32_minimax
90 [ 56] 56 Code 0x000000000000ba10 0x0000000000000000 0x000e0000 iexp2_lut
91 [ 57] 57 Code 0x000000000000ba94 0x0000000000000000 0x000e0000 powf_exp2
92 [ 58] 58 Code 0x000000000000bb18 0x0000000000000000 0x000e0000 powf_exp2_exact_int
93 [ 59] 59 Code 0x000000000000bb24 0x0000000000000000 0x000e0000 powf_exp2_big
94 [ 60] 60 Code 0x000000000000bb74 0x0000000000000000 0x000e0000 powf_exp2_overflow
95