From a0d3cac4e69101669681a4d8af6dc3e8bd2c9a6a Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sun, 15 Sep 2019 00:01:26 -0700 Subject: 5659 --- html/examples/ex12.subx.html | 62 +++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 32 deletions(-) (limited to 'html/examples/ex12.subx.html') diff --git a/html/examples/ex12.subx.html b/html/examples/ex12.subx.html index 97a07ed9..a6b2dc64 100644 --- a/html/examples/ex12.subx.html +++ b/html/examples/ex12.subx.html @@ -59,47 +59,45 @@ if ('onhashchange' in window) { 2 # Create a new segment using mmap, save the address, write to it. 3 # 4 # To run: - 5 # $ ./subx translate examples/ex12.subx -o examples/ex12 + 5 # $ ./subx translate init.linux examples/ex12.subx -o examples/ex12 6 # $ ./subx run examples/ex12 7 # You shouldn't get a segmentation fault. 8 - 9 == code 0x09000000 + 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 # syscall(mmap, 0x1000) -16 bb/copy-to-ebx Mmap-new-segment/imm32 -17 b8/copy-to-eax 0x5a/imm32/mmap -18 cd/syscall 0x80/imm8 -19 -20 # write to *eax to check that we have access to the newly-allocated segment -21 c7 0/subop/copy 0/mod/direct 0/rm32/eax . . . . . 0x34/imm32 # copy to *eax -22 -23 # syscall(exit, eax) -24 89/copy 3/mod/direct 3/rm32/ebx . . . 0/r32/eax . . # copy eax to ebx -25 b8/copy-to-eax 1/imm32/exit -26 cd/syscall 0x80/imm8 +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 . . # copy eax to ebx +24 e8/call syscall_exit/disp32 +25 +26 == data 27 -28 == data 0x0a000000 -29 -30 # various constants used here were found in the Linux sources (search for file mman-common.h) -31 Mmap-new-segment: # type mmap_arg_struct -32 # addr -33 0/imm32 -34 # len -35 0x100/imm32 -36 # protection flags -37 3/imm32 # PROT_READ | PROT_WRITE -38 # sharing flags -39 0x22/imm32 # MAP_PRIVATE | MAP_ANONYMOUS -40 # fd -41 -1/imm32 # since MAP_ANONYMOUS is specified -42 # offset -43 0/imm32 # since MAP_ANONYMOUS is specified -44 -45 # . . vim:nowrap:textwidth=0 +28 # various constants used here were found in the Linux sources (search for file mman-common.h) +29 Mmap-new-segment: # type mmap_arg_struct +30 # addr +31 0/imm32 +32 # len +33 0x100/imm32 +34 # protection flags +35 3/imm32 # PROT_READ | PROT_WRITE +36 # sharing flags +37 0x22/imm32 # MAP_PRIVATE | MAP_ANONYMOUS +38 # fd +39 -1/imm32 # since MAP_ANONYMOUS is specified +40 # offset +41 0/imm32 # since MAP_ANONYMOUS is specified +42 +43 # . . vim:nowrap:textwidth=0 -- cgit 1.4.1-2-gfad0