From 4ebc562052d82bd51179703a4f9e557ced817973 Mon Sep 17 00:00:00 2001 From: George Rimar Date: Fri, 23 Sep 2016 13:29:20 +0000 Subject: [PATCH] [ELF] - Linkerscript: accept space between '=' and expression in section filler. Previously we failed to parse next scripts because disallowed a space between filler value and '=': .text : { ... } :text = 0x9090 Differential revision: https://reviews.llvm.org/D24831 llvm-svn: 282248 --- lld/ELF/LinkerScript.cpp | 6 +++++- lld/test/ELF/linkerscript/sections-padding.s | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 0febb25..646dbbd 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -1275,8 +1275,12 @@ ScriptParser::readOutputSectionDescription(StringRef OutSec) { setError("unknown command " + Tok); } Cmd->Phdrs = readOutputSectionPhdrs(); - if (peek().startswith("=")) + + if (skip("=")) + Cmd->Filler = readOutputSectionFiller(next()); + else if (peek().startswith("=")) Cmd->Filler = readOutputSectionFiller(next().drop_front()); + return Cmd; } diff --git a/lld/test/ELF/linkerscript/sections-padding.s b/lld/test/ELF/linkerscript/sections-padding.s index e9efc75..51d3a88 100644 --- a/lld/test/ELF/linkerscript/sections-padding.s +++ b/lld/test/ELF/linkerscript/sections-padding.s @@ -31,6 +31,11 @@ # RUN: | FileCheck --check-prefix=ERR2 %s # ERR2: invalid filler expression: 0x99XX +## Check case with space between '=' and expression: +# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } = 0x1122 }" > %t.script +# RUN: ld.lld -o %t.out --script %t.script %t +# RUN: llvm-objdump -s %t.out | FileCheck -check-prefix=YES %s + .section .mysec.1,"a" .align 16 .byte 0x66 -- 2.7.4