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: Mangle pc-relative addressing destining to tp #7068

Merged
merged 7 commits into from
Nov 11, 2024
Merged
Changes from 1 commit
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
15 changes: 11 additions & 4 deletions core/arch/riscv64/mangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,22 +619,29 @@ mangle_rel_addr(dcontext_t *dcontext, instrlist_t *ilist, instr_t *instr,
instr_get_rel_data_or_instr_target(instr, &tgt);
ASSERT(opnd_is_reg(dst));
ASSERT(opnd_is_rel_addr(instr_get_src(instr, 0)));
bool uses_reg_stolen = instr_uses_reg(instr, dr_reg_stolen),
uses_reg_tp = instr_uses_reg(instr, DR_REG_TP);

ASSERT_NOT_IMPLEMENTED(!instr_uses_reg(instr, DR_REG_TP));

if (instr_uses_reg(instr, dr_reg_stolen)) {
if (uses_reg_stolen || uses_reg_tp) {
dst = opnd_create_reg(DR_REG_A0);
PRE(ilist, next_instr,
ziyao233 marked this conversation as resolved.
Show resolved Hide resolved
instr_create_save_to_tls(dcontext, DR_REG_A0, TLS_REG0_SLOT));
}

insert_mov_immed_ptrsz(dcontext, (ptr_int_t)tgt, dst, ilist, next_instr, NULL, NULL);

if (instr_uses_reg(instr, dr_reg_stolen)) {
if (uses_reg_stolen) {
PRE(ilist, next_instr,
instr_create_save_to_tls(dcontext, DR_REG_A0, TLS_REG_STOLEN_SLOT));
PRE(ilist, next_instr,
instr_create_restore_from_tls(dcontext, DR_REG_A0, TLS_REG0_SLOT));
} else if (uses_reg_tp) {
ziyao233 marked this conversation as resolved.
Show resolved Hide resolved
PRE(ilist, next_instr,
instr_create_save_to_tls(
dcontext, DR_REG_A0,
os_tls_offset(os_get_app_tls_base_offset(TLS_REG_LIB))));
ziyao233 marked this conversation as resolved.
Show resolved Hide resolved
PRE(ilist, next_instr,
instr_create_restore_from_tls(dcontext, DR_REG_A0, TLS_REG0_SLOT));
ksco marked this conversation as resolved.
Show resolved Hide resolved
}

instrlist_remove(ilist, instr);
Expand Down
Loading