From 1c08e9f5cee04c0164a5f8408e6854ce64fe3d29 Mon Sep 17 00:00:00 2001 From: George Rimar Date: Fri, 16 Feb 2018 10:42:58 +0000 Subject: [ELF] - Support COPY, INFO, OVERLAY output sections attributes. This is PR36298. (COPY), (INFO), (OVERLAY) all have the same effect: section should be marked as non-allocatable. (https://www.eecs.umich.edu/courses/eecs373/readings/Linker.pdf, 3.6.8.1 Output Section Type) Differential revision: https://reviews.llvm.org/D43071 llvm-svn: 325331 --- lld/ELF/ScriptParser.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'lld/ELF/ScriptParser.cpp') diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index 9f3eeda8b58..41857227641 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -617,12 +617,14 @@ uint32_t ScriptParser::readFill() { return V; } -// Reads an expression and/or the special directive "(NOLOAD)" for an -// output section definition. +// Reads an expression and/or the special directive for an output +// section definition. Directive is one of following: "(NOLOAD)", +// "(COPY)", "(INFO)" or "(OVERLAY)". // // An output section name can be followed by an address expression -// and/or by "(NOLOAD)". This grammar is not LL(1) because "(" can be -// interpreted as either the beginning of some expression or "(NOLOAD)". +// and/or directive. This grammar is not LL(1) because "(" can be +// interpreted as either the beginning of some expression or begining +// of directive. // // https://sourceware.org/binutils/docs/ld/Output-Section-Address.html // https://sourceware.org/binutils/docs/ld/Output-Section-Type.html @@ -633,6 +635,11 @@ void ScriptParser::readSectionAddressType(OutputSection *Cmd) { Cmd->Noload = true; return; } + if (consume("COPY") || consume("INFO") || consume("OVERLAY")) { + expect(")"); + Cmd->NonAlloc = true; + return; + } Cmd->AddrExpr = readExpr(); expect(")"); } else { -- cgit v1.2.3