-
Notifications
You must be signed in to change notification settings - Fork 14
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
Fix an incorrect number of zero bytes being inserted between sections #44
Conversation
Man that loop has all the bugs. Do you have a binary showing the problem we can add to those test cases? |
And does this by any chance close #38 |
The problem is exhibited by an example from my RTOS, but I think I can whip up a smaller test case.
No, it's unrelated. |
2abaa79
to
b05388a
Compare
When processing the `i`-th section (where `i > 0`), `start[i] - (start[0] + len[i - 1])` zero bytes are inserted *after* that section. This doesn't make sense and causes sections to be written at incorrect locations under certain circumstances. This commit updates the code in order that `start[i] - (start[i - 1] + len[i - 1])` = `start[i] - end[i - 1]` zero bytes are inserted *before* each section.
I threw a commit on unifying the if statements that I think is an improvement. Is this done? It tested a pygamer and it still works with this patch so seems ok |
Yep, it's ready to merge. |
Just as a datapoint: The linker script changes in |
This PR fixes a bug in the
elf_to_bin
function.When processing the
i
-th section (wherei > 0
),start[i] - (start[0] + len[i - 1])
zero bytes are inserted after that section. This doesn't make any sense and causes sections to be written at incorrect locations under certain circumstances.This PR updates the code so that
start[i] - (start[i - 1] + len[i - 1])
=start[i] - end[i - 1]
zero bytes are inserted before each section.