[PATCH] D28803: [ELF] - Support optional comma after output section command.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 17 05:25:31 PST 2017


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;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28803.84657.patch
Type: text/x-patch
Size: 1038 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170117/1d7a3d51/attachment.bin>


More information about the llvm-commits mailing list