COFF: Fix import thunks and name mangling for x86.

With this patch, LLD is now able to correctly link a "hello world"
program written in assembly for 32-bit x86.

llvm-svn: 241771
This commit is contained in:
Rui Ueyama
2015-07-09 01:25:49 +00:00
parent 6335057824
commit 7c3e23fffd
7 changed files with 141 additions and 25 deletions

View File

@@ -245,7 +245,9 @@ ImportThunkChunk::ImportThunkChunk(Defined *S) : ImpSymbol(S) {
void ImportThunkChunk::writeTo(uint8_t *Buf) {
memcpy(Buf + FileOff, ImportThunkData, sizeof(ImportThunkData));
// The first two bytes is a JMP instruction. Fill its operand.
uint32_t Operand = ImpSymbol->getRVA() - RVA - getSize();
uint32_t Operand = Config->is64()
? ImpSymbol->getRVA() - RVA - getSize()
: ImpSymbol->getRVA() + Config->ImageBase;
write32le(Buf + FileOff + 2, Operand);
}