COFF: Fix locally-imported symbol's base relocations.

Base relocations are RVA and not VA, so we shouldn't add ImageBase.

llvm-svn: 241883
This commit is contained in:
Rui Ueyama 2015-07-10 04:30:54 +00:00
parent 0de292f5d0
commit c851ccc3bd
2 changed files with 13 additions and 2 deletions

View File

@ -263,7 +263,7 @@ void ImportThunkChunk::writeTo(uint8_t *Buf) {
void LocalImportChunk::getBaserels(std::vector<uint32_t> *Res,
Defined *ImageBase) {
Res->push_back(getRVA() + Config->ImageBase);
Res->push_back(getRVA());
}
size_t LocalImportChunk::getSize() const {

View File

@ -1,13 +1,24 @@
# RUN: yaml2obj < %s > %t.obj
# RUN: lld -flavor link2 /out:%t.exe /entry:main %t.obj
# RUN: llvm-objdump -s %t.exe | FileCheck %s
# RUN: llvm-readobj -coff-basereloc %t.exe | FileCheck -check-prefix=BASEREL %s
# CHECK: Contents of section .text:
# CHECK-NEXT: 1000 00200000
# CHECK: Contents of section .rdata:
# CHECK-NEXT: 2000 04100040 01000000
# BASEREL: BaseReloc [
# BASEREL-NEXT: Entry {
# BASEREL-NEXT: Type: DIR64
# BASEREL-NEXT: Address: 0x2000
# BASEREL-NEXT: }
# BASEREL-NEXT: Entry {
# BASEREL-NEXT: Type: ABSOLUTE
# BASEREL-NEXT: Address: 0x2000
# BASEREL-NEXT: }
# BASEREL-NEXT: ]
---
header:
Machine: IMAGE_FILE_MACHINE_AMD64