[PATCH] D43241: [ELF] - Do not crash with --emit-relocs and --icf=all together.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 02:30:18 PST 2018


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325877: [ELF] - Do not crash with --emit-relocs and --icf=all together. (authored by grimar, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43241?vs=134859&id=135609#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43241

Files:
  lld/trunk/ELF/InputSection.cpp
  lld/trunk/test/ELF/emit-relocs-icf.s


Index: lld/trunk/test/ELF/emit-relocs-icf.s
===================================================================
--- lld/trunk/test/ELF/emit-relocs-icf.s
+++ lld/trunk/test/ELF/emit-relocs-icf.s
@@ -0,0 +1,33 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
+# RUN: ld.lld --emit-relocs --icf=all %t1.o -o %t
+# RUN: llvm-readobj -r %t | FileCheck %s
+
+# CHECK:      Relocations [
+# CHECK-NEXT:   Section {{.*}} .rela.text {
+# CHECK-NEXT:     R_X86_64_32 .text 0x1
+# CHECK-NEXT:     R_X86_64_PLT32 fn 0xFFFFFFFFFFFFFFFC
+# CHECK-NEXT:   }
+# CHECK-NEXT: ]
+
+.section .text.fn,"ax", at progbits,unique,0
+.globl fn
+.type fn, at function
+fn:
+ nop
+
+bar:
+  movl $bar, %edx
+  callq fn at PLT
+  nop
+
+.section .text.fn2,"ax", at progbits,unique,1
+.globl fn2
+.type fn2, at function
+fn2:
+ nop
+
+foo:
+  movl $foo, %edx
+  callq fn2 at PLT
+  nop
Index: lld/trunk/ELF/InputSection.cpp
===================================================================
--- lld/trunk/ELF/InputSection.cpp
+++ lld/trunk/ELF/InputSection.cpp
@@ -789,6 +789,8 @@
   Alignment = std::max(Alignment, Other->Alignment);
   Other->Repl = Repl;
   Other->Live = false;
+  for (InputSection *IS : Other->DependentSections)
+    IS->Live = false;
 }
 
 template <class ELFT>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43241.135609.patch
Type: text/x-patch
Size: 1281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180223/253248d9/attachment.bin>


More information about the llvm-commits mailing list