[lld] r266607 - Remove isGotRelative.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 18 05:31:39 PDT 2016
Author: rafael
Date: Mon Apr 18 07:31:37 2016
New Revision: 266607
URL: http://llvm.org/viewvc/llvm-project?rev=266607&view=rev
Log:
Remove isGotRelative.
It is now redundant with the expression. While at it, handle both "X -
Got" and "Got - PC".
Added:
lld/trunk/test/ELF/i386-gotpc.s
Modified:
lld/trunk/ELF/Target.cpp
lld/trunk/ELF/Target.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=266607&r1=266606&r2=266607&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Mon Apr 18 07:31:37 2016
@@ -93,7 +93,6 @@ public:
void relaxTlsIeToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
void relaxTlsLdToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const override;
- bool isGotRelative(uint32_t Type) const override;
bool refersToGotEntry(uint32_t Type) const override;
};
@@ -271,7 +270,6 @@ bool TargetInfo::needsCopyRel(uint32_t T
return mayNeedCopy<ELFT>(S) && needsCopyRelImpl(Type);
}
-bool TargetInfo::isGotRelative(uint32_t Type) const { return false; }
bool TargetInfo::isHintRel(uint32_t Type) const { return false; }
bool TargetInfo::isRelRelative(uint32_t Type) const { return true; }
@@ -487,13 +485,6 @@ bool X86TargetInfo::needsPltImpl(uint32_
return Type == R_386_PLT32;
}
-bool X86TargetInfo::isGotRelative(uint32_t Type) const {
- // This relocation does not require got entry,
- // but it is relative to got and needs it to be created.
- // Here we request for that.
- return Type == R_386_GOTOFF;
-}
-
bool X86TargetInfo::refersToGotEntry(uint32_t Type) const {
return Type == R_386_GOT32;
}
Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=266607&r1=266606&r2=266607&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Mon Apr 18 07:31:37 2016
@@ -68,7 +68,6 @@ public:
virtual RelExpr getRelExpr(uint32_t Type, const SymbolBody &S) const = 0;
virtual void relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const = 0;
- virtual bool isGotRelative(uint32_t Type) const;
bool canRelaxTls(uint32_t Type, const SymbolBody *S) const;
template <class ELFT>
bool needsCopyRel(uint32_t Type, const SymbolBody &S) const;
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=266607&r1=266606&r2=266607&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Apr 18 07:31:37 2016
@@ -467,8 +467,6 @@ void Writer<ELFT>::scanRelocs(InputSecti
if (Offset == (uintX_t)-1)
continue;
- if (Target->isGotRelative(Type))
- HasGotOffRel = true;
// Set "used" bit for --as-needed.
if (OrigBody.isUndefined() && !OrigBody.isWeak())
@@ -476,6 +474,12 @@ void Writer<ELFT>::scanRelocs(InputSecti
S->File->IsUsed = true;
RelExpr Expr = Target->getRelExpr(Type, Body);
+
+ // This relocation does not require got entry, but it is relative to got and
+ // needs it to be created. Here we request for that.
+ if (Expr == R_GOTONLY_PC || Expr == R_GOTREL)
+ HasGotOffRel = true;
+
uintX_t Addend = getAddend<ELFT>(RI);
const uint8_t *BufLoc = Buf + RI.r_offset;
if (!RelTy::IsRela)
Added: lld/trunk/test/ELF/i386-gotpc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/i386-gotpc.s?rev=266607&view=auto
==============================================================================
--- lld/trunk/test/ELF/i386-gotpc.s (added)
+++ lld/trunk/test/ELF/i386-gotpc.s Mon Apr 18 07:31:37 2016
@@ -0,0 +1,20 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
+// RUN: ld.lld %t.o -o %t.so -shared
+// RUN: llvm-readobj -s %t.so | FileCheck %s
+// RUN: llvm-objdump -d %t.so | FileCheck --check-prefix=DISASM %s
+
+movl $_GLOBAL_OFFSET_TABLE_, %eax
+
+// CHECK: Name: .got (38)
+// CHECK-NEXT: Type: SHT_PROGBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT: SHF_ALLOC
+// CHECK-NEXT: SHF_WRITE
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address: 0x2030
+
+// DISASM: Disassembly of section .text:
+// DISASM-NEXT: .text:
+// DISASM-NEXT: 1000: {{.*}} movl $4144, %eax
+// 0x2030 - 0x1000 = 4144
More information about the llvm-commits
mailing list