llvm-project/lld/lib
Rafael Auler 9a7e211e8f [LinkerScript] Implement semantics for simple sections mappings
This commit implements the behaviour of the SECTIONS linker script directive,
used to not only define a custom mapping between input and output sections, but
also order input sections in the output file. To do this, we modify
DefaultLayout with hooks at important places that allow us to re-order input
sections according to a custom order. We also add a hook in SegmentChunk to
allow us to calculate linker script expressions while assigning virtual
addresses to the input sections that live in a segment.

Not all SECTIONS constructs are currently supported, but only the ones that do
not use special sort orders. It adds two LIT test as practical examples of
which sections directives are currently supported.

In terms of high-level changes, it creates 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 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.

http://reviews.llvm.org/D8157

llvm-svn: 232402
2015-03-16 19:55:15 +00:00
..
Config add_lld_library -> add_llvm_library 2015-01-21 21:26:27 +00:00
Core [LinkerScript] Implement linker script expression evaluation 2015-03-09 21:43:35 +00:00
Driver [LinkerScript] Implement semantics for simple sections mappings 2015-03-16 19:55:15 +00:00
ReaderWriter [LinkerScript] Implement semantics for simple sections mappings 2015-03-16 19:55:15 +00:00
CMakeLists.txt Remove YAML/Native round-trip passes. 2015-02-20 22:10:28 +00:00
Makefile Update makefile to reflect that the Passes directory is gone here. 2015-03-07 09:03:17 +00:00