boot2

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

start.S (696B)


      1 /* tcc-libc entry stub — same role as P1/entry-libc.P1pp's p1_main:
      2  * call __libc_init(argc, argv) so `environ` is set, then main(argc,
      3  * argv), then exit with main's return value. Linux x86_64 brings
      4  * argc at [rsp] and argv at rsp+8 on entry. */
      5 
      6     .globl _start
      7 _start:
      8     movq (%rsp), %rdi          /* argc */
      9     leaq 8(%rsp), %rsi         /* argv */
     10     pushq %rsi                 /* save across __libc_init call */
     11     pushq %rdi                 /* keeps 16-byte stack alignment */
     12     call __libc_init
     13     popq %rdi
     14     popq %rsi
     15     call main
     16     /* main's return is in %rax — feed it to exit(2). */
     17     movq %rax, %rdi
     18     movq $60, %rax             /* NR_exit */
     19     syscall