mirror of
https://github.com/yuzu-mirror/oaknut.git
synced 2026-01-26 09:14:13 +01:00
oaknut: Fix crossing sign boundary in PageOffset
This commit is contained in:
parent
206468d721
commit
a66b32d263
|
|
@ -78,7 +78,7 @@ struct PageOffset {
|
|||
|
||||
static std::uint32_t encode(std::uintptr_t current_addr, std::uintptr_t target)
|
||||
{
|
||||
std::uint64_t diff = (static_cast<std::uint64_t>(target) >> shift_amount) - (static_cast<std::uint64_t>(current_addr) >> shift_amount);
|
||||
std::uint64_t diff = static_cast<std::uint64_t>((static_cast<std::int64_t>(target - current_addr) >> shift_amount));
|
||||
if (detail::sign_extend<bitsize>(diff) != diff)
|
||||
throw OaknutException{ExceptionType::OffsetOutOfRange};
|
||||
diff &= detail::mask_from_size(bitsize);
|
||||
|
|
|
|||
|
|
@ -138,6 +138,11 @@ TEST_CASE("ADR")
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE("PageOffset")
|
||||
{
|
||||
REQUIRE(PageOffset<21, 12>::encode(0x0000000088e74000, 0xffffffffd167dece) == 0xd2202);
|
||||
}
|
||||
|
||||
TEST_CASE("ADRP")
|
||||
{
|
||||
CodeBlock mem{4096};
|
||||
|
|
|
|||
Loading…
Reference in a new issue