boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

sys_stubs.S (1552B)


      1 /* Linux aarch64 syscall stubs matching the sys_* labels libp1pp
      2  * provides (see P1/P1pp.P1pp). boot2-syscall.c declares them as
      3  * extern long sys_<name>(...) and the mes-libc layers (read/write/
      4  * open/close/lseek/sbrk/unlink/_exit) call them. The cc.scm + libp1pp
      5  * pipeline resolves these labels against P1pp.P1pp's wrappers; the
      6  * tcc-libc suite links against this object instead since tcc-built
      7  * binaries don't catm libp1pp.
      8  *
      9  * Linux aarch64 syscall ABI: nr in x8, args in x0-x5, return in x0.
     10  *
     11  * sys_open/sys_unlink shuffle args because Linux's openat/unlinkat
     12  * take an AT_FDCWD prefix that the libp1pp-compatible wrappers
     13  * don't surface to callers.
     14  */
     15 
     16     .globl sys_read, sys_write, sys_close, sys_open
     17     .globl sys_lseek, sys_brk, sys_unlink, sys_exit
     18 
     19 sys_read:
     20     mov x8, #63
     21     svc #0
     22     ret
     23 
     24 sys_write:
     25     mov x8, #64
     26     svc #0
     27     ret
     28 
     29 sys_close:
     30     mov x8, #57
     31     svc #0
     32     ret
     33 
     34 sys_open:
     35     /* (path, flags, mode) -> openat(AT_FDCWD, path, flags, mode) */
     36     mov x3, x2          /* mode  */
     37     mov x2, x1          /* flags */
     38     mov x1, x0          /* path  */
     39     mov x0, #-100       /* AT_FDCWD */
     40     mov x8, #56
     41     svc #0
     42     ret
     43 
     44 sys_lseek:
     45     mov x8, #62
     46     svc #0
     47     ret
     48 
     49 sys_brk:
     50     mov x8, #214
     51     svc #0
     52     ret
     53 
     54 sys_unlink:
     55     /* (path) -> unlinkat(AT_FDCWD, path, 0) */
     56     mov x1, x0          /* path  */
     57     mov x0, #-100       /* AT_FDCWD */
     58     mov x2, #0          /* flags */
     59     mov x8, #35
     60     svc #0
     61     ret
     62 
     63 sys_exit:
     64     mov x8, #93
     65     svc #0
     66     /* unreachable */
     67     b .