[PATCH] D28803: [ELF] - Support optional comma after output section command.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 17 07:05:44 PST 2017
LGTM
George Rimar via Phabricator <reviews at reviews.llvm.org> writes:
> grimar created this revision.
>
> I found this when tried to link linux kernel with LLD:
>
> https://github.com/torvalds/linux/blob/master/arch/x86/entry/vdso/vdso-layout.lds.S#L86
>
> Output section command can have optional comma at the end:
>
> .text : { *(.text*) } :text =0x90909090,
>
> It was documented about 3 years ago for binutils:
> https://sourceware.org/ml/binutils/2014-04/msg00045.html
>
>
> https://reviews.llvm.org/D28803
>
> 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
> @@ -36,6 +36,11 @@
> # RUN: ld.lld -o %t.out --script %t.script %t
> # RUN: llvm-objdump -s %t.out | FileCheck -check-prefix=YES %s
>
> +## Check case with optional comma following output section command:
> +# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x1122, .a : { *(.a*) } }" > %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
> @@ -1471,6 +1471,9 @@
> else if (peek().startswith("="))
> Cmd->Filler = readOutputSectionFiller(next().drop_front());
>
> + // Consume optional comma following output section command.
> + consume(",");
> +
> return Cmd;
> }
>
>
>
> Index: test/ELF/linkerscript/sections-padding.s
> ===================================================================
> --- test/ELF/linkerscript/sections-padding.s
> +++ test/ELF/linkerscript/sections-padding.s
> @@ -36,6 +36,11 @@
> # RUN: ld.lld -o %t.out --script %t.script %t
> # RUN: llvm-objdump -s %t.out | FileCheck -check-prefix=YES %s
>
> +## Check case with optional comma following output section command:
> +# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x1122, .a : { *(.a*) } }" > %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
> @@ -1471,6 +1471,9 @@
> else if (peek().startswith("="))
> Cmd->Filler = readOutputSectionFiller(next().drop_front());
>
> + // Consume optional comma following output section command.
> + consume(",");
> +
> return Cmd;
> }
>
More information about the llvm-commits
mailing list