[lld] r329219 - Don't ignore addend in getOffset.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 4 12:13:31 PDT 2018


Author: rafael
Date: Wed Apr  4 12:13:30 2018
New Revision: 329219

URL: http://llvm.org/viewvc/llvm-project?rev=329219&view=rev
Log:
Don't ignore addend in getOffset.

We were ignoring the addend if the piece was dead. I don't expect this
to make a difference in any real world situations, but it is simpler
anyway.

Added:
    lld/trunk/test/ELF/merge-gc-piece.s
Modified:
    lld/trunk/ELF/InputSection.cpp

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=329219&r1=329218&r2=329219&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed Apr  4 12:13:30 2018
@@ -978,9 +978,6 @@ uint64_t MergeInputSection::getOffset(ui
   // In that case we need to search from the original section piece vector.
   const SectionPiece &Piece =
       *findSectionPiece(const_cast<MergeInputSection *>(this), Offset);
-  if (!Piece.Live)
-    return 0;
-
   uint64_t Addend = Offset - Piece.InputOff;
   return Piece.OutputOff + Addend;
 }

Added: lld/trunk/test/ELF/merge-gc-piece.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/merge-gc-piece.s?rev=329219&view=auto
==============================================================================
--- lld/trunk/test/ELF/merge-gc-piece.s (added)
+++ lld/trunk/test/ELF/merge-gc-piece.s Wed Apr  4 12:13:30 2018
@@ -0,0 +1,29 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld %t.o -o %t.so -shared --gc-sections
+# RUN: llvm-readobj -s -section-data %t.so | FileCheck %s
+
+# CHECK:      Name: .bar
+# CHECK-NEXT: Type: SHT_PROGBITS
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address:
+# CHECK-NEXT: Offset:
+# CHECK-NEXT: Size: 16
+# CHECK-NEXT: Link:
+# CHECK-NEXT: Info:
+# CHECK-NEXT: AddressAlignment:
+# CHECK-NEXT: EntrySize:
+# CHECK-NEXT: SectionData (
+# CHECK-NEXT:   0000: 90010000 00000000 91010000 00000000
+# CHECK-NEXT: )
+
+        .section .foo,"aM", at progbits,8
+        .quad 42
+        .global sym
+sym:
+        .quad 43
+
+        .section .bar
+        .quad .foo + 1
+        .quad .foo + 2




More information about the llvm-commits mailing list