我有以下程序,(我认为)该程序分配了一堆虚拟内存(通过使用sys_brk更改系统中断),然后尝试写入新分配的内存。但是,我收到了SIGSEGV(在第一次内存写入时,我不明白为什么)。
[OP@localhost sys_brk]$ cat out_of_memory.s
.section .text
.globl _start
_start:
mov $12, %rax
mov $0x1000000, %rdi
syscall
# i: index of memory we are writing to (%rax)
mov $0x403000, %rax
evil_loop_start:
cmp $0x1000000, %rax
jge evil_loop_end
mov %rax, (%rax)
add 0x8, %rax
jmp evil_loop_start
evil_loop_end:
hlt