eliben / pyelftools

Parsing ELF and DWARF in Python
Other
2.04k stars 512 forks source link

Support AArch64 in ELF32 (ILP32) #536

Open ondrudav opened 10 months ago

ondrudav commented 10 months ago

ILP32 on AArch64 produces ELF32 files with alternative relocation codes as defined by: https://github.com/ARM-software/abi-aa/blob/b0f1111afbd7d0aa8f2b160dd63971e69c99955a/aaelf64/aaelf64.rst#L1028

Currently this results in Unsupported relocation type: X exceptions

I'm considering adding the codes to ENUM_RELOC_TYPE_AARCH64 and _RELOCATION_RECIPES_AARCH64 as it's the simplest but this has 2 downsides:

  1. Lack of error when a code occurs in a file of the opposite variation.
  2. R_AARCH64_NONE and R_AARCH64_P32_NONE are both 0 and readelf.py won't tell the difference.
    • Note: the code only knows R_AARCH64_NONE under the alias 256

The other option is another pair of enum + dict for ILP32 and conditionals in _do_apply_relocation() and describe_reloc_type() if I'm not missing anything.

sevaa commented 2 months ago

A sample binary would be nice, please.