[PATCH] D22683: [ELF] Symbol assignment within input section list

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 14:09:19 PDT 2016


ruiu added inline comments.

================
Comment at: ELF/LinkerScript.cpp:120-121
@@ -122,1 +119,4 @@
+    // .foo : { *(.foo.*) end_foo = .; }
+    SectionOffset = alignTo(SectionOffset, C->Alignment);
+    SectionOffset += C->getSize();
   };
----------------
evgeny777 wrote:
> ruiu wrote:
> > evgeny777 wrote:
> > > ruiu wrote:
> > > > This offset computation is not accurate. On MIPS or ARM, input sections may have additional pieces of data, or thunks, at their ends. Thunks are added to input sections in Writetr::finalizeSections, so in this function we don't know the exact size of input sections. So this is computing offsets too early.
> > > Thanks for pointing this out. I suggest calculating offsets in addScriptedSymbols than. What's your opinion?
> > If you can do it, it would work, but I"m not sure how you are going to do it.
> I think this can be done by implementing a special sort of input section (like SymbolInputSection<ELFT>) with zero size and alignment of 1. One can store a list of such sections in LinkerScript<ELFT> and calculate real offset, taking SymbolInputSection<ELFT>::OutSec as a starting point.
> 
> I believe there should be other ways also. Need some research.
I haven't thought hard enough yet, but it sounds at least not a bad idea.

The other idea (I'm not suggesting it's better than yours) would be to create DefinedRegular symbols instead of DefinedSymthetic symbols. Synthetic symbols are associated to output sections, while regular symbols are associated to input sections, so the linker don't need to adjust offsets later.


https://reviews.llvm.org/D22683





More information about the llvm-commits mailing list