[PATCH] D29983: [LLD][ELF] Calculate sizes of SHF_ALLOC Synthetic Sections early

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 16 11:55:08 PST 2017


ruiu added a comment.

In https://reviews.llvm.org/D29983#678530, @peter.smith wrote:

> Thank you both for the comments. I'm thinking that it may be better to rework this a little bit and resubmit as the MipsGot::PageIndex calculation breaks my assertion that adding range extension thunks can't affect the size of the SyntheticSections. The size of the MipsGot is proportional to the size of the OutputSections size (modulo 64k), while the amount of Thunks added is likely to be smaller than 64k adding a Thunk could potentially extend over a page boundary.
>
> Instead of adding a finalizeAllocSize() I'm thinking about the following pseudo-code:
>
>   // if need thunks ...
>   bool AddressesChanged = true;
>   do {
>     if (AddressesChanged)
>       updateSyntheticSectionAllocSizes();
>     AssignAddresses();
>     AddressesChanged = createThunks();
>   } while (AddressesChanged)
>
>
> I'll have a go at implementing using this model to see if it comes out a bit cleaner. Let me know if this sounds like a bad idea?


This is what I expected. We need a for-loop somewhere which adds thunks until a convergence is obtained (all addresses are fixed), so that seems overall fine.

> Some specific follow-up:
> 
> - The OS->size += 8 after the ARMExidxSentinelSection is best removed. The OS->Size of the .ARM.exidx Output Section isn't updated until assignOffsets() is called. This caused a problem when I experimentally assigned addresses beforehand, correcting the size fixed the problem with the early address assignment but we don't need it right now.



> - I think it would be possible to change the SymbolTableSection to accept the addition of locals and globals in any order, I'm happy to have a go at that but it will be worth submitting as a separate patch. Would you prefer that to be done before doing this work or after?

Maybe before, if that makes it easier for you to make other changes?

> As an aside I've experimented a bit with LinkerScript address assignment and it is possible to re-run the address assignment if all the state in the class members such as LMAOffset, AlreadyOutputOS is reset to the initial value.




https://reviews.llvm.org/D29983





More information about the llvm-commits mailing list