added segment attribute formatting for 64-bit, and fixed some words to xwords in...
authorEli Bendersky <eliben@gmail.com>
Wed, 14 Sep 2011 03:18:28 +0000 (06:18 +0300)
committerEli Bendersky <eliben@gmail.com>
Wed, 14 Sep 2011 03:18:28 +0000 (06:18 +0300)
elftools/elf/structs.py
scripts/readelf.py

index bb685cf3ef553b76c42b93795aacd8827db27b77..58088202d69bd3ccc3eee96ae4558a9f789d9a07 100644 (file)
@@ -112,9 +112,9 @@ class ELFStructs(object):
                 self.Elf_offset('p_offset'),
                 self.Elf_addr('p_vaddr'),
                 self.Elf_addr('p_paddr'),
-                self.Elf_word('p_filesz'),
-                self.Elf_word('p_memsz'),
-                self.Elf_word('p_align'),
+                self.Elf_xword('p_filesz'),
+                self.Elf_xword('p_memsz'),
+                self.Elf_xword('p_align'),
             )   
         
     def _create_shdr(self):
index 982add47974e53d3bc148f7ef55c3d8f1d7b0a1b..2b21549bbde8141780d136d30838b28c83479914 100644 (file)
@@ -129,6 +129,18 @@ class ReadElf(object):
                     self._format_hex(segment['p_memsz'], fieldsize=5),
                     describe_p_flags(segment['p_flags']),
                     self._format_hex(segment['p_align'])))
+            else: # 64
+                self._emitline('%s %s %s' % (
+                    self._format_hex(segment['p_offset'], fullhex=True),
+                    self._format_hex(segment['p_vaddr'], fullhex=True),
+                    self._format_hex(segment['p_paddr'], fullhex=True)))
+                self._emitline('                 %s %s  %-3s    %s' % (
+                    self._format_hex(segment['p_filesz'], fullhex=True),
+                    self._format_hex(segment['p_memsz'], fullhex=True),
+                    describe_p_flags(segment['p_flags']),
+                    # lead0x set to False for p_align, to mimic readelf.
+                    # No idea why the difference from 32-bit mode :-|
+                    self._format_hex(segment['p_align'], lead0x=False)))
 
             if isinstance(segment, InterpSegment):
                 self._emitline('      [Requesting program interpreter: %s]' %