[lld] r292225 - [ELF] - Support optional comma after output section command.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 17 07:32:12 PST 2017


Author: grimar
Date: Tue Jan 17 09:32:12 2017
New Revision: 292225

URL: http://llvm.org/viewvc/llvm-project?rev=292225&view=rev
Log:
[ELF] - Support optional comma after output section command.

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

Differential revision: https://reviews.llvm.org/D28803

Modified:
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/test/ELF/linkerscript/sections-padding.s

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=292225&r1=292224&r2=292225&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Tue Jan 17 09:32:12 2017
@@ -1471,6 +1471,9 @@ ScriptParser::readOutputSectionDescripti
   else if (peek().startswith("="))
     Cmd->Filler = readOutputSectionFiller(next().drop_front());
 
+  // Consume optional comma following output section command.
+  consume(",");
+
   return Cmd;
 }
 

Modified: lld/trunk/test/ELF/linkerscript/sections-padding.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/sections-padding.s?rev=292225&r1=292224&r2=292225&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/sections-padding.s (original)
+++ lld/trunk/test/ELF/linkerscript/sections-padding.s Tue Jan 17 09:32:12 2017
@@ -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




More information about the llvm-commits mailing list