[PATCH] D24831: [ELF] - Linkerscript: accept space between '=' and expression in section filler.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 22 09:35:12 PDT 2016
grimar created this revision.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, evgeny777.
Previously we failed to parce next scripts because disallowed
a space between filler value and '=':
```
.text : {
...
} :text = 0x9090
```
Found it in the wild here: https://searchcode.com/file/61508112/xen/arch/x86/xen.lds.S
https://reviews.llvm.org/D24831
Files:
ELF/LinkerScript.cpp
test/ELF/linkerscript/sections-padding.s
Index: test/ELF/linkerscript/sections-padding.s
===================================================================
--- test/ELF/linkerscript/sections-padding.s
+++ 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
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -1217,8 +1217,13 @@
setError("unknown command " + Tok);
}
Cmd->Phdrs = readOutputSectionPhdrs();
- if (peek().startswith("="))
- Cmd->Filler = readOutputSectionFiller(next().drop_front());
+ if (peek().startswith("=")) {
+ StringRef Filler = next().drop_front();
+ // GNU linkers accepts a space between '=' and fill expression.
+ if (Filler.empty())
+ Filler = next();
+ Cmd->Filler = readOutputSectionFiller(Filler);
+ }
return Cmd;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24831.72183.patch
Type: text/x-patch
Size: 1239 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160922/d6a40fb6/attachment.bin>
More information about the llvm-commits
mailing list