System V ABI 4.1 specifies that program header's p_vaddr should equal p_offset, modulo p_align.
(https://docs.oracle.com/cd/E19683-01/816-1386/chapter6-83432/index.html).
I was able to violate this using the linkerscript.
Patch fixes the issue.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
ELF/Writer.cpp | ||
---|---|---|
1641–1644 ↗ | (On Diff #54667) | // Adjusts the file alignment for a given output section and returns // its new file offset. The file offset must be the same with its // virtual address (modulo the page size) so that the loader can load // executables without any address adjustment. |
1646 ↗ | (On Diff #54667) | Rename this getFileAlignment. |
1674–1676 ↗ | (On Diff #54667) | You want to move these three lines of code to the new function because it handles alignment as well. Then you can remove Align parameter from the function. |
ELF/Writer.cpp | ||
---|---|---|
1646 ↗ | (On Diff #54667) | Done. |
1658 ↗ | (On Diff #54667) | Added Mask variable to simplify. |
1674–1676 ↗ | (On Diff #54667) | Done. |
ELF/Writer.cpp | ||
---|---|---|
1672–1679 ↗ | (On Diff #54824) | Can this be return alignTo(Off, PageSize, Sec->getVA())? |
ELF/Writer.cpp | ||
---|---|---|
1667–1670 ↗ | (On Diff #54824) | For relocatable output, do we even have to adjust file offset? |
ELF/Writer.cpp | ||
---|---|---|
1667–1670 ↗ | (On Diff #54824) | Did not find anywhere that we should not do that for -r. But gold and bfd both do that, so I guess yes, |
1672–1679 ↗ | (On Diff #54824) | I think yes. |
Comment Actions
LGTM
ELF/Writer.cpp | ||
---|---|---|
1687–1694 ↗ | (On Diff #54992) | Nice. I knew alignTo accepts the third argument, but this is the first time I see that is useful. |
ELF/Writer.cpp | ||
---|---|---|
1687–1694 ↗ | (On Diff #54992) | Yeah, I also saw it, but it was completely not obvious for me that it can be replacement for what was wrote before. |