Description
This notes down a small pass ordering issue related to our thunk creation framework.
If the synthetic section .rela.dyn has no entries before thunk creation, it will be removed. The output will have no .rela.dyn section.
Writer<ELFT>::run
Writer<ELFT>::finalizeSections
forEachRelSec(scanRelocations<ELFT>) // Most dynamic relocations are added in this pass.
removeUnusedSyntheticSections
// The synthetic section .rela.dyn is removed from its parent (OutputSection .rela.dyn) because it has no entries.
Writer<ELFT>::finalizeAddressDependentContent
ThunkCreator::createThunks
// Add a dynamic relocation to mainPart->relaDyn. It is essentially a no-op because .rela.dyn is dead.
This can affect targets that add dynamic relocations in ThunkCreator::createThunks
. Currently only PPC64 is affected, because only PPC64 needs .branch_lt to work around the lack of PC-relative addressing before Power ISA v3.0.
Fortunately, this pass ordering problem usually does not matter in practice. PPC64PILongBranchThunk
is used by PIC (config->isPic
) cases. In PIC cases, there are almost assuredly some dynamic relocations.
It is not clear that it can be easily fixed and a fix is probably not worthwhile on its own. If there are other problems related to ordering of thunk creation, we can revisit this.