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 instr_encode_arch #6324

Merged
merged 3 commits into from
Sep 23, 2023
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
12 changes: 10 additions & 2 deletions core/ir/riscv64/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ instr_encode_arch(dcontext_t *dcontext, instr_t *instr, byte *copy_pc, byte *fin
{
ksco marked this conversation as resolved.
Show resolved Hide resolved
decode_info_t di;
uint enc;
int instr_length;

if (has_instr_opnds != NULL) {
*has_instr_opnds = false;
Expand Down Expand Up @@ -135,8 +136,15 @@ instr_encode_arch(dcontext_t *dcontext, instr_t *instr, byte *copy_pc, byte *fin
});
return NULL;
}
*(uint *)copy_pc = enc;
return copy_pc + 4;
instr_length = instr_length_arch(dcontext, instr);
if (instr_length == RISCV64_INSTR_COMPRESSED_SIZE) {
*(ushort *)copy_pc = (ushort)enc;
} else {
ASSERT(instr_length == RISCV64_INSTR_SIZE);
*(uint *)copy_pc = enc;
}

return copy_pc + instr_length;
}

byte *
Expand Down
Loading