ELF2: Do not use host pointer size to calculate x86_64 relocation addresses.

Previous code had a potential portability issue because intptr_t is
not guaranteed to be 64 bit.

llvm-svn: 248856
This commit is contained in:
Rui Ueyama 2015-09-29 23:25:21 +00:00
parent 9a0db7cbef
commit e3fbc89c44
1 changed files with 2 additions and 2 deletions

View File

@ -107,8 +107,8 @@ void X86_64TargetInfo::writePltEntry(uint8_t *Buf, uint64_t GotEntryAddr,
const uint8_t Inst[] = {0xff, 0x25, 0, 0, 0, 0, 0x90, 0x90};
memcpy(Buf, Inst, sizeof(Inst));
uintptr_t NextPC = PltEntryAddr + 6;
intptr_t Delta = GotEntryAddr - NextPC;
uint64_t NextPC = PltEntryAddr + 6;
int64_t Delta = GotEntryAddr - NextPC;
assert(isInt<32>(Delta));
write32le(Buf + 2, Delta);
}