@@ -163,6 +163,16 @@ def chunk_into_words(code, bytes_per_word, byteorder):
163
163
return words
164
164
165
165
166
+ def print_ulp_header (h ):
167
+ print ('ULP magic : %s (0x%08x)' % (h .magic .to_bytes (4 , 'little' ), h .magic ))
168
+ print ('.text offset : %s (0x%02x)' % (h .text_offset , h .text_offset ))
169
+ print ('.text size : %s (0x%02x)' % (h .text_size , h .text_size ))
170
+ print ('.data offset : %s (0x%02x)' % (h .text_offset + h .text_size , h .text_offset + h .text_size ))
171
+ print ('.data size : %s (0x%02x)' % (h .data_size , h .data_size ))
172
+ print ('.bss size : %s (0x%02x)' % (h .bss_size , h .bss_size ))
173
+ print ('----------------------------------------' )
174
+
175
+
166
176
def print_code_line (byte_offset , i , asm ):
167
177
lineformat = '{0:04x} {1} {2}'
168
178
hex = ubinascii .hexlify (i .to_bytes (4 , 'little' ))
@@ -210,6 +220,13 @@ def disassemble_file(filename, verbose=False):
210
220
)
211
221
h = struct (addressof (data ), binary_header_struct_def , LITTLE_ENDIAN )
212
222
223
+ if (h .magic != 0x00706c75 ):
224
+ print ('Invalid signature: 0x%08x (should be: 0x%08x)' % (h .magic , 0x00706c75 ))
225
+ return
226
+
227
+ if verbose :
228
+ print_ulp_header (h )
229
+
213
230
code = data [h .text_offset :]
214
231
words = chunk_into_words (code , bytes_per_word = 4 , byteorder = 'little' )
215
232
@@ -223,7 +240,7 @@ def print_help():
223
240
print ('Options:' )
224
241
print (' -h Show this help text' )
225
242
print (' -m <byte_sequence> Sequence of hex bytes (8 per instruction)' )
226
- print (' -v Verbose mode. Also show instruction fields' )
243
+ print (' -v Verbose mode. Show ULP header and fields of each instruction ' )
227
244
print (' <filename> Path to ULP binary' )
228
245
pass
229
246
0 commit comments