Skip to content

Commit

Permalink
Merge pull request ocaml#13577 from tmcgilchrist/riscv_disable_cfi
Browse files Browse the repository at this point in the history
Honour --disable-cfi option for riscv runtime
  • Loading branch information
gasche authored Oct 29, 2024
2 parents d21b863 + d4caf8b commit 9caaced
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion runtime/riscv.S
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,13 @@ name:
sd sp, Cstack_sp(TMP2)
/* Switch to C stack */
mv sp, TMP2
#ifdef ASM_CFI_SUPPORTED
CFI_REMEMBER_STATE
/* sp points to the c_stack_link. */
.cfi_escape DW_CFA_def_cfa_expression, 5, \
DW_OP_breg + DW_REG_sp, Cstack_sp_offset, DW_OP_deref, \
DW_OP_plus_uconst, 16 /* fp + retaddr */
#endif
.endm

/* Switch from C to OCaml stack. */
Expand Down Expand Up @@ -683,6 +685,7 @@ L(jump_to_caml):
mv TRAP_PTR, t2
/* Switch stacks and call the OCaml code */
mv sp, t2
#ifdef ASM_CFI_SUPPORTED
CFI_REMEMBER_STATE
.cfi_escape DW_CFA_def_cfa_expression, 3 + 2 + 2, \
/* sp points to the exn handler on the OCaml stack */ \
Expand All @@ -693,6 +696,7 @@ L(jump_to_caml):
/* 16 fp + ret addr */ \
/* need to split to get under 127 limit */ \
DW_OP_plus_uconst, 120, DW_OP_plus_uconst, 120
#endif
/* Call the OCaml code */
jalr TMP2
L(caml_retaddr):
Expand Down Expand Up @@ -1177,6 +1181,7 @@ FUNCTION(caml_runstack)
mv TRAP_PTR, t3
/* Switch to the new stack */
mv sp, t3
#ifdef ASM_CFI_SUPPORTED
CFI_REMEMBER_STATE
.cfi_escape DW_CFA_def_cfa_expression, 3+3+2, \
DW_OP_breg + DW_REG_sp, \
Expand All @@ -1186,7 +1191,7 @@ FUNCTION(caml_runstack)
+ Handler_parent_offset, DW_OP_deref, \
DW_OP_plus_uconst, Stack_sp_offset, DW_OP_deref, \
DW_OP_plus_uconst, 16 /* fp + ret addr */

#endif
/* Call the function on the new stack */
mv a0, a2
jalr a3
Expand Down

0 comments on commit 9caaced

Please sign in to comment.