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
720 stars 155 forks source link

Loaded, modified, saved elf file is more different than expected from original #63

Closed sktpin closed 3 years ago

sktpin commented 3 years ago

Hello, I'm don't know a lot of details about the .elf format, so maybe there can be a good reason for it.

I have a bare metal project for ARM Cortex M, using the ARM GCC compiler toolchain for that. So I use ELFIO load a produced .elf file, search for one section by name, call set_data() on that section to change the content (size should remain the same), and call .save() on that elfio object. The changed section is only a few uint32's big.

Looking at the resulting file in the hex editor, I find things like big blocks (kilobytes maybe) of zeroes where the original file had data. Also, the saved file is now 6KB bigger than the original one.

Can there be legitimate reasons for these observations, or is something wrong? (I've not tried using it yet)

serge1 commented 3 years ago

Duplicate of #62