diff options
| author | Davide Italiano <davide@freebsd.org> | 2015-08-29 13:15:42 +0000 |
|---|---|---|
| committer | Davide Italiano <davide@freebsd.org> | 2015-08-29 13:15:42 +0000 |
| commit | 94f183a6966b59f90961c3f69c955a129926a99f (patch) | |
| tree | 93aeeb79a51def7cf75c7c7e4d73b356dc80dd54 | |
| parent | a184adffab7d3f24488f12eb4d31c4af880a9166 (diff) | |
| download | bcm5719-llvm-94f183a6966b59f90961c3f69c955a129926a99f.tar.gz bcm5719-llvm-94f183a6966b59f90961c3f69c955a129926a99f.zip | |
[ELFv2] Implement R_X86_64_32 relocation.
Differential Revision: http://reviews.llvm.org/D12436
llvm-svn: 246362
| -rw-r--r-- | lld/ELF/Writer.cpp | 6 | ||||
| -rw-r--r-- | lld/test/elf2/relocation.s | 14 |
2 files changed, 18 insertions, 2 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 4d1937b8fca..34c5f1ff69c 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -254,11 +254,15 @@ template <class ELFT> void OutputSection<ELFT>::writeTo(uint8_t *Buf) { uint32_t Type = RI.getType(EObj->isMips64EL()); uintX_t P = this->getVA() + C->getOutputSectionOff(); uintX_t SymVA = getSymVA<ELFT>(cast<DefinedRegular<ELFT>>(Body)); + uint8_t *Location = Base + Offset; switch (Type) { case llvm::ELF::R_X86_64_PC32: - support::endian::write32le(Base + Offset, + support::endian::write32le(Location, SymVA + (RI.r_addend - (P + Offset))); break; + case llvm::ELF::R_X86_64_32: + support::endian::write32le(Location, SymVA + RI.r_addend); + break; default: llvm::errs() << Twine("unrecognized reloc ") + Twine(Type) << '\n'; break; diff --git a/lld/test/elf2/relocation.s b/lld/test/elf2/relocation.s index cbf7c7858d5..054846ea403 100644 --- a/lld/test/elf2/relocation.s +++ b/lld/test/elf2/relocation.s @@ -1,6 +1,6 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t // RUN: lld -flavor gnu2 %t -o %t2 -// RUN: llvm-objdump -d %t2 | FileCheck %s +// RUN: llvm-objdump -t -d %t2 | FileCheck %s // REQUIRES: x86 @@ -14,4 +14,16 @@ _start: .global lulz lulz: +.global bar +.text +bar: + movl $bar, %edx // R_X86_64_32 + +// R_X86_64_32 +// CHECK: bar: +// CHECK: 1000: ba 00 10 00 00 movl $4096, %edx + // CHECK: e8 04 00 00 00 callq 4 + +// Also check that symbols match. +// CHECK: 0000000000001000 .text 00000000 bar |

