Skip to content

Commit 046dabb

Browse files
committed
parse_ident():
Modern linuxen seem to use an OS/ABI of '0', believing that it means "Unix - SYSTEM V". go(): parse_note() appears to make assumptions about the prstatus and psinfo structs that do not apply to the "GNU" branded system (i.e. linux). __main__: assign the results of go() to globals
1 parent 634205d commit 046dabb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

parse_elf.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ def parse_ident (data):
294294
r['class'] = {0:'unknown',1:'32-bit',2:'64-bit'}[ord(data[EI_CLASS])]
295295
r['data'] = {0:'unknown',1:'little-endian',2:'big-endian'}[ord(data[EI_DATA])]
296296
r['osabi'] = {
297+
0:'unix', # modern linux reports this as "UNIX - System V"
297298
1:'hpux', 2:'netbsd', 3:'linux', 4:'hurd', 5:'86open',
298299
6:'solaris', 7:'monterey', 8:'irix', 9:'freebsd',
299300
10:'tru64', 97:'arm', 255:'standalone'
@@ -499,13 +500,20 @@ def go (filename):
499500
# Check for FreeBSD branding
500501
if name == 'FreeBSD\x00' and descsz == 4:
501502
pass
503+
elif name == 'GNU\x00':
504+
# doesn't match the struct description
505+
pass
502506
else:
503507
parse_note_prstatus(core_info, desc)
504508
elif note_type == 2:
505509
# floating point register info
506510
pass
507511
elif note_type == 3:
508-
parse_note_psinfo(core_info, desc)
512+
if name == 'GNU\x00':
513+
# doesn't match the struct description
514+
pass
515+
else:
516+
parse_note_psinfo(core_info, desc)
509517
else:
510518
print "unknown note type:", note_type
511519

@@ -609,4 +617,4 @@ def _go(out):
609617
else:
610618
sort = None
611619
report_out = sys.stdout
612-
go (sys.argv[1])
620+
ehdr, phdr_list, shdr_list, syms, core_info = go (sys.argv[1])

0 commit comments

Comments
 (0)