From a41c3c06ed272a45f1a8593b3e516bdea900ff03 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Wed, 14 Sep 2011 06:18:28 +0300 Subject: [PATCH] added segment attribute formatting for 64-bit, and fixed some words to xwords in the segment struct definition --- elftools/elf/structs.py | 6 +++--- scripts/readelf.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/elftools/elf/structs.py b/elftools/elf/structs.py index bb685cf..5808820 100644 --- a/elftools/elf/structs.py +++ b/elftools/elf/structs.py @@ -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): diff --git a/scripts/readelf.py b/scripts/readelf.py index 982add4..2b21549 100644 --- a/scripts/readelf.py +++ b/scripts/readelf.py @@ -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]' % -- 2.30.2