-
Notifications
You must be signed in to change notification settings - Fork 159
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
write: fix reserving empty section error #514
Conversation
d0e19ed
to
3e5fccf
Compare
Thanks for the PR. However, it does not look correct. Can you give an in depth explanation so I can better understand the problem? Are you running the |
for example, the reserved_len is 64. then the first section's len is 42, align_start is 16. the offset is 64. But next section's len is 0, align_start is 16. the offset should be 112, but the offset is 106. |
Ok, and does that offset of 106 causes problems? It does sound like something that needs fixing, but I want to understand the problem first. |
yes,the 106/16 is not a integer. so it is a unaligned offset. |
Yes I understand what an unaligned offset is. What were you doing that caused you to notice that this is a problem? I see that running elfcopy on it gives an error:
Is that all that you were trying to do, or are you trying to use this code in something else where the unaligned offset causes a problem? |
I just want to copy a elf with a empty section. This function said that "Returns the aligned offset of the start of the range". But if len is 0, it doesn't call "util::align" just return "self.len". Then I think this is a problem. |
if we copy a elf with a empty section and the sh_addralign is not 0, it will return a unaligned offset. Signed-off-by: lzwycc <lzw32321226@163.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
`reserve` must always return an aligned address, even if the section is empty. This matches the behaviour of `write_align`. Also both `reserve` and `write_align` must handle the possibility of `sh_addralign` being 0. Signed-off-by: lzwycc <lzw32321226@163.com>
if we copy a elf with a empty section and the sh_addralign(align_start) is not 0, it will return a unaligned offset.