From f4c1cd4006626ebccdd2a7096bbe2b26bb91097f Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 18 Apr 2016 12:58:59 +0000 Subject: [PATCH] Fix handling of R_X86_64_GOT32. It computes the offset to the end of .got. llvm-svn: 266610 --- lld/ELF/Target.cpp | 3 ++- lld/test/ELF/relocation.s | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 49d07c6..5d1332e 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -649,7 +649,7 @@ RelExpr X86_64TargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const { case R_X86_64_PC32: return R_PC; case R_X86_64_GOT32: - return R_GOT; + return R_GOT_FROM_END; case R_X86_64_GOTPCREL: case R_X86_64_GOTTPOFF: return R_GOT_PC; @@ -869,6 +869,7 @@ void X86_64TargetInfo::relocateOne(uint8_t *Loc, uint32_t Type, break; case R_X86_64_32S: case R_X86_64_TPOFF32: + case R_X86_64_GOT32: checkInt<32>(Val, Type); write32le(Loc, Val); break; diff --git a/lld/test/ELF/relocation.s b/lld/test/ELF/relocation.s index aa58040..1183268 100644 --- a/lld/test/ELF/relocation.s +++ b/lld/test/ELF/relocation.s @@ -124,3 +124,11 @@ R_X86_64_GOTPCREL: // 7952 = 0x101f0000 in little endian // CHECK: Contents of section .R_X86_64_GOTPCREL // CHECK-NEXT: 101d0 201f0000 + +.section .R_X86_64_GOT32,"a",@progbits +.global R_X86_64_GOT32 +R_X86_64_GOT32: + .long zed@got + +// CHECK: Contents of section .R_X86_64_GOT32: +// CHECK-NEXT: f8ffffff -- 2.7.4