1 # Example showing mmap syscall. 2 # Create a new segment using mmap, save the address, write to it. 3 # 4 # To run: 5 # $ ./bootstrap translate init.linux apps/ex12.subx -o apps/ex12 6 # $ ./bootstrap run apps/ex12 7 # You shouldn't get a segmentation fault. 8 9 == code 10 # instruction effective address register displacement immediate 11 # . op subop mod rm32 base index scale r32 12 # . 1-3 bytes 3 bits 2 bits 3 bits 3 bits 3 bits 2 bits 2 bits 0/1/2/4 bytes 0/1/2/4 bytes 13 14 Entry: 15 # mmap(Mmap-new-segment->len) 16 bb/copy-to-ebx Mmap-new-segment/imm32 17 e8/call syscall_mmap/disp32 18 19 # write to *eax to check that we have access to the newly-allocated segment 20 c7 0/subop/copy 0/mod/direct 0/rm32/eax . . . . . 0x34/imm32 # copy to *eax 21 22 # exit(eax) 23 89/copy 3/mod/direct 3/rm32/ebx . . . 0/r32/eax