some more header descriptions added
authorEli Bendersky <eliben@gmail.com>
Fri, 9 Sep 2011 05:22:35 +0000 (08:22 +0300)
committerEli Bendersky <eliben@gmail.com>
Fri, 9 Sep 2011 05:22:35 +0000 (08:22 +0300)
elftools/elf/descriptions.py
scripts/readelf.py

index c06f97fb0de84d83ef24e3ed2d03ab7db9dd67f9..ff149a528c8ea726dda2031bdabc79b8b043d54b 100644 (file)
@@ -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',
+)
index a0eb79b5e6c4f21c96d4c504b9d10e448d268c1d..96fae3069c1fae86b0d79da9608b6606511ea798 100644 (file)
@@ -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