summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2014-08-07 20:41:57 +0000
committerLang Hames <lhames@gmail.com>2014-08-07 20:41:57 +0000
commit4ea28e22942822426c894cc4c60b956075b44f7c (patch)
treec62b269480d40b1587a40f9561a18b72221fa2ef
parent56579b63248d7f8cd9e253adad94b9ed0cfb30e6 (diff)
downloadbcm5719-llvm-4ea28e22942822426c894cc4c60b956075b44f7c.tar.gz
bcm5719-llvm-4ea28e22942822426c894cc4c60b956075b44f7c.zip
[MCJIT] Replace a c-style cast with reinterpret_cast + static_cast.
C-style casts (and reinterpret_casts) result in implementation defined values when a pointer is cast to a larger integer type. On some platforms this was leading to bogus address computations in RuntimeDyldMachOAArch64. This should fix http://llvm.org/PR20501. llvm-svn: 215143
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
index ced85f3e55a..ffdb53a6b18 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
@@ -362,9 +362,9 @@ private:
assert(RE.Size == 2);
SectionEntry &Section = Sections[RE.SectionID];
StubMap::const_iterator i = Stubs.find(Value);
- uint8_t *Addr;
+ uintptr_t Addr;
if (i != Stubs.end())
- Addr = Section.Address + i->second;
+ Addr = reinterpret_cast<uintptr_t>(Section.Address) + i->second;
else {
// FIXME: There must be a better way to do this then to check and fix the
// alignment every time!!!
@@ -385,11 +385,11 @@ private:
else
addRelocationForSection(GOTRE, Value.SectionID);
Section.StubOffset = StubOffset + getMaxStubSize();
- Addr = (uint8_t *)StubAddress;
+ Addr = StubAddress;
}
RelocationEntry TargetRE(RE.SectionID, RE.Offset, RE.RelType, /*Addend=*/0,
RE.IsPCRel, RE.Size);
- resolveRelocation(TargetRE, (uint64_t)Addr);
+ resolveRelocation(TargetRE, static_cast<uint64_t>(Addr));
}
};
}
OpenPOWER on IntegriCloud