Implement Replace::Replace properly for aarch64#110
Implement Replace::Replace properly for aarch64#110mikedld wants to merge 1 commit intodascandy:masterfrom
Replace::Replace properly for aarch64#110Conversation
Add a separate implementation for aarch64 which boils down to
ldr x17, =0x1122334455667788
br x17
The `x17` register is used as it's allowed to be modified during
function call and doesn't require saving. Old approach under `SOME_ARM`
ifdef that doesn't require changing any registers isn't possible since
the `pc` register is no longer directly accessible.
Tested with qemu-aarch64 user mode emulation.
|
i know this is years old but i was looking into hippomocks on arm64 myself recently and thought this might be useful to someone: not sure what was going on in qemu, but i tried this patch on both an apple m2 and a raspberry pi 4, and i found that while it does make it work in some cases, it's very brittle, to the point where hippomock's own tests don't pass as written. that's because this solution requires the mocked function to consist of at least four instructions -- two to replace by the i experimented with using unfortunately i have very little knowledge of assembly or memory layouts myself so this is as far as i got. i just can't figure out how to work around that two-instruction limitation. |
|
Not sure i understand the change but i can help testing it, i think gh can run some tests using qemu too Unsure it will fix other plaforms as reported at |
|
@fzodana, mocking non-virtual functions is brittle regardless of the platform / architecture (approach taken in this PR isn't specific to aarch64) so I consider this a known limitation. There's a reason why other mocking frameworks don't even try. That said, I'm not an ARM expert so if you know of a better way — feel free to open a separate PR. |
Add a separate implementation for aarch64 which boils down to
The
x17register is used as it's allowed to be modified during function call and doesn't require saving. Old approach underSOME_ARMifdef that doesn't require changing any registers isn't possible since thepcregister is no longer directly accessible.Tested with qemu-aarch64 user mode emulation. I've also only tested it with
cpp11branch, but opening the PR againstmaster; do tell if additional PR againstcpp11will be required or whether you'll merge it there yourself.Potentially fixes #73, #57. CC @rzr for review.