ELF: Change how to handle KEEP linker script command.
authorRui Ueyama <ruiu@google.com>
Thu, 21 Apr 2016 22:00:51 +0000 (22:00 +0000)
committerRui Ueyama <ruiu@google.com>
Thu, 21 Apr 2016 22:00:51 +0000 (22:00 +0000)
commit8ec77e64fcd419df30e09989bcba62c5cb9fd172
treebf9fa9dc7b90805ff201e4bfae471980150214b3
parent243b71fd8b9171be13cc3279583c1426a532a25c
ELF: Change how to handle KEEP linker script command.

You can instruct the linker to not discard sections even if they
are unused and --gc-sections option is given. The linker script
command for doing that is KEEP. The syntax is KEEP(foo) where foo
is a section name. KEEP commands are written in SECTIONS command,
so you can specify the order of sections *and* which sections
will be kept.

Each sub-command in SECTIONS command are translated into SectionRule
object. Previously, each SectionRule has `Keep` bit. However,
if you think about it, this hid information in too deep in elements
of a list. Semantically, KEEP commands aren't really related to
SECTIONS subcommands. We can keep the section list for KEEP in a
separate list. This patch does that.

llvm-svn: 267065
lld/ELF/LinkerScript.cpp
lld/ELF/LinkerScript.h
lld/test/ELF/linkerscript-sections-keep.s