我不明白。此外,最令人惊讶的是:当我从终端运行该程序时,它会出现段错误,但在gdb中不会出现段错误。因此,尽管我很想显示gdb输出,但由于它并不有趣,所以我无法做到,而且似乎完全可以完成我想要的操作。
[OP@localhost sys_brk]$ cat out_of_memory.s
.section .text
.globl _start
_start:
mov $12, %rax # sys_brk
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:
mov $34, %rax # sys_pause
syscall