[PATCH] [lld] [LinkerScript] Implement semantics for simple sections mappings
rafaelauler at gmail.com
Sun Mar 8 18:49:36 PDT 2015
Hi shankar.easwaran, ruiu,
This patch should work on top of D8156 because it needs linker script
This patch implements the behaviour of the SECTIONS linker script directive,
used to define a custom mapping between input and output sections. Not all
sections constructs are currently supported, but only the ones that do not
use special sort orders. I added two LIT test as practical examples of which
sections directives are currently supported.
In terms of high-level changes, I created a new class "script::Sema" that owns
all linker script ASTs and the logic for linker script semantics as well.
ELFLinkingContext owns a single copy of Sema, which will be used throughout
the object file reading process (to assign rule ids to atoms) and writing
process (to layout sections as proposed by the linker script).
Other high-level change is that the writer no longer uses a "const" copy of
the linking context. This happens because linker script expressions must be
calculated *while* calculating final virtual addresses, which is a very late
step in object file writing. While calculating these expressions, we need to
update the linker script symbol table (inside the semantics object), and, thus,
we are "modifying our context" as we prepare to write the file.
The difference D7915 is that I implemented several suggestions from Rui and
* there is no exposed "id". Clients always ask how to order a section,
and whether we use "ids" to sort or not is internal to the Sema class
implementation. (suggestion from Rui)
* improved the input sections ordering and addressed the test case
mentioned by Shankar (second LIT test case in this patch) (suggestion from Shankar)
* refactored the code in DefaultLayout to live in ScriptLayout (suggestion from Shankar)
I also took the opportunity to improve the code and implement simple
SORT directives and wildcard matching.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 64267 bytes
Desc: not available
More information about the llvm-commits