[lld] r216512 - [PECOFF] Fix AMD64_ADDR64 relocation.
Rui Ueyama
ruiu at google.com
Tue Aug 26 18:10:01 PDT 2014
Author: ruiu
Date: Tue Aug 26 20:10:01 2014
New Revision: 216512
URL: http://llvm.org/viewvc/llvm-project?rev=216512&view=rev
Log:
[PECOFF] Fix AMD64_ADDR64 relocation.
IMAGE_REL_AMD64_ADDR64 relocation should set 64-bit *VA* (virtual
address) instead of *RVA* (relative virtual address), so we have
to add the iamge base to the target's RVA.
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
lld/trunk/test/pecoff/Inputs/reloc64-1.obj.yaml
lld/trunk/test/pecoff/reloc64.test
Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=216512&r1=216511&r2=216512&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Tue Aug 26 20:10:01 2014
@@ -572,7 +572,7 @@ void AtomChunk::applyRelocations64(uint8
switch (ref->kindValue()) {
case llvm::COFF::IMAGE_REL_AMD64_ADDR64:
- *relocSite64 = targetAddr;
+ *relocSite64 = targetAddr + imageBase;
break;
case llvm::COFF::IMAGE_REL_AMD64_ADDR32:
*relocSite32 = targetAddr + imageBase;
Modified: lld/trunk/test/pecoff/Inputs/reloc64-1.obj.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/reloc64-1.obj.yaml?rev=216512&r1=216511&r2=216512&view=diff
==============================================================================
--- lld/trunk/test/pecoff/Inputs/reloc64-1.obj.yaml (original)
+++ lld/trunk/test/pecoff/Inputs/reloc64-1.obj.yaml Tue Aug 26 20:10:01 2014
@@ -6,11 +6,14 @@ sections:
- Name: .text
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
Alignment: 16
- SectionData: E800000000C3
+ SectionData: E80000000048b80000000000000000
Relocations:
- VirtualAddress: 1
SymbolName: fn2
Type: IMAGE_REL_AMD64_REL32
+ - VirtualAddress: 7
+ SymbolName: fn2
+ Type: IMAGE_REL_AMD64_ADDR64
- Name: .data
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
Alignment: 16
Modified: lld/trunk/test/pecoff/reloc64.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/reloc64.test?rev=216512&r1=216511&r2=216512&view=diff
==============================================================================
--- lld/trunk/test/pecoff/reloc64.test (original)
+++ lld/trunk/test/pecoff/reloc64.test Tue Aug 26 20:10:01 2014
@@ -8,3 +8,4 @@
CHECK: Disassembly of section .text:
CHECK-NEXT: .text:
CHECK-NEXT: 1000: e8 0b 00 00 00 callq 11
+CHECK-NEXT: 1005: 48 b8 10 10 00 40 01 00 00 00 movabsq $5368713232, %rax
More information about the llvm-commits
mailing list