From: Eli Bendersky Date: Fri, 9 Sep 2011 07:05:57 +0000 (+0300) Subject: prints ELF header correctly X-Git-Tag: v0.10~129 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d62928db721527981ffc8429f717f7d0a41639eb;p=pyelftools.git prints ELF header correctly --- diff --git a/scripts/readelf.py b/scripts/readelf.py index 96fae30..44b7798 100644 --- a/scripts/readelf.py +++ b/scripts/readelf.py @@ -64,12 +64,40 @@ class ReadElf(object): describe_e_machine(header['e_machine'])) self._emitline(' Version: %s' % describe_e_version_numeric(header['e_version'])) + self._emitline(' Entry point address: %s' % + self._format_addr(header['e_entry'])) + self._emit(' Start of program headers %s' % + header['e_phoff']) + self._emitline(' (bytes into file)') + self._emit(' Start of section headers %s' % + header['e_shoff']) + self._emitline(' (bytes into file)') + self._emitline(' Flags: %s' % + self._format_addr(header['e_flags'])) + self._emitline(' Size of this header: %s (bytes)' % + header['e_ehsize']) + self._emitline(' Size of program headers: %s (bytes)' % + header['e_phentsize']) + self._emitline(' Number of program headers: %s' % + header['e_phnum']) + self._emitline(' Size of section headers: %s (bytes)' % + header['e_shentsize']) + self._emitline(' Number of section headers: %s' % + header['e_shnum']) + self._emitline(' Section header string table index: %s' % + header['e_shstrndx']) + + def _format_addr(self, addr): + """ Format an address into a string + """ + return '0x%x' % addr + def _emit(self, s): """ Emit an object to output """ self.output.write(str(s)) - + def _emitline(self, s): """ Emit an object to output, followed by a newline """