[Wisp-cvs] wisp/users/dig elfdump.py,1.3,1.4
Status: Alpha
Brought to you by:
digg
From: <di...@us...> - 2003-04-14 23:47:54
|
Update of /cvsroot/wisp/wisp/users/dig In directory sc8-pr-cvs1:/tmp/cvs-serv6233 Modified Files: elfdump.py Log Message: cleanup Index: elfdump.py =================================================================== RCS file: /cvsroot/wisp/wisp/users/dig/elfdump.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- elfdump.py 14 Apr 2003 22:31:23 -0000 1.3 +++ elfdump.py 14 Apr 2003 23:47:50 -0000 1.4 @@ -20,6 +20,7 @@ if args: for filename in args: f = open(filename, 'r') + def take (tpl): return ftake(f, tpl) e_ident = f.read(16) print 'ELF header of %r:' % filename print 'Magic: %r:' % e_ident[0:4] @@ -33,8 +34,7 @@ state_enum('File version', ord(e_ident[6]), {1: 'current'}) print 'Padding bytes: %0r' % e_ident[7:] - e_type, e_machine, e_version, e_entry, e_phoff = \ - struct.unpack(bytesex + 'HHLLL', f.read(16)) + e_type, e_machine, e_version, e_entry, e_phoff = take('wwttt') state_enum('Object file type', e_type, { 1: 'relocatable', 2: 'executable', @@ -52,14 +52,13 @@ print 'Entry point: [%08x]' % e_entry e_shoff, e_flags, e_ehsize, e_phentsize, e_phnum, e_shentsize = \ - struct.unpack(bytesex + 'LLHHHH', f.read(16)) + take('ttwwww') print 'Processor-specific flags: [%08x]' % e_flags print 'ELF header size: [%08x] bytes' % e_ehsize print 'Program header table: %i entries at [%08x], 0x%x bytes each' % \ (e_phnum, e_phoff, e_phentsize) - e_shnum, e_shstrndx = \ - struct.unpack(bytesex + 'HH', f.read(4)) + e_shnum, e_shstrndx = take('ww') print 'Section header table: %i entries at [%08x], 0x%x bytes each' % \ (e_shnum, e_shoff, e_shentsize) print 'Section header strings in section #%i' % e_shstrndx |