[lld] r320431 - ELF: Do not follow relocation edges to output sections during GC.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 11 14:47:43 PST 2017


Author: pcc
Date: Mon Dec 11 14:47:43 2017
New Revision: 320431

URL: http://llvm.org/viewvc/llvm-project?rev=320431&view=rev
Log:
ELF: Do not follow relocation edges to output sections during GC.

This fixes an assertion error introduced by r320390.

Differential Revision: https://reviews.llvm.org/D41095

Modified:
    lld/trunk/ELF/MarkLive.cpp
    lld/trunk/test/ELF/gc-sections-linker-defined-symbol.s

Modified: lld/trunk/ELF/MarkLive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MarkLive.cpp?rev=320431&r1=320430&r2=320431&view=diff
==============================================================================
--- lld/trunk/ELF/MarkLive.cpp (original)
+++ lld/trunk/ELF/MarkLive.cpp Mon Dec 11 14:47:43 2017
@@ -71,12 +71,13 @@ static void resolveReloc(InputSectionBas
       SS->getFile<ELFT>()->IsNeeded = true;
 
   if (auto *D = dyn_cast<Defined>(&B)) {
-    if (!D->Section)
+    auto *RelSec = dyn_cast_or_null<InputSectionBase>(D->Section);
+    if (!RelSec)
       return;
     uint64_t Offset = D->Value;
     if (D->isSection())
       Offset += getAddend<ELFT>(Sec, Rel);
-    Fn(cast<InputSectionBase>(D->Section), Offset);
+    Fn(RelSec, Offset);
     return;
   }
 

Modified: lld/trunk/test/ELF/gc-sections-linker-defined-symbol.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gc-sections-linker-defined-symbol.s?rev=320431&r1=320430&r2=320431&view=diff
==============================================================================
--- lld/trunk/test/ELF/gc-sections-linker-defined-symbol.s (original)
+++ lld/trunk/test/ELF/gc-sections-linker-defined-symbol.s Mon Dec 11 14:47:43 2017
@@ -13,4 +13,6 @@
 # CHECK-NEXT: Section: .dynamic
 
         .data
+        .globl g
+        g:
         .quad _end




More information about the llvm-commits mailing list