From: Eli Bendersky Date: Fri, 9 Sep 2011 05:22:35 +0000 (+0300) Subject: some more header descriptions added X-Git-Tag: v0.10~130 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=de8d71e6a40b386aec761a05eb2eb89e7da81283;p=pyelftools.git some more header descriptions added --- diff --git a/elftools/elf/descriptions.py b/elftools/elf/descriptions.py index c06f97f..ff149a5 100644 --- a/elftools/elf/descriptions.py +++ b/elftools/elf/descriptions.py @@ -27,6 +27,12 @@ def describe_ei_osabi(x): def describe_e_type(x): return _DESCR_E_TYPE.get(x, _unknown()) +def describe_e_machine(x): + return _DESCR_E_MACHINE.get(x, _unknown()) + +def describe_e_version_numeric(x): + return '0x%x' % ENUM_E_VERSION[x] + #------------------------------------------------------------------------------- def _unknown(): @@ -74,3 +80,19 @@ _DESCR_E_TYPE = dict( PROC_SPECIFIC='Processor Specific', ) +_DESCR_E_MACHINE = dict( + EM_NONE='None', + EM_M32='WE32100', + EM_SPARC='Sparc', + EM_386='Intel 80386', + EM_68K='MC68000', + EM_88K='MC88000', + EM_860='Intel 80860', + EM_MIPS='MIPS R3000', + EM_S370='IBM System/370', + EM_MIPS_RS4_BE='MIPS 4000 big-endian', + EM_IA_64='Intel IA-64', + EM_X86_64='Advanced Micro Devices X86-64', + EM_AVR='Atmel AVR 8-bit microcontroller', + RESERVED='RESERVED', +) diff --git a/scripts/readelf.py b/scripts/readelf.py index a0eb79b..96fae30 100644 --- a/scripts/readelf.py +++ b/scripts/readelf.py @@ -21,7 +21,8 @@ from elftools.common.exceptions import ELFError from elftools.elf.elffile import ELFFile from elftools.elf.descriptions import ( describe_ei_class, describe_ei_data, describe_ei_version, - describe_ei_osabi, describe_e_type, + describe_ei_osabi, describe_e_type, describe_e_machine, + describe_e_version_numeric, ) @@ -59,6 +60,10 @@ class ReadElf(object): e_ident['EI_ABIVERSION']) self._emitline(' Type: %s' % describe_e_type(header['e_type'])) + self._emitline(' Machine: %s' % + describe_e_machine(header['e_machine'])) + self._emitline(' Version: %s' % + describe_e_version_numeric(header['e_version'])) def _emit(self, s): """ Emit an object to output