[lld] r309191 - [ELF, LinkerScript] Memory region name parsing fix

Meador Inge via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 26 14:51:09 PDT 2017


Author: meadori
Date: Wed Jul 26 14:51:09 2017
New Revision: 309191

URL: http://llvm.org/viewvc/llvm-project?rev=309191&view=rev
Log:
[ELF, LinkerScript] Memory region name parsing fix

This patch fixes a small issue with respect to how memory region names
are parsed on output section descriptions.  For example, consider:

  .text : { *(.text) } > rom

That can also be written like:

  .text : { *(.text) } >rom

The latter form is accepted by GNU LD and is fairly common.

Differential Revision: https://reviews.llvm.org/D35920

Modified:
    lld/trunk/ELF/ScriptParser.cpp
    lld/trunk/test/ELF/linkerscript/memory.s

Modified: lld/trunk/ELF/ScriptParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ScriptParser.cpp?rev=309191&r1=309190&r2=309191&view=diff
==============================================================================
--- lld/trunk/ELF/ScriptParser.cpp (original)
+++ lld/trunk/ELF/ScriptParser.cpp Wed Jul 26 14:51:09 2017
@@ -652,6 +652,8 @@ ScriptParser::readOutputSectionDescripti
 
   if (consume(">"))
     Cmd->MemoryRegionName = next();
+  else if (peek().startswith(">"))
+    Cmd->MemoryRegionName = next().drop_front();
 
   Cmd->Phdrs = readOutputSectionPhdrs();
 

Modified: lld/trunk/test/ELF/linkerscript/memory.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/memory.s?rev=309191&r1=309190&r2=309191&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/memory.s (original)
+++ lld/trunk/test/ELF/linkerscript/memory.s Wed Jul 26 14:51:09 2017
@@ -21,8 +21,8 @@
 # RUN:   rom (rx) : org = (0x80 * 0x1000 * 0x1000), len = 64M \
 # RUN: } \
 # RUN: SECTIONS { \
-# RUN:   .text : { *(.text) } > rom \
-# RUN:   .data : { *(.data) } > ram \
+# RUN:   .text : { *(.text) } >rom \
+# RUN:   .data : { *(.data) } >ram \
 # RUN: }" > %t.script
 # RUN: ld.lld -o %t1 --script %t.script %t
 # RUN: llvm-objdump -section-headers %t1 | FileCheck -check-prefix=RAMROM %s




More information about the llvm-commits mailing list