[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

llvm-svn: 309191
This commit is contained in:
Meador Inge 2017-07-26 21:51:09 +00:00
parent cb98c14f89
commit b0e6229742
2 changed files with 4 additions and 2 deletions

View File

@ -652,6 +652,8 @@ ScriptParser::readOutputSectionDescription(StringRef OutSec) {
if (consume(">"))
Cmd->MemoryRegionName = next();
else if (peek().startswith(">"))
Cmd->MemoryRegionName = next().drop_front();
Cmd->Phdrs = readOutputSectionPhdrs();

View File

@ -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