mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-23 11:03:02 +08:00
fix: patch relocations byte-wise
there is no restriction for alignment of relocation offset Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
4ab91eab1e
commit
6e20cbc05f
@@ -402,17 +402,20 @@ void Linker::patchAddress(void *relocAddress, const uint64_t value, const Linker
|
||||
switch (relocation.type) {
|
||||
default:
|
||||
UNRECOVERABLE_IF(RelocationInfo::Type::address != relocation.type);
|
||||
*reinterpret_cast<uint64_t *>(relocAddress) = value;
|
||||
break;
|
||||
case RelocationInfo::Type::addressLow:
|
||||
*reinterpret_cast<uint32_t *>(relocAddress) = static_cast<uint32_t>(value & 0xffffffff);
|
||||
break;
|
||||
case RelocationInfo::Type::addressHigh:
|
||||
*reinterpret_cast<uint32_t *>(relocAddress) = static_cast<uint32_t>((value >> 32) & 0xffffffff);
|
||||
break;
|
||||
case RelocationInfo::Type::address16:
|
||||
*reinterpret_cast<uint16_t *>(relocAddress) = static_cast<uint16_t>(value);
|
||||
memcpy_s(relocAddress, sizeof(uint64_t), &value, sizeof(uint64_t));
|
||||
break;
|
||||
case RelocationInfo::Type::addressLow: {
|
||||
uint32_t valueToPatch = static_cast<uint32_t>(value & 0xffffffff);
|
||||
memcpy_s(relocAddress, sizeof(uint32_t), &valueToPatch, sizeof(uint32_t));
|
||||
} break;
|
||||
case RelocationInfo::Type::addressHigh: {
|
||||
uint32_t valueToPatch = static_cast<uint32_t>((value >> 32) & 0xffffffff);
|
||||
memcpy_s(relocAddress, sizeof(uint32_t), &valueToPatch, sizeof(uint32_t));
|
||||
} break;
|
||||
case RelocationInfo::Type::address16: {
|
||||
uint16_t valueToPatch = static_cast<uint16_t>(value & 0xffff);
|
||||
memcpy_s(relocAddress, sizeof(uint16_t), &valueToPatch, sizeof(uint16_t));
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user