rajeshgangam / pydevtools

Automatically exported from code.google.com/p/pydevtools
Other
0 stars 0 forks source link

Crash with ELF which doesn't containt a .strtab section neither a .symtab #9

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. try to instranciate a bintools.elf.ELF objet with a ELF which doesn't 
containt a .strtab section neither a .symtab and you obtain this:
Traceback (most recent call last):
  File "./apply_patch.py", line 81, in <module>
    p_in_elf = ELF(p_in)
  File "/home/cocolapin/python/lib/bintools/elf/__init__.py", line 50, in __init__
    strtab = self.sect_dict['.strtab']
KeyError: '.strtab'

What version of the product are you using? On what operating system?
revision 23
GNU/Linux x86

Please provide any additional information below.
a easy workaround is to modify bintools/elf/__init__.py by
49,51c49,52
<         strtab = self.sect_dict['.strtab']
<         self.strtab = StringTable(self.io, strtab.offset, strtab.size)
<         

---
>         if '.strtab' in self.sect_dict:
>             strtab = self.sect_dict['.strtab']
>             self.strtab = StringTable(self.io, strtab.offset, strtab.size)
> 
53,56c54,58
<         symtab = self.sect_dict['.symtab']
<         count = symtab.size / Symbol.LENGTH
<         self.symbols = self.load_entries(symtab.offset, count, Symbol)
<     

---
>         if '.symtab' in self.sect_dict:
>             symtab = self.sect_dict['.symtab']
>             count = symtab.size / Symbol.LENGTH
>             self.symbols = self.load_entries(symtab.offset, count, Symbol)
> 

Original issue reported on code.google.com by dumpc...@gmail.com on 11 Dec 2011 at 12:42

GoogleCodeExporter commented 8 years ago
I believe you fixed it by yourself in commit r24. Thanks!

Original comment by stefan.h...@gmail.com on 25 Dec 2011 at 11:30