Skip to content

Instantly share code, notes, and snippets.

@syuu1228
Last active December 8, 2021 21:20
Show Gist options
  • Select an option

  • Save syuu1228/8189292 to your computer and use it in GitHub Desktop.

Select an option

Save syuu1228/8189292 to your computer and use it in GitHub Desktop.

Revisions

  1. syuu1228 revised this gist Dec 30, 2013. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions arm-mmap.s
    Original file line number Diff line number Diff line change
    @@ -19,19 +19,19 @@
    _start:
    ldr r0, .L3
    mov r1, #2
    mov r7, #5 @ open("/dev/mem", O_RDWR) = 3
    swi #0
    mov r7, #5
    swi #0 @ open("/dev/mem", O_RDWR) = 3
    mov r4, r0
    mov r0, #0
    mov r1, #256
    mov r2, #1
    mov r3, #1
    mov r5, #1280
    mov r7, #192 @ mmap2(NULL, 256, PROT_READ, MAP_SHARED, 3, 0x500) = 0x40000000
    swi #0
    mov r7, #192
    swi #0 @ mmap2(NULL, 256, PROT_READ, MAP_SHARED, 3, 0x500) = 0x40000000
    mov r0, #0
    mov r7, #1 @ exit(0) = ?
    swi #0
    mov r7, #1
    swi #0 @ exit(0) = ?
    .L4:
    .align 2
    .L3:
  2. syuu1228 revised this gist Dec 30, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions arm-mmap.s
    Original file line number Diff line number Diff line change
    @@ -19,18 +19,18 @@
    _start:
    ldr r0, .L3
    mov r1, #2
    mov r7, #5 @ sys_open
    mov r7, #5 @ open("/dev/mem", O_RDWR) = 3
    swi #0
    mov r4, r0
    mov r0, #0
    mov r1, #256
    mov r2, #1
    mov r3, #1
    mov r5, #1280
    mov r7, #192 @ sys_mmap2
    mov r7, #192 @ mmap2(NULL, 256, PROT_READ, MAP_SHARED, 3, 0x500) = 0x40000000
    swi #0
    mov r0, #0
    mov r7, #1 @ sys_exit
    mov r7, #1 @ exit(0) = ?
    swi #0
    .L4:
    .align 2
  3. syuu1228 created this gist Dec 30, 2013.
    40 changes: 40 additions & 0 deletions arm-mmap.s
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    @ This is Linux/arm EABI system call sample program.
    @
    @ Build with following command:
    @ as -o arm-mmap.o arm-mmap.s
    @ ld -o arm-mmap arm-mmap.o
    @
    @ You can see the program issues system calls by following command:
    @ strace ./arm-mmap
    @

    .section .rodata
    .align 2
    .LC0:
    .ascii "/dev/mem\000"
    .text
    .align 2
    .global _start
    .type _start, %function
    _start:
    ldr r0, .L3
    mov r1, #2
    mov r7, #5 @ sys_open
    swi #0
    mov r4, r0
    mov r0, #0
    mov r1, #256
    mov r2, #1
    mov r3, #1
    mov r5, #1280
    mov r7, #192 @ sys_mmap2
    swi #0
    mov r0, #0
    mov r7, #1 @ sys_exit
    swi #0
    .L4:
    .align 2
    .L3:
    .word .LC0
    .size _start, .-_start