llvm-project/lld/lib/ReaderWriter
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
..
ELF [LinkerScript] Implement semantics for simple sections mappings 2015-03-16 19:55:15 +00:00
MachO [ELF] Ability to resolve undefined symbols lazily 2015-03-14 10:34:43 +00:00
Native Remove sectionPosition attribute. 2015-03-08 01:01:40 +00:00
PECOFF [ELF] Ability to resolve undefined symbols lazily 2015-03-14 10:34:43 +00:00
YAML Remove sectionPosition attribute. 2015-03-08 01:01:40 +00:00
CMakeLists.txt Remove YAML/Native round-trip passes. 2015-02-20 22:10:28 +00:00
CoreLinkingContext.cpp Remove sectionPosition attribute. 2015-03-08 01:01:40 +00:00
FileArchive.cpp Make File non-const in the resolver. 2015-03-04 04:36:46 +00:00
LinkerScript.cpp [LinkerScript] Implement semantics for simple sections mappings 2015-03-16 19:55:15 +00:00
Makefile Initial set of Makefiles 2014-06-04 09:54:07 +00:00