[PATCH] D22683: [ELF] Symbol assignment within input section list
Eugene Leviant via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 5 05:04:41 PDT 2016
evgeny777 added a comment.
If we calculate input section offset in addSection() and do not change it later then assignment to "." should be easy. I think, its enough to add a parameter to addSection, like this
template <class ELFT>
void OutputSection<ELFT>::addSection(InputSectionBase<ELFT> *C, uintX_t Offset) {
// ... add section to Sections vector and set OutSec.
uintX_t Off = alignTo(this->Header.sh_size + Offset, S->Alignment);
S->OutSecOff = Off;
// ... calculate size
}
I haven't tried it yet, but at a first glance this should work
================
Comment at: ELF/OutputSections.cpp:845-847
@@ -844,2 +844,5 @@
this->updateAlignment(S->Alignment);
+ uintX_t Off = alignTo(this->Header.sh_size, S->Alignment);
+ S->OutSecOff = Off;
+ this->Header.sh_size = Off + S->getSize();
}
----------------
ruiu wrote:
> Okay, so you seems to call assignOffsets() in sortInitFini because we need to assign offsets after sorting input sections. But if you sort input sections, the total output section size may change, because padding sizes to satisfy alignment requirements may change.
>
> I think you wan tto compute the total size of sections inside assignOffsets. I mean, you can make this function really just add input section to the vector and does nothing more than that, and let assignOffsets compute the alignment and the output section size.
Doing so will complicate adding symbols, because you don't know symbol offset when you process it in LinkerScript<ELFT>::createSections.
We don't want to switch back to virtual input section, AFAIK, so I wonder ho do you suggest handling symbols this time.
BTW, please look at this review:
https://reviews.llvm.org/D23197
It refactors sorting of special sections.
================
Comment at: ELF/OutputSections.cpp:894
@@ -890,1 +893,3 @@
+
+ assignOffsets();
}
----------------
ruiu wrote:
> If there's no .init or .ctors, assignOffsets is not called? Is it correct?
I think so. We call this method only if Factory.lookup() return us a section
https://reviews.llvm.org/D22683
More information about the llvm-commits
mailing list