serge1 / ELFIO

ELFIO - ELF (Executable and Linkable Format) reader and producer implemented as a header only C++ library
http://serge1.github.io/ELFIO
MIT License
706 stars 152 forks source link

Add rpl rpx support #112

Closed gblues closed 1 year ago

gblues commented 1 year ago

Hey!

With a few tweaks, this library is super-useful for making Wii U homebrew. I'm contributing those tweaks back in this PR.

Change summary:

  1. Add a handful of constants:
    • SHT_RPL_EXPORTS
    • SHT_RPL_IMPORTS
    • SHT_RPL_CRCS
    • SHT_RPL_FILEINFO
    • SHF_RPX_DEFLATE
  2. implement zlib decompression/compression for elf sections that have the SHF_RPX_DEFLATE flag set
serge1 commented 1 year ago

Hi @gblues , usage of the library for Wii U homebrew sounds like a great idea. I would like to accept related modifications. Saying this, I would like to prevent introduction of additional dependencies like usage of Zip library.

Do you think it is possible to work with compressed data at level upper to ELFIO API? The API provides access to raw section data, so, it should be doable. In case it is absolutely necessary to make conversions 'from inside', introduction of corresponding callback may help.

What is your opinion?

Thank you

gblues commented 1 year ago

That's a pretty reasonable concern. Lemme see what I can come up with.

gblues commented 1 year ago

@serge1 please take a look at the most recent commit, which leverages dependency inversion to remove the zlib dependency previously introduced.

serge1 commented 1 year ago

The implementation looks good! Thank you very much!

serge1 commented 1 year ago

A question: Does Wii U name is actually required for the interface name? Are you aware about other solutions/architectures that use compressed section data?

I also should think more about introducing of 'cerr' stream. The library didn't use this error reporting mechanism untill now.

Accepted and Merged.

Thank you again

nstrong-scw commented 1 year ago

There's an existing SHF_COMPRESSED flag so .. maybe? I don't have the expertise to design a more general-case interface.

If I knew how to do it, what I would do is take a crack at implementing SHF_COMPRESSED support and see if you can do it with the interface I created; if so, then go ahead and rename it something more general.