smoke_mmap.nx source
↩ module page · 15 lines · 415 B
1// smoke_mmap.nx -- verify sys_mmap works in our RV64 ELF chain.
2//
3// If this exits 7, sys_mmap returned a valid pointer + the
4// memory is writeable + readable. If it segfaults / exits
5// non-zero, the chain has a sys_mmap bug.
6
7import "syscalls.nx"
8
9func main() -> i64 {
10 let p: *u8 = sys_mmap(4096)
11 p[0] = 7
12 p[1] = 8
13 let v: i64 = p[0]
14 return __syscall(93, v, 0, 0, 0, 0, 0)
15}