uint8_t *DataAddr = S.Address;
uint64_t LoadAddr = S.LoadAddress;
- unsigned StartPadding = LoadAddr & 7;
+ unsigned StartPadding = LoadAddr & (ColsPerRow - 1);
unsigned BytesRemaining = S.Size;
if (StartPadding) {
- dbgs() << "\n" << format("0x%08x", LoadAddr & ~(ColsPerRow - 1)) << ":";
+ dbgs() << "\n" << format("0x%016" PRIx64, LoadAddr & ~(ColsPerRow - 1)) << ":";
while (StartPadding--)
dbgs() << " ";
}
uint64_t RuntimeDyldImpl::readBytesUnaligned(uint8_t *Src,
unsigned Size) const {
uint64_t Result = 0;
- uint8_t *Dst = reinterpret_cast<uint8_t*>(&Result);
-
- if (IsTargetLittleEndian == sys::IsLittleEndianHost) {
- if (!sys::IsLittleEndianHost)
- Dst += sizeof(Result) - Size;
- memcpy(Dst, Src, Size);
- } else {
- Dst += Size - 1;
- for (unsigned i = 0; i < Size; ++i)
- *Dst-- = *Src++;
- }
+ if (IsTargetLittleEndian) {
+ Src += Size - 1;
+ while (Size--)
+ Result = (Result << 8) | *Src--;
+ } else
+ while (Size--)
+ Result = (Result << 8) | *Src++;
return Result;
}
void RuntimeDyldImpl::writeBytesUnaligned(uint64_t Value, uint8_t *Dst,
unsigned Size) const {
- uint8_t *Src = reinterpret_cast<uint8_t*>(&Value);
- if (IsTargetLittleEndian == sys::IsLittleEndianHost) {
- if (!sys::IsLittleEndianHost)
- Src += sizeof(Value) - Size;
- memcpy(Dst, Src, Size);
+ if (IsTargetLittleEndian) {
+ while (Size--) {
+ *Dst++ = Value & 0xFF;
+ Value >>= 8;
+ }
} else {
- Src += Size - 1;
- for (unsigned i = 0; i < Size; ++i)
- *Dst++ = *Src--;
+ Dst += Size - 1;
+ while (Size--) {
+ *Dst-- = Value & 0xFF;
+ Value >>= 8;
+ }
}
}
// "big enough" type.
DEBUG(dbgs() << "Reassigning address for section "
<< SectionID << " (" << Sections[SectionID].Name << "): "
- << format("0x%016x", Sections[SectionID].LoadAddress) << " -> "
- << format("0x%016x", Addr) << "\n");
+ << format("0x%016" PRIx64, Sections[SectionID].LoadAddress) << " -> "
+ << format("0x%016" PRIx64, Addr) << "\n");
Sections[SectionID].LoadAddress = Addr;
}