* also create other stuff in struct constructor
* sample for getting ELF's string table contents
diff --git a/elftools/elf/structs.py b/elftools/elf/structs.py
index bfaca07..090a8a9 100644
--- a/elftools/elf/structs.py
+++ b/elftools/elf/structs.py
@@ -36,6 +36,8 @@
self.Elf_sxword = SBInt32 if self.elfclass == 32 else SBInt64
self._create_ehdr()
+ self._create_shdr()
+ self._create_sym()
def _create_ehdr(self):
self.Elf_Ehdr = Struct('Elf_Ehdr',
diff --git a/z.py b/z.py
index b52b969..aa4672e 100644
--- a/z.py
+++ b/z.py
@@ -1,10 +1,30 @@
+import sys
from elftools.elf.structs import ELFStructs
+# read a little-endian, 64-bit file
es = ELFStructs(True, 64)
-
stream = open('binfiles/z.elf', 'rb')
-print es.Elf_Ehdr.parse_stream(stream)
+eheader = es.Elf_Ehdr.parse_stream(stream)
+
+print eheader
+
+shtable_offset = eheader.e_shoff
+strtable_section_offset = shtable_offset + eheader.e_shstrndx * eheader.e_shentsize
+
+# get to the section header for the sh string table
+print strtable_section_offset
+stream.seek(strtable_section_offset)
+sheader = es.Elf_Shdr.parse_stream(stream)
+print sheader
+
+# yay, looks correct!!
+stream.seek(sheader.sh_offset)
+buf = stream.read(sheader.sh_size)
+for c in buf:
+ sys.stdout.write('%02X' % ord(c))
+
+
#~ print es.Elf_Ehdr