-
Notifications
You must be signed in to change notification settings - Fork 156
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
Elf Builder fails with non-homogenous PT_LOAD alignments #656
Comments
My assumption was that all PT_LOAD segment were page aligned, but that's clearly wrong. It seems that the program headers you gave don't satisfy the requirement that "loadable process segments must have congruent values for p_vaddr and p_offset, modulo the page size", so I guess there are some processors for which this is not a requirement? I don't have much experience in this area, so if I have further wrong assumptions here then please correct me. |
To elaborate, the congruence requirement comes from https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-83432.html, but it does seem to be talking about something that is likely processor specific. We currently implement that requirement in |
I think you're right in that it's processor-dependent. This is specifically for the Cortex M4F (thumbv7em-none-eabihf), as found on the STM32G4 lineup. I've got something workable for now but it breaks the |
See if #659 meets your needs. |
When calling
object::build::elf::Builder::read32(...)
on an ELF file that contains different alignments in its load sections (e.g. the below), the following error is raised: "Unsupported alignments for PT_LOAD segments"From
objdump -x myelf
:I may be missing something, but I don't see a reason for this restriction, and causes the elf builder to fail to load a subset of files that are valid. In my case, this prevents us from being able to read ELF files that perform floating point trigonometric methods on a 32-bit platform with hard-float support.
The issue seems to originate in
src/build/elf.rs:146
and onwards, where the alignment of the first section with PT_LOAD is latched throughbuilder.load_align
.The alignments are stored per-segment in the lines following, so it seems odd to be storing it at the builder level when I can only find references to
builder.load_align
in therewrite
crate.Is there a reason that I'm missing for the PT_LOAD segments to be homogenous in alignment as a requirement? If not, I'm happy to open a PR to fix this issue.
Thanks!
The text was updated successfully, but these errors were encountered: