[lld] r221007 - [mach-o] explicitly cast little_n uses to ints to silence MSVC
Tim Northover
tnorthover at apple.com
Fri Oct 31 15:12:21 PDT 2014
Author: tnorthover
Date: Fri Oct 31 17:12:20 2014
New Revision: 221007
URL: http://llvm.org/viewvc/llvm-project?rev=221007&view=rev
Log:
[mach-o] explicitly cast little_n uses to ints to silence MSVC
Hopefully this'll fix the build failure in the bot.
Modified:
lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp?rev=221007&r1=221006&r2=221007&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp Fri Oct 31 17:12:20 2014
@@ -458,7 +458,7 @@ std::error_code ArchHandler_arm64::getPa
*kind = delta64;
if (auto ec = atomFromSymbolIndex(reloc2.symbol, target))
return ec;
- *addend = *(little64_t *)fixupContent + offsetInAtom;
+ *addend = (int64_t)*(little64_t *)fixupContent + offsetInAtom;
return std::error_code();
case ((ARM64_RELOC_SUBTRACTOR | rExtern | rLength4) << 16 |
ARM64_RELOC_UNSIGNED | rExtern | rLength4):
@@ -466,7 +466,7 @@ std::error_code ArchHandler_arm64::getPa
*kind = delta32;
if (auto ec = atomFromSymbolIndex(reloc2.symbol, target))
return ec;
- *addend = *(little32_t *)fixupContent + offsetInAtom;
+ *addend = (int32_t)*(little32_t *)fixupContent + offsetInAtom;
return std::error_code();
default:
return make_dynamic_error_code(Twine("unsupported arm64 relocation pair"));
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp?rev=221007&r1=221006&r2=221007&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp Fri Oct 31 17:12:20 2014
@@ -262,18 +262,18 @@ ArchHandler_x86::getReferenceInfo(const
*kind = branch32;
if (E ec = atomFromSymbolIndex(reloc.symbol, target))
return ec;
- *addend = fixupAddress + 4 + *(little32_t *)fixupContent;
+ *addend = fixupAddress + 4 + (int32_t)*(little32_t *)fixupContent;
break;
case GENERIC_RELOC_VANILLA | rPcRel | rLength4:
// ex: call _foo (and _foo defined)
*kind = branch32;
- targetAddress = fixupAddress + 4 + *(little32_t *)fixupContent;
+ targetAddress = fixupAddress + 4 + (int32_t)*(little32_t *)fixupContent;
return atomFromAddress(reloc.symbol, targetAddress, target, addend);
break;
case GENERIC_RELOC_VANILLA | rScattered | rPcRel | rLength4:
// ex: call _foo+n (and _foo defined)
*kind = branch32;
- targetAddress = fixupAddress + 4 + *(little32_t *)fixupContent;
+ targetAddress = fixupAddress + 4 + (int32_t)*(little32_t *)fixupContent;
if (E ec = atomFromAddress(0, reloc.value, target, addend))
return ec;
*addend = targetAddress - reloc.value;
@@ -283,18 +283,18 @@ ArchHandler_x86::getReferenceInfo(const
*kind = branch16;
if (E ec = atomFromSymbolIndex(reloc.symbol, target))
return ec;
- *addend = fixupAddress + 2 + *(little16_t *)fixupContent;
+ *addend = fixupAddress + 2 + (int16_t)*(little16_t *)fixupContent;
break;
case GENERIC_RELOC_VANILLA | rPcRel | rLength2:
// ex: callw _foo (and _foo defined)
*kind = branch16;
- targetAddress = fixupAddress + 2 + *(little16_t *)fixupContent;
+ targetAddress = fixupAddress + 2 + (int16_t)*(little16_t *)fixupContent;
return atomFromAddress(reloc.symbol, targetAddress, target, addend);
break;
case GENERIC_RELOC_VANILLA | rScattered | rPcRel | rLength2:
// ex: callw _foo+n (and _foo defined)
*kind = branch16;
- targetAddress = fixupAddress + 2 + *(little16_t *)fixupContent;
+ targetAddress = fixupAddress + 2 + (int16_t)*(little16_t *)fixupContent;
if (E ec = atomFromAddress(0, reloc.value, target, addend))
return ec;
*addend = targetAddress - reloc.value;
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp?rev=221007&r1=221006&r2=221007&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp Fri Oct 31 17:12:20 2014
@@ -345,17 +345,17 @@ ArchHandler_x86_64::getReferenceInfo(con
case ripRel32Minus1:
if (E ec = atomFromSymbolIndex(reloc.symbol, target))
return ec;
- *addend = *(little32_t *)fixupContent + 1;
+ *addend = (int32_t)*(little32_t *)fixupContent + 1;
return std::error_code();
case ripRel32Minus2:
if (E ec = atomFromSymbolIndex(reloc.symbol, target))
return ec;
- *addend = *(little32_t *)fixupContent + 2;
+ *addend = (int32_t)*(little32_t *)fixupContent + 2;
return std::error_code();
case ripRel32Minus4:
if (E ec = atomFromSymbolIndex(reloc.symbol, target))
return ec;
- *addend = *(little32_t *)fixupContent + 4;
+ *addend = (int32_t)*(little32_t *)fixupContent + 4;
return std::error_code();
case ripRel32Anon:
targetAddress = fixupAddress + 4 + *(little32_t *)fixupContent;
@@ -427,18 +427,18 @@ ArchHandler_x86_64::getPairReferenceInfo
case delta64:
if (E ec = atomFromSymbolIndex(reloc2.symbol, target))
return ec;
- *addend = *(little64_t *)fixupContent + offsetInAtom;
+ *addend = (int64_t)*(little64_t *)fixupContent + offsetInAtom;
return std::error_code();
case delta32:
if (E ec = atomFromSymbolIndex(reloc2.symbol, target))
return ec;
- *addend = *(little32_t *)fixupContent + offsetInAtom;
+ *addend = (int32_t)*(little32_t *)fixupContent + offsetInAtom;
return std::error_code();
case delta64Anon:
- targetAddress = offsetInAtom + *(little64_t *)fixupContent;
+ targetAddress = offsetInAtom + (int64_t)*(little64_t *)fixupContent;
return atomFromAddress(reloc2.symbol, targetAddress, target, addend);
case delta32Anon:
- targetAddress = offsetInAtom + *(little32_t *)fixupContent;
+ targetAddress = offsetInAtom + (int32_t)*(little32_t *)fixupContent;
return atomFromAddress(reloc2.symbol, targetAddress, target, addend);
default:
llvm_unreachable("bad reloc pair kind");
Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h?rev=221007&r1=221006&r2=221007&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h Fri Oct 31 17:12:20 2014
@@ -40,21 +40,27 @@ template<typename T>
static inline uint16_t read16(const T *loc, bool isBig) {
assert((uint64_t)loc % llvm::alignOf<T>() == 0 &&
"invalid pointer alignment");
- return isBig ? *(ubig16_t *)loc : *(ulittle16_t *)loc;
+ if (isBig)
+ return *(ubig16_t *)loc;
+ return *(ulittle16_t *)loc;
}
template<typename T>
static inline uint32_t read32(const T *loc, bool isBig) {
assert((uint64_t)loc % llvm::alignOf<T>() == 0 &&
"invalid pointer alignment");
- return isBig ? *(ubig32_t *)loc : *(ulittle32_t *)loc;
+ if (isBig)
+ return *(ubig32_t *)loc;
+ return *(ulittle32_t *)loc;
}
template<typename T>
static inline uint64_t read64(const T *loc, bool isBig) {
assert((uint64_t)loc % llvm::alignOf<T>() == 0 &&
"invalid pointer alignment");
- return isBig ? *(ubig64_t *)loc : *(ulittle64_t *)loc;
+ if (isBig)
+ return *(ubig64_t *)loc;
+ return *(ulittle64_t *)loc;
}
inline void write16(uint8_t *loc, uint16_t value, bool isBig) {
More information about the llvm-commits
mailing list