[lld] r329367 - Don't ignore addend when a SHF_MERGE section is dead.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 5 18:10:33 PDT 2018
Author: rafael
Date: Thu Apr 5 18:10:33 2018
New Revision: 329367
URL: http://llvm.org/viewvc/llvm-project?rev=329367&view=rev
Log:
Don't ignore addend when a SHF_MERGE section is dead.
This is similar to r329219, but for the entire section. Like r329219 I
don't expect this to have any real impact, it is just more consistent
and simpler.
Added:
lld/trunk/test/ELF/merge-gc-piece2.s
Modified:
lld/trunk/ELF/InputSection.cpp
lld/trunk/ELF/SyntheticSections.cpp
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=329367&r1=329366&r2=329367&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Thu Apr 5 18:10:33 2018
@@ -970,9 +970,6 @@ SectionPiece *MergeInputSection::getSect
// Because contents of a mergeable section is not contiguous in output,
// it is not just an addition to a base output offset.
uint64_t MergeInputSection::getOffset(uint64_t Offset) const {
- if (!Live)
- return 0;
-
// Find a string starting at a given offset.
auto It = OffsetMap.find(Offset);
if (It != OffsetMap.end())
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=329367&r1=329366&r2=329367&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Thu Apr 5 18:10:33 2018
@@ -2532,9 +2532,8 @@ void elf::mergeSections() {
// splitIntoPieces needs to be called on each MergeInputSection
// before calling finalizeContents(). Do that first.
parallelForEach(InputSections, [](InputSectionBase *Sec) {
- if (Sec->Live)
- if (auto *S = dyn_cast<MergeInputSection>(Sec))
- S->splitIntoPieces();
+ if (auto *S = dyn_cast<MergeInputSection>(Sec))
+ S->splitIntoPieces();
});
std::vector<MergeSyntheticSection *> MergeSections;
Added: lld/trunk/test/ELF/merge-gc-piece2.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/merge-gc-piece2.s?rev=329367&view=auto
==============================================================================
--- lld/trunk/test/ELF/merge-gc-piece2.s (added)
+++ lld/trunk/test/ELF/merge-gc-piece2.s Thu Apr 5 18:10:33 2018
@@ -0,0 +1,27 @@
+# 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: 01000000 00000000 02000000 00000000
+# CHECK-NEXT: )
+
+ .section .foo,"aM", at progbits,8
+ .quad 42
+ .quad 43
+
+ .section .bar
+ .quad .foo + 1
+ .quad .foo + 2
More information about the llvm-commits
mailing list