[ELF] - Linkerscript: implement NOLOAD section type.

This is PR32351

Each output section may have a type. The type is a keyword in parentheses.
(https://sourceware.org/binutils/docs/ld/Output-Section-Type.html#Output-Section-Type)
This patch support only one type, it is NOLOAD.
If output section has such type, we force it to be SHT_NOBITS. 

More details are available on a review page.

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

llvm-svn: 304925
This commit is contained in:
George Rimar
2017-06-07 16:31:08 +00:00
parent 92f6677159
commit fbb0463f39
4 changed files with 63 additions and 4 deletions

View File

@@ -568,10 +568,20 @@ ScriptParser::readOutputSectionDescription(StringRef OutSec) {
OutputSectionCommand *Cmd =
Script->createOutputSectionCommand(OutSec, getCurrentLocation());
// Read an address expression.
// https://sourceware.org/binutils/docs/ld/Output-Section-Address.html
if (peek() != ":")
Cmd->AddrExpr = readExpr();
if (peek() != ":") {
// Read an address expression.
// https://sourceware.org/binutils/docs/ld/Output-Section-Address.html
if (peek() != "(")
Cmd->AddrExpr = readExpr();
// Read a section type. Currently, only NOLOAD is supported.
// https://sourceware.org/binutils/docs/ld/Output-Section-Type.html
if (consume("(")) {
expect("NOLOAD");
expect(")");
Cmd->Noload = true;
}
}
expect(":");