[PATCH] D29276: [ELF] - Linkerscript: do not fail on additional semicolons in linkerscript.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 30 09:34:51 PST 2017
LGTM
George Rimar via Phabricator <reviews at reviews.llvm.org> writes:
> grimar updated this revision to Diff 86283.
> grimar added a comment.
>
> - Addressed review comments.
>
>
> https://reviews.llvm.org/D29276
>
> Files:
> ELF/LinkerScript.cpp
> test/ELF/linkerscript/sections.s
>
>
> Index: test/ELF/linkerscript/sections.s
> ===================================================================
> --- test/ELF/linkerscript/sections.s
> +++ test/ELF/linkerscript/sections.s
> @@ -93,6 +93,11 @@
> # SEC-MULTI: 6 .shstrtab 00000035 {{[0-9a-f]*}}
> # SEC-MULTI: 7 .strtab 00000008 {{[0-9a-f]*}}
>
> +# Input section pattern contains additional semicolon.
> +# Case found in linux kernel script. Check we are able to parse it.
> +# RUN: echo "SECTIONS { .text : { ;;*(.text);;S = 0;; } }" > %t.script
> +# RUN: ld.lld -o /dev/null --script %t.script %t
> +
> .globl _start
> _start:
> mov $60, %rax
> Index: ELF/LinkerScript.cpp
> ===================================================================
> --- ELF/LinkerScript.cpp
> +++ ELF/LinkerScript.cpp
> @@ -1493,7 +1493,9 @@
>
> while (!Error && !consume("}")) {
> StringRef Tok = next();
> - if (SymbolAssignment *Assignment = readProvideOrAssignment(Tok)) {
> + if (Tok == ";") {
> + // Unnecessary semicolons are permitted here, but should be ignored.
> + } else if (SymbolAssignment *Assignment = readProvideOrAssignment(Tok)) {
> Cmd->Commands.emplace_back(Assignment);
> } else if (BytesDataCommand *Data = readBytesDataCommand(Tok)) {
> Cmd->Commands.emplace_back(Data);
>
>
> Index: test/ELF/linkerscript/sections.s
> ===================================================================
> --- test/ELF/linkerscript/sections.s
> +++ test/ELF/linkerscript/sections.s
> @@ -93,6 +93,11 @@
> # SEC-MULTI: 6 .shstrtab 00000035 {{[0-9a-f]*}}
> # SEC-MULTI: 7 .strtab 00000008 {{[0-9a-f]*}}
>
> +# Input section pattern contains additional semicolon.
> +# Case found in linux kernel script. Check we are able to parse it.
> +# RUN: echo "SECTIONS { .text : { ;;*(.text);;S = 0;; } }" > %t.script
> +# RUN: ld.lld -o /dev/null --script %t.script %t
> +
> .globl _start
> _start:
> mov $60, %rax
> Index: ELF/LinkerScript.cpp
> ===================================================================
> --- ELF/LinkerScript.cpp
> +++ ELF/LinkerScript.cpp
> @@ -1493,7 +1493,9 @@
>
> while (!Error && !consume("}")) {
> StringRef Tok = next();
> - if (SymbolAssignment *Assignment = readProvideOrAssignment(Tok)) {
> + if (Tok == ";") {
> + // Unnecessary semicolons are permitted here, but should be ignored.
> + } else if (SymbolAssignment *Assignment = readProvideOrAssignment(Tok)) {
> Cmd->Commands.emplace_back(Assignment);
> } else if (BytesDataCommand *Data = readBytesDataCommand(Tok)) {
> Cmd->Commands.emplace_back(Data);
More information about the llvm-commits
mailing list