Completely remove UVM32_STACK_PROTECTION unless enabled (requires manually changing crt0.S), as this saves 16 bytes on every .bin

This commit is contained in:
Toby Jaffey 2025-12-14 00:09:32 +00:00
parent c1399fbe86
commit 173d5056a5
17 changed files with 6 additions and 5 deletions

View file

@ -9,9 +9,10 @@
.align 4
_start:
la a0, _estack
li a7, uvm32_syscall_stackprotect
ecall
# Uncomment below to enable stack protection, requires -DUVM32_STACK_PROTECTION
# la a0, _estack
# li a7, uvm32_syscall_stackprotect
# ecall
# sp is already setup by vm
sw ra,12(sp)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -273,8 +273,8 @@ uint32_t uvm32_run(uvm32_state_t *vmst, uvm32_evt_t *evt, uint32_t instr_meter)
case UVM32_SYSCALL_HALT:
setStatus(vmst, UVM32_STATUS_ENDED);
break;
case UVM32_SYSCALL_STACKPROTECT: {
#ifdef UVM32_STACK_PROTECTION
case UVM32_SYSCALL_STACKPROTECT: {
// don't allow errant code to change it once set
if (vmst->_stack_canary == (uint8_t *)NULL) {
uint32_t param0 = vmst->_core.regs[10]; // a0
@ -295,8 +295,8 @@ uint32_t uvm32_run(uvm32_state_t *vmst, uvm32_evt_t *evt, uint32_t instr_meter)
*vmst->_stack_canary = STACK_CANARY_VALUE;
}
}
#endif
} break;
#endif
default:
// user defined syscalls
vmst->_ioevt.typ = UVM32_EVT_SYSCALL;