mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Add a stack canary, setup on boot
This commit is contained in:
parent
9596838a4b
commit
9baedb42e8
21 changed files with 61 additions and 16 deletions
21
apps/crt0.S
21
apps/crt0.S
|
|
@ -1,19 +1,24 @@
|
|||
#include "uvm32_sys.h"
|
||||
|
||||
.equ uvm32_syscall_halt, 0x1000000
|
||||
.equ uvm32_syscall_yield, 0x1000001
|
||||
.equ uvm32_syscall_stackprotect, 0x1000002
|
||||
|
||||
.section .initial_jump , "ax", %progbits
|
||||
.global _start
|
||||
.align 4
|
||||
_start:
|
||||
|
||||
la a0, _estack
|
||||
li a7, uvm32_syscall_stackprotect
|
||||
ecall
|
||||
|
||||
# sp is already setup by vm
|
||||
sw ra,12(sp)
|
||||
jal ra, main
|
||||
#if 1
|
||||
// rust will interpret the "#if 1" and "#include" as comments and ignore
|
||||
// C, asm, zig will include the file below, which references a constant from uvm32_sys.h
|
||||
#include "non-rust-crt0-hack.S"
|
||||
#else
|
||||
// only rust will see this
|
||||
li a7, {UVM32_SYSCALL_HALT}
|
||||
#endif
|
||||
|
||||
li a7, uvm32_syscall_halt
|
||||
ecall
|
||||
|
||||
.section .data
|
||||
|
||||
|
|
|
|||
|
|
@ -78,8 +78,9 @@ SECTIONS
|
|||
_sstack = .;
|
||||
}
|
||||
*/
|
||||
/* _sstack = .;*/
|
||||
|
||||
.stack : ALIGN( 16 ) {
|
||||
_estack = .;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ void print_maze() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void main(void) {
|
||||
init_maze();
|
||||
carve(1, 1);
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
li a7,UVM32_SYSCALL_HALT
|
||||
|
|
@ -9,7 +9,7 @@ use core::panic::PanicInfo;
|
|||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
|
||||
// startup code
|
||||
global_asm!(include_str!("../../crt0.S"), UVM32_SYSCALL_HALT = const UVM32_SYSCALL_HALT);
|
||||
global_asm!(include_str!("../../crt0.S"));
|
||||
|
||||
fn syscall(id: u32, param1: u32, param2: u32) -> u32 {
|
||||
let mut value;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue