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 .align 4
_start: _start:
la a0, _estack # Uncomment below to enable stack protection, requires -DUVM32_STACK_PROTECTION
li a7, uvm32_syscall_stackprotect # la a0, _estack
ecall # li a7, uvm32_syscall_stackprotect
# ecall
# sp is already setup by vm # sp is already setup by vm
sw ra,12(sp) 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: case UVM32_SYSCALL_HALT:
setStatus(vmst, UVM32_STATUS_ENDED); setStatus(vmst, UVM32_STATUS_ENDED);
break; break;
case UVM32_SYSCALL_STACKPROTECT: {
#ifdef UVM32_STACK_PROTECTION #ifdef UVM32_STACK_PROTECTION
case UVM32_SYSCALL_STACKPROTECT: {
// don't allow errant code to change it once set // don't allow errant code to change it once set
if (vmst->_stack_canary == (uint8_t *)NULL) { if (vmst->_stack_canary == (uint8_t *)NULL) {
uint32_t param0 = vmst->_core.regs[10]; // a0 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; *vmst->_stack_canary = STACK_CANARY_VALUE;
} }
} }
#endif
} break; } break;
#endif
default: default:
// user defined syscalls // user defined syscalls
vmst->_ioevt.typ = UVM32_EVT_SYSCALL; vmst->_ioevt.typ = UVM32_EVT_SYSCALL;