Arm64Emitter: Get rid of pointer casts in PoisonMemory
The previous code invokes undefined behavior.
This commit is contained in:
parent
6a17d87b07
commit
a7ec2d3831
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include "Common/ArmCommon.h"
|
#include "Common/ArmCommon.h"
|
||||||
|
@ -1137,14 +1138,16 @@ class ARM64CodeBlock : public CodeBlock<ARM64XEmitter>
|
||||||
private:
|
private:
|
||||||
void PoisonMemory() override
|
void PoisonMemory() override
|
||||||
{
|
{
|
||||||
u32* ptr = (u32*)region;
|
|
||||||
u32* maxptr = (u32*)(region + region_size);
|
|
||||||
// If our memory isn't a multiple of u32 then this won't write the last remaining bytes with
|
// If our memory isn't a multiple of u32 then this won't write the last remaining bytes with
|
||||||
// anything
|
// anything
|
||||||
// Less than optimal, but there would be nothing we could do but throw a runtime warning anyway.
|
// Less than optimal, but there would be nothing we could do but throw a runtime warning anyway.
|
||||||
// AArch64: 0xD4200000 = BRK 0
|
// AArch64: 0xD4200000 = BRK 0
|
||||||
while (ptr < maxptr)
|
constexpr u32 brk_0 = 0xD4200000;
|
||||||
*ptr++ = 0xD4200000;
|
|
||||||
|
for (size_t i = 0; i < region_size; i += sizeof(u32))
|
||||||
|
{
|
||||||
|
std::memcpy(region + i, &brk_0, sizeof(u32));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue