Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saved .elf differs from read .elf by a lot more than the changed section #62

Closed
sktpin opened this issue Jan 14, 2021 · 3 comments
Closed

Comments

@sktpin
Copy link

sktpin commented Jan 14, 2021

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
Copy link
Owner

serge1 commented Jan 15, 2021

Hi,

Generally speaking, it is not valid to compare files in ELF format by binary comparison. The more correct way is comparison of headers, sections and segments' contents.

Without knowing more details, the file size may increase due to increasing of section size - ELF writer recalculates layouout and moves location of the next section to a place corresponding to its align requriement.

Best regards,
Serge

@sktpin
Copy link
Author

sktpin commented Jan 15, 2021

Ok, thanks, good to know.
I meanwhile also tested the resulting .elf with the MCU vendor-provided IDE to debug, then read out the flash with their utility & compaired against the toolchain-generated raw binary file. The flash content derived from the saved .elf matches with that IDE-generated bin file, so it looks like it works.
Then there is no problem.
Thanks for your very useful library!

@serge1
Copy link
Owner

serge1 commented Jan 16, 2021

Per the previous comment - the issue is closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants