[lld] r308681 - Fix symbol type with icf.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 20 14:55:40 PDT 2017


Author: rafael
Date: Thu Jul 20 14:55:40 2017
New Revision: 308681

URL: http://llvm.org/viewvc/llvm-project?rev=308681&view=rev
Log:
Fix symbol type with icf.

We were not looking at Repl and so thinking there was no output
section associated with the merged symbol. Because of that it was
produced as absolute.

This was found by an internal round of testing.

Added:
    lld/trunk/test/ELF/icf-symbol-type.s
Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/test/ELF/arm-icf-exidx.s

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=308681&r1=308680&r2=308681&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Thu Jul 20 14:55:40 2017
@@ -160,7 +160,7 @@ uint64_t SectionBase::getOffset(uint64_t
 OutputSection *SectionBase::getOutputSection() {
   InputSection *Sec;
   if (auto *IS = dyn_cast<InputSection>(this))
-    Sec = IS;
+    Sec = cast<InputSection>(IS->Repl);
   else if (auto *MS = dyn_cast<MergeInputSection>(this))
     Sec = MS->getParent();
   else if (auto *EH = dyn_cast<EhInputSection>(this))

Modified: lld/trunk/test/ELF/arm-icf-exidx.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/arm-icf-exidx.s?rev=308681&r1=308680&r2=308681&view=diff
==============================================================================
--- lld/trunk/test/ELF/arm-icf-exidx.s (original)
+++ lld/trunk/test/ELF/arm-icf-exidx.s Thu Jul 20 14:55:40 2017
@@ -23,7 +23,7 @@ __aeabi_unwind_cpp_pr0:
  bx lr
 
 // CHECK: Disassembly of section .text:
-// CHECK-NEXT: f:
+// CHECK-NEXT: g:
 // CHECK-NEXT:    11000:        1e ff 2f e1     bx      lr
 // CHECK: __aeabi_unwind_cpp_pr0:
 // CHECK-NEXT:    11004:        00 f0 20 e3     nop

Added: lld/trunk/test/ELF/icf-symbol-type.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf-symbol-type.s?rev=308681&view=auto
==============================================================================
--- lld/trunk/test/ELF/icf-symbol-type.s (added)
+++ lld/trunk/test/ELF/icf-symbol-type.s Thu Jul 20 14:55:40 2017
@@ -0,0 +1,20 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld %t.o -o %t --icf=all -shared
+# RUN: llvm-readelf --dyn-symbols %t | FileCheck %s
+
+# We used to mark bar as absolute.
+
+# CHECK: [[ADDR:[0-9a-z]*]]  0 NOTYPE  GLOBAL DEFAULT   4 foo
+# CHECK: [[ADDR]]            0 NOTYPE  GLOBAL DEFAULT   4 bar
+
+        .section        .text.f,"ax", at progbits
+        .globl  foo
+foo:
+        retq
+
+        .section        .text.g,"ax", at progbits
+        .globl  bar
+bar:
+        retq




More information about the llvm-commits mailing list