This is a minimal implementation to produce legal output. Future patches will combine multiple compatible PT_LOADs.
It uses the term PHDR instead of segment as not all PHDRs represent segments.
Paths
| Differential D12718
[elf2] Assign output sections to PHDRs. ClosedPublic Authored by Bigcheese on Sep 8 2015, 7:06 PM.
Details
Summary This is a minimal implementation to produce legal output. Future patches will combine multiple compatible PT_LOADs. It uses the term PHDR instead of segment as not all PHDRs represent segments.
Diff Detail Event TimelineBigcheese updated this object. Comment Actions + static const uint64_t BaseAddress = 0x400000; Any reason to change this in this patch? It can be done in another + FileOff = RoundUpToAlignment(FileOff, ELFT::Is64Bits ? 8 : 4); That is not needed. The file header size is already a multiple of 8 or
+ for (OutputSectionBase<ELFT::Is64Bits> *Sec : OutputSections) Use Elf_Phdr instead of Elf_Phdr_Impl + ++NumPhdrs; Include {} around the for. Alternatively, write it as for (OutputSectionBase<ELFT::Is64Bits> *Sec : OutputSections) if (outputSectionHasPHDR<ELFT>(Sec)) ++NumPhdrs; FileOff += NumPhdrs * sizeof(Elf_Phdr); Even better, we can merge the loop with the following one since all + FileSize = RoundUpToAlignment(FileOff, 8); This can just be FileSize = FileOff; no? Why do we have to pad the end of the file? An attached patch with most of these comments is attached.
This revision is now accepted and ready to land.Sep 9 2015, 1:29 PM
Revision Contents
Diff 34365 ELF/Writer.cpp
test/elf2/basic.s
test/elf2/basic32.s
test/elf2/basic32be.s
test/elf2/basic64be.s
test/elf2/relocation.s
test/elf2/symbols.s
|