[lld] r276175 - Delete EhInputSection::getOffset.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 20 13:19:59 PDT 2016
Author: rafael
Date: Wed Jul 20 15:19:58 2016
New Revision: 276175
URL: http://llvm.org/viewvc/llvm-project?rev=276175&view=rev
Log:
Delete EhInputSection::getOffset.
We no longer need it for relocations in .eh_frame.
The only relocations that point to .eh_frame are the ones trying to
find the output .eh_frame.
This actually fixes a bug in the symbol value code. It was not
handling -1 as an indicator for a piece not being included in the
output.
Modified:
lld/trunk/ELF/InputSection.cpp
lld/trunk/ELF/InputSection.h
lld/trunk/ELF/Relocations.cpp
lld/trunk/test/ELF/eh-frame-marker.s
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=276175&r1=276174&r2=276175&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed Jul 20 15:19:58 2016
@@ -68,7 +68,10 @@ typename ELFT::uint InputSectionBase<ELF
case Regular:
return cast<InputSection<ELFT>>(this)->OutSecOff + Offset;
case EHFrame:
- return cast<EhInputSection<ELFT>>(this)->getOffset(Offset);
+ // The file crtbeginT.o has relocations pointing to the start of an empty
+ // .eh_frame that is known to be the first in the link. It does that to
+ // identify the start of the output .eh_frame.
+ return Offset;
case Merge:
return cast<MergeInputSection<ELFT>>(this)->getOffset(Offset);
case MipsReginfo:
@@ -461,21 +464,6 @@ void EhInputSection<ELFT>::split() {
}
}
-template <class ELFT>
-typename ELFT::uint EhInputSection<ELFT>::getOffset(uintX_t Offset) const {
- // The file crtbeginT.o has relocations pointing to the start of an empty
- // .eh_frame that is known to be the first in the link. It does that to
- // identify the start of the output .eh_frame. Handle this special case.
- if (this->getSectionHdr()->sh_size == 0)
- return Offset;
- const SectionPiece *Piece = this->getSectionPiece(Offset);
- if (Piece->OutputOff == size_t(-1))
- return -1; // Not in the output
-
- uintX_t Addend = Offset - Piece->InputOff;
- return Piece->OutputOff + Addend;
-}
-
static size_t findNull(ArrayRef<uint8_t> A, size_t EntSize) {
// Optimize the common case.
StringRef S((const char *)A.data(), A.size());
Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=276175&r1=276174&r2=276175&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Wed Jul 20 15:19:58 2016
@@ -171,10 +171,6 @@ public:
static bool classof(const InputSectionBase<ELFT> *S);
void split();
- // Translate an offset in the input section to an offset in the output
- // section.
- uintX_t getOffset(uintX_t Offset) const;
-
// Relocation section that refer to this one.
const Elf_Shdr *RelocSection = nullptr;
};
Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=276175&r1=276174&r2=276175&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Wed Jul 20 15:19:58 2016
@@ -557,7 +557,6 @@ static void scanRelocs(InputSectionBase<
if (PieceI->OutputOff == (uintX_t)-1)
continue;
Offset = PieceI->OutputOff + RI.r_offset - PieceI->InputOff;
- assert(Offset == C.getOffset(RI.r_offset));
} else {
Offset = C.getOffset(RI.r_offset);
}
Modified: lld/trunk/test/ELF/eh-frame-marker.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/eh-frame-marker.s?rev=276175&r1=276174&r2=276175&view=diff
==============================================================================
--- lld/trunk/test/ELF/eh-frame-marker.s (original)
+++ lld/trunk/test/ELF/eh-frame-marker.s Wed Jul 20 15:19:58 2016
@@ -1,6 +1,18 @@
// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
// RUN: ld.lld --eh-frame-hdr %t.o -o %t.so -shared
+// RUN: llvm-readobj -t -s %t.so | FileCheck %s
// We used to crash on this.
+
+// CHECK: Name: .eh_frame
+// CHECK-NEXT: Type: SHT_PROGBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address: 0x200
+
+// CHECK: Name: foo
+// CHECK-NEXT: Value: 0x200
+
.section .eh_frame
foo:
.long 0
More information about the llvm-commits
mailing list