[lld] r287969 - Create sections with just assignments as STT_NOBITS.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 25 22:55:35 PST 2016


Author: rafael
Date: Sat Nov 26 00:55:35 2016
New Revision: 287969

URL: http://llvm.org/viewvc/llvm-project?rev=287969&view=rev
Log:
Create sections with just assignments as STT_NOBITS.

This matches the behaviour of bfd ld. Using 0 was causing problems
with strip, which would remove these sections.

Modified:
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/test/ELF/linkerscript/symbol-only.s

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=287969&r1=287968&r2=287969&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Sat Nov 26 00:55:35 2016
@@ -566,7 +566,7 @@ template <class ELFT> void LinkerScript<
   // '.' is assigned to, but creating these section should not have any bad
   // consequeces and gives us a section to put the symbol in.
   uintX_t Flags = SHF_ALLOC;
-  uint32_t Type = 0;
+  uint32_t Type = SHT_NOBITS;
   for (const std::unique_ptr<BaseCommand> &Base : Opt.Commands) {
     auto *Cmd = dyn_cast<OutputSectionCommand>(Base.get());
     if (!Cmd)

Modified: lld/trunk/test/ELF/linkerscript/symbol-only.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/symbol-only.s?rev=287969&r1=287968&r2=287969&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/symbol-only.s (original)
+++ lld/trunk/test/ELF/linkerscript/symbol-only.s Sat Nov 26 00:55:35 2016
@@ -12,8 +12,8 @@
 # CHECK:      Sections:
 # CHECK-NEXT: Idx Name          Size      Address
 # CHECK-NEXT:   0               00000000 0000000000000000
-# CHECK-NEXT:   1 abc           00000000 [[ADDR:[0-9a-f]*]]
-# CHECK-NEXT:   2 bar           00000000 0000000000001000 DATA
+# CHECK:          abc           00000000 [[ADDR:[0-9a-f]*]] BSS
+# CHECK-NEXT:     bar           00000000 0000000000001000 DATA
 
 # CHECK: SYMBOL TABLE:
 # CHECK:     [[ADDR]]         abc                00000000 foo




More information about the llvm-commits mailing list