[PATCH] D35920: [ELF, LinkerScript] Memory region name parsing fix

Meador Inge via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 26 14:44:49 PDT 2017


meadori created this revision.
Herald added a subscriber: emaste.

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.


https://reviews.llvm.org/D35920

Files:
  ELF/ScriptParser.cpp
  test/ELF/linkerscript/memory.s


Index: test/ELF/linkerscript/memory.s
===================================================================
--- test/ELF/linkerscript/memory.s
+++ test/ELF/linkerscript/memory.s
@@ -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
Index: ELF/ScriptParser.cpp
===================================================================
--- ELF/ScriptParser.cpp
+++ ELF/ScriptParser.cpp
@@ -652,6 +652,8 @@
 
   if (consume(">"))
     Cmd->MemoryRegionName = next();
+  else if (peek().startswith(">"))
+    Cmd->MemoryRegionName = next().drop_front();
 
   Cmd->Phdrs = readOutputSectionPhdrs();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35920.108364.patch
Type: text/x-patch
Size: 949 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170726/08150103/attachment.bin>


More information about the llvm-commits mailing list