HexHive / retrowrite

RetroWrite -- Retrofitting compiler passes through binary rewriting
Other
655 stars 78 forks source link

Exception: 'r_addend' key missing in relocation #9

Closed kbeckmann closed 11 months ago

kbeckmann commented 4 years ago

First of all, thanks for publishing the research and source for this tool.

When running python3 -m rwtools.asan.asantool serverbrowser.so serverbrower_instr I get the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/konrad/dev/retrowrite/rwtools/asan/asantool.py", line 83, in <module>
    rewriter = do_symbolization(args.binary, args.outfile)
  File "/home/konrad/dev/retrowrite/rwtools/asan/asantool.py", line 21, in do_symbolization
    reloc_list = loader.reloc_list_from_symtab()
  File "/home/konrad/dev/retrowrite/librw/loader.py", line 113, in reloc_list_from_symtab
    'addend': rel['r_addend'],
  File "/home/konrad/dev/retrowrite/retro/lib/python3.8/site-packages/elftools/elf/relocation.py", line 36, in __getitem__
    return self.entry[name]
  File "/home/konrad/dev/retrowrite/retro/lib/python3.8/site-packages/elftools/construct/lib/container.py", line 35, in __getitem__
    return self.__dict__[name]
KeyError: 'r_addend'

If I print the rel object, there is no r_addend key in the entry in my case:

<Relocation (REL): Container({'r_offset': 3346624, 'r_info': 8, 'r_info_sym': 0, 'r_info_type': 8})>

The binary/library in question is not stripped and has tons of symbols and sections. It is part of the Steam client. I guess I shouldn't share the binary here for copyright reasons.

I haven't debugged this in depth yet, but I guess this issue will show up for others sooner or later.

sushant94 commented 4 years ago

Thanks for the report! I'll check this out first thing day after tomorrow!

gannimo commented 11 months ago

If this is still an issue, let us know. The code has gone through quite some changes.