forked from OSchip/llvm-project
[mach-o] explicitly cast little_n uses to ints to silence MSVC
Hopefully this'll fix the build failure in the bot. llvm-svn: 221007
This commit is contained in:
parent
80944df6f4
commit
cadb77a43e
|
|
@ -458,7 +458,7 @@ std::error_code ArchHandler_arm64::getPairReferenceInfo(
|
|||
*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::getPairReferenceInfo(
|
|||
*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"));
|
||||
|
|
|
|||
|
|
@ -262,18 +262,18 @@ ArchHandler_x86::getReferenceInfo(const Relocation &reloc,
|
|||
*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 Relocation &reloc,
|
|||
*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;
|
||||
|
|
|
|||
|
|
@ -345,17 +345,17 @@ ArchHandler_x86_64::getReferenceInfo(const Relocation &reloc,
|
|||
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(const normalized::Relocation &reloc1,
|
|||
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");
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue