[lld] r248856 - ELF2: Do not use host pointer size to calculate x86_64 relocation addresses.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 16:25:21 PDT 2015


Author: ruiu
Date: Tue Sep 29 18:25:21 2015
New Revision: 248856

URL: http://llvm.org/viewvc/llvm-project?rev=248856&view=rev
Log:
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.

Modified:
    lld/trunk/ELF/Target.cpp

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=248856&r1=248855&r2=248856&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Tue Sep 29 18:25:21 2015
@@ -107,8 +107,8 @@ void X86_64TargetInfo::writePltEntry(uin
   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);
 }




More information about the llvm-commits mailing list