[ELF] Choose default segment when it is not specified
authorEugene Leviant <evgeny.leviant@gmail.com>
Wed, 19 Oct 2016 15:04:49 +0000 (15:04 +0000)
committerEugene Leviant <evgeny.leviant@gmail.com>
Wed, 19 Oct 2016 15:04:49 +0000 (15:04 +0000)
commitce30b1c78ef3b7d6e5426b4ed778eccd68162c7e
tree6731a89fe109d7861cff29ae48756016ae26f02b
parent37dabc24270ceb55337544c8df904208659a5330
[ELF] Choose default segment when it is not specified

Linker scripts may specify PHDRS, but not specify section to
segment assignments, i.e:

PHDRS { seg PT_LOAD; }
SECTIONS {
  .sec1 {} : seg
  .sec2 {}
}

In such case linker should still choose some segment for .sec2 section.
This patch will add .sec2 to previously opened segments (seg) or to the
very first PT_LOAD segment, if no section-to-segment assignments has been
made

Differential revision: https://reviews.llvm.org/D24795

llvm-svn: 284600
lld/ELF/LinkerScript.cpp
lld/test/ELF/linkerscript/openbsd-randomize.s
lld/test/ELF/linkerscript/phdrs-flags.s
lld/test/ELF/linkerscript/phdrs.s