-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(esptool): Allow ELF files without segments again (ESPTOOL-1132) #1118
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
Conversation
👋 Hello tormodvolden, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. Click to see more instructions ...
Review and merge process you can expect ...
|
|
Thanks @tormodvolden for the fix, will try to merge is ASAP. |
|
@tormodvolden can you please change the commit message to something like |
089b52a to
ac34f64
Compare
|
Sure, done. |
|
My original commit summary tried do convey that this fixes some kind of regression, since having zero program header counts was working fine in older versions of esptool. Actually "program header counts" would be better, what do you think? |
I am okay with that if you prefer. Will wait for your change. You can mention the regression in the body, but write |
ac34f64 to
b9695ce
Compare
|
OK, I edited it to say "program headers". |
|
@tormodvolden sorry, we just merged some MR and we do not use merge commits, can you please rebase on master so you have credit in history? |
The program header table can describe zero or more segments. However, commit ca16d5f introduced checks in _read_segments() that will fail on a zero number of program header entries. Simply return early and skip these checks in _read_segments() if e_phnum is zero. Signed-off-by: Tormod Volden <[email protected]>
b9695ce to
d27ce37
Compare
|
Rebased to latest master. |
The program header table can describe zero or more segments. However, commit ca16d5f introduced checks in _read_segments() that will fail on a zero number of program header entries.
ELF files created by objcopy based on a binary file may not have any segments / program header table. The number of program header entries e_phnum in the ELF header is zero.
This was fine before commit ca16d5f, but is currently broken and esptool will exit with this error:
A fatal error occurred: No segment header found at offset 0000 in ELF file.This PR reinstates the possibility of having no such entries by simply returning early and skip these checks in _read_segments() if e_phnum is zero.
The change has no implication if the number of entries is non-zero.
I have tested this change with the following hardware & software combinations:
Tested with ELF files created by objcopy that have no segments. esptool elf2image now successfully creates an image.
I have run the esptool automated integration tests with this change and the above hardware:
NO_TESTING