eliben / pyelftools

Parsing ELF and DWARF in Python
Other
1.99k stars 507 forks source link

Initial s390x relocation support #515

Closed stefan-sf-ibm closed 10 months ago

stefan-sf-ibm commented 10 months ago

This adds initial s390x relocation support as defined by the ABI.

sevaa commented 10 months ago

Any chance we could get a test binary to go along with that?

stefan-sf-ibm commented 10 months ago

Sure, I've followed the existing examples in test/testfiles_for_readelf and added a binary s390x-relocs.o.elf.

sevaa commented 10 months ago

Thanks. Did you get a chance to run the readelf autotest on the new binary? To test the new binary alone, run the following from the project root (assuming *nix):

python3 test/run_readelf_tests.py test/testfiles_for_readelf/s390x-relocs.o.elf

On Windows, it's possible too, but more involved than that. On Mac, I've never tried.

EDIT: the unittest is perfectly runnable under any OS. It's just test/run_all_unittests.py with no OS specific dependencies.

stefan-sf-ibm commented 10 months ago

@sevaa thanks for pointing this out. I only ran my own local tests. Running the testsuite I found a typo where s390x was lower and upper case in ENUM_RELOC_TYPE_S390X. I stream lined it in upper case style. Beside that a _DESCR_E_MACHINE entry was missing.

I also changed the existing entry of get_machine_arch from returning IBM System/390 to IBM S/390 in order to follow readelf.c.

Testsuite runs fine for me, now:

$ python3 test/run_readelf_tests.py test/testfiles_for_readelf/s390x-relocs.o.elf 
Test file 'test/testfiles_for_readelf/s390x-relocs.o.elf'

Conclusion: SUCCESS