Skip to content

Commit 543dedd

Browse files
committed
Die noisily on a load/store fail exception.
This should help point out any remaining offenders trying to write to const data.
1 parent dce0d2c commit 543dedd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

app/user/user_exceptions.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#define L16UI_MATCH 0x001002u
3939
#define L16SI_MATCH 0x009002u
4040

41+
#define LOAD_STORE_COMPLAIN_LOUDLY_ON_ERROR
42+
#include "c_stdio.h"
4143

4244
void load_non_32_wide_handler (struct exception_frame *ef, uint32_t cause)
4345
{
@@ -70,6 +72,11 @@ void load_non_32_wide_handler (struct exception_frame *ef, uint32_t cause)
7072
else
7173
{
7274
die:
75+
#ifdef LOAD_STORE_COMPLAIN_LOUDLY_ON_ERROR
76+
while (1)
77+
c_printf("\nerror: instruction %x at %x failed on memory access to %x\n",
78+
insn, epc1, excvaddr);
79+
#endif
7380
/* Turns out we couldn't fix this, trigger a system break instead
7481
* and hang if the break doesn't get handled. This is effectively
7582
* what would happen if the default handler was installed. */

0 commit comments

Comments
 (0)