[PATCH] D30641: [LLD][ELF] Fix ordering of Mips LA25 Thunks when Linker Script used

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 6 03:56:31 PST 2017


peter.smith created this revision.
Herald added a subscriber: sdardis.

For the Mips LA25 Thunks we want the Thunks to precede the target section. The existing code merges these thunks into OutputSections::Sections. This is not sufficient when linker scripts are used as the order of sections and the addresses assigned to them are determined by the InputSectionDescription in the LinkerScript, and thunks are generated after the InputSectionDescription contents have been generated.

This change merges the LA25 Thunks into the InputSectionDescription as well as the OutputSections so that the ordering of the Thunks is maintained. To do this we need to ask the script to calculate the offsets of the OutputSection as all the offsets for script controlled OutputSections are 0 at thunk creation time. We need to ask the script to calculate the offsets as there may be multiple InputSectionDescriptions with location expressions in between them.

The state is cleared at the start of the Linker Script address assignment as we will be running this function twice when Thunks are created.

I've gone for an implementation that merges the result of the createThunks() function into the InputSectionDescription. An alternative is to rewrite createThunks to work on ranges of InputSectionData and have createThunks ask the script for the InputSectionDescription ranges. I'm open to suggestions on how best to work out how scripts and thunks interact as range extension thunks will need to deal with location expressions.

I've based this on top of https://reviews.llvm.org/D30637.


https://reviews.llvm.org/D30641

Files:
  ELF/LinkerScript.cpp
  ELF/LinkerScript.h
  ELF/Relocations.cpp
  ELF/Writer.cpp
  test/ELF/mips-npic-call-pic-script.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30641.90669.patch
Type: text/x-patch
Size: 13056 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170306/93f858cd/attachment.bin>


More information about the llvm-commits mailing list