pfalcon / ScratchABit

Easily retargetable and hackable interactive disassembler with IDAPython-compatible plugin API
GNU General Public License v3.0
393 stars 47 forks source link

KeyError: 'r_addend' on Ubuntu 14.04 Python3.4.3 #11

Closed sheinz closed 8 years ago

sheinz commented 8 years ago

Hi,

I'm having trouble running ScratchABit on my machine:

$ python scratchabit.py example-elf
Traceback (most recent call last):
  File "scratchabit.py", line 721, in <module>
    load_target_file(loader, sys.argv[1])
  File "scratchabit.py", line 623, in load_target_file
    entry = loader.load(engine.ADDRESS_SPACE, fname)
  File "/home/user/esp/virtenv/ScratchABit/plugins/loader/elf.py", line 407, in load
    return load_sections(aspace, elffile)
  File "/home/user/esp/virtenv/ScratchABit/plugins/loader/elf.py", line 280, in load_sections
    if reloc["r_addend"] != 0:
  File "/home/user/esp/virtenv/ScratchABit/plugins/loader/pyelftools/elftools/elf/relocation.py", line 35, in __getitem__
    return self.entry[name]
  File "/home/user/esp/virtenv/ScratchABit/plugins/loader/pyelftools/elftools/construct/lib/container.py", line 35, in __getitem__
    return self.__dict__[name]
KeyError: 'r_addend'

Am I missing something? I use Ubuntu 14.04 with Python 3.4.3 Thanks

BlueShrub commented 8 years ago

Same issue here

$ uname -a
Linux novi-ThinkPad-X120e 4.2.0-34-generic #39-Ubuntu SMP Thu Mar 10 22:13:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

$ python3 -V
Python 3.4.3+

$ python3 scratchabit.py example-elf
Traceback (most recent call last):
  File "scratchabit.py", line 721, in <module>
    load_target_file(loader, sys.argv[1])
  File "scratchabit.py", line 623, in load_target_file
    entry = loader.load(engine.ADDRESS_SPACE, fname)
  File "/opt/ScratchABit/plugins/loader/elf.py", line 407, in load
    return load_sections(aspace, elffile)
  File "/opt/ScratchABit/plugins/loader/elf.py", line 280, in load_sections
    if reloc["r_addend"] != 0:
  File "/opt/ScratchABit/plugins/loader/pyelftools/elftools/elf/relocation.py", line 35, in __getitem__
    return self.entry[name]
  File "/opt/ScratchABit/plugins/loader/pyelftools/elftools/construct/lib/container.py", line 35, in __getitem__
    return self.__dict__[name]
KeyError: 'r_addend'
pfalcon commented 8 years ago

Thanks for the reports, confirmed.

pfalcon commented 8 years ago

Partial fix was pushed, though it still crashes later. The issue is that recently "advanced" loading of Xtensa ELF files was added, which was implemented in an adhoc way and now clashes with x86. I'm on it.

BlueShrub commented 8 years ago

That's a pretty solid response time :).

In the event it's helpful, this is the new error on my machine (although I imagine it's what you were referring to):

# python3 scratchabit.py example-elf
Traceback (most recent call last):
  File "scratchabit.py", line 721, in <module>
    load_target_file(loader, sys.argv[1])
  File "scratchabit.py", line 623, in load_target_file
    entry = loader.load(engine.ADDRESS_SPACE, fname)
  File "/opt/ScratchABit/plugins/loader/elf.py", line 409, in load
    return load_sections(aspace, elffile)
  File "/opt/ScratchABit/plugins/loader/elf.py", line 296, in load_sections
    rel_type = RELOC_TYPES[reloc["r_info_type"]]
KeyError: 7
pfalcon commented 8 years ago

Yes, that was the other error, and it's now fixed too. python scratchabit.py example-elf now works as expected.

BlueShrub commented 8 years ago

Works for me now. My first time using this tool -- pretty handy! Very impressed.

Thanks again!

pfalcon commented 8 years ago

You're welcome. And I know it could be made better, and that's on todo ;-).