Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i#3544 RV64: Fix patch_stub for unaligned stub_pc #6711

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/arch/riscv64/emit_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ void
patch_stub(fragment_t *f, cache_pc stub_pc, cache_pc target_pc, cache_pc target_prefix_pc,
ksco marked this conversation as resolved.
Show resolved Hide resolved
bool hot_patch)
{
/* If stub_pc is not aligned to 4 bytes, the first instruction will be c.nop, see
* insert_exit_stub_other_flags(). */
stub_pc = ALIGNED(stub_pc, 4) ? stub_pc : stub_pc + 2;
ptr_int_t off = (ptr_int_t)target_pc - (ptr_int_t)stub_pc;
if (off < 0x100000 && off > (ptr_int_t)0xFFFFFFFFFFF00000L) {
/* target_pc is a near fragment. We can get there with a J (OP_jal, 21-bit signed
Expand Down
Loading