[lld] r303770 - Do not track section types of previous sections, always use PROGBITS for dummy sections.

Dmitry Mikulin via llvm-commits llvm-commits at lists.llvm.org
Wed May 24 09:48:31 PDT 2017


Author: dmikulin
Date: Wed May 24 11:48:31 2017
New Revision: 303770

URL: http://llvm.org/viewvc/llvm-project?rev=303770&view=rev
Log:
Do not track section types of previous sections, always use PROGBITS for dummy sections.

Fix for PR33029.

Added:
    lld/trunk/test/ELF/linkerscript/arm-lscript.s
Modified:
    lld/trunk/ELF/LinkerScript.cpp

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=303770&r1=303769&r2=303770&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Wed May 24 11:48:31 2017
@@ -684,7 +684,6 @@ void LinkerScript::adjustSectionsBeforeS
   // '.' is assigned to, but creating these section should not have any bad
   // consequeces and gives us a section to put the symbol in.
   uint64_t Flags = SHF_ALLOC;
-  uint32_t Type = SHT_PROGBITS;
 
   for (int I = 0, E = Opt.Commands.size(); I != E; ++I) {
     auto *Cmd = dyn_cast<OutputSectionCommand>(Opt.Commands[I]);
@@ -692,14 +691,13 @@ void LinkerScript::adjustSectionsBeforeS
       continue;
     if (OutputSection *Sec = Cmd->Sec) {
       Flags = Sec->Flags;
-      Type = Sec->Type;
       continue;
     }
 
     if (isAllSectionDescription(*Cmd))
       continue;
 
-    auto *OutSec = make<OutputSection>(Cmd->Name, Type, Flags);
+    auto *OutSec = make<OutputSection>(Cmd->Name, SHT_PROGBITS, Flags);
     OutSec->SectionIndex = I;
     OutputSections->push_back(OutSec);
     Cmd->Sec = OutSec;

Added: lld/trunk/test/ELF/linkerscript/arm-lscript.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/arm-lscript.s?rev=303770&view=auto
==============================================================================
--- lld/trunk/test/ELF/linkerscript/arm-lscript.s (added)
+++ lld/trunk/test/ELF/linkerscript/arm-lscript.s Wed May 24 11:48:31 2017
@@ -0,0 +1,9 @@
+// REQUIRES: arm
+// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
+// RUN: echo  "SECTIONS { \
+// RUN:         .rel.dyn : {    } \
+// RUN:         .zed     : { PROVIDE_HIDDEN (foobar = .); } \
+// RUN:         }" > %t.script
+// This is a test case for PR33029. Making sure that linker can digest
+// the above script without dumping core.
+// RUN: ld.lld -emit-relocs -T %t.script %t.o -shared -o %t.so




More information about the llvm-commits mailing list