diff options
author | Michael Forney <mforney@mforney.org> | 2017-07-04 12:25:39 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2017-07-04 23:27:34 -0700 |
commit | 6e064ade4c10bce0127ebebf6cd1dc2bb24213f5 (patch) | |
tree | 2c9736734f0be29a352909667cc333afa1134b26 /rt/start-openbsd.s | |
parent | ceb89c2cd04c695188993fe029698e2e1ee6d457 (diff) | |
download | mc-6e064ade4c10bce0127ebebf6cd1dc2bb24213f5.tar.gz |
Simplify _start routines
sys$__environment was unused since 94ee9832f5861c4d09afa12338720eb3a479c342.
Delete it and count, which is no longer needed.
Simplify _start routines since they no longer need to allocate space for the
environment slice and populate it.
Diffstat (limited to 'rt/start-openbsd.s')
-rw-r--r-- | rt/start-openbsd.s | 50 |
1 files changed, 14 insertions, 36 deletions
diff --git a/rt/start-openbsd.s b/rt/start-openbsd.s index 663d865..ad62bf4 100644 --- a/rt/start-openbsd.s +++ b/rt/start-openbsd.s @@ -8,15 +8,7 @@ .p2align 2 .data - -/* sys._environment : byte[:][:] */ -.globl sys$__environment -sys$__environment: - .envbase: - .quad 0 /* env size */ - .envlen: - .quad 0 /* env ptr */ - +/* sys.__cenvp : byte## */ .globl sys$__cenvp sys$__cenvp: .quad 0 @@ -26,45 +18,31 @@ sys$__cenvp: * The entry point for the whole program. * This is called by the OS. In order, it: * - Sets up all argc entries as slices - * - Sets up all envp entries as slices * - Converts argc/argv to a slice - * - Stashes envp in sys._environment * - Stashes a raw envp copy in __cenvp (for syscalls to use) * - Calls main() */ .globl _start _start: - /* turn args into a slice */ movq %rsp,%rbp - /* stack allocate sizeof(byte[:])*(argc + len(envp)) */ - movq (%rbp),%rax - leaq 16(%rbp,%rax,8), %rbx /* argp = argv + 8*argc + 8 */ - call count - addq %r9,%rax - imulq $16,%rax - subq %rax,%rsp - movq %rsp, %rdx /* saved args[:] */ + /* load argc, argv, envp from stack */ + movq (%rbp),%rax /* argc */ + leaq 8(%rbp),%rbx /* argv */ + leaq 16(%rbp,%rax,8),%rcx /* envp = argv + 8*argc + 8 */ - /* convert envp to byte[:][:] for sys._environment */ - movq (%rbp),%rax - leaq 16(%rbp,%rax,8), %rbx /* envp = argv + 8*argc + 8 */ /* store envp for some syscalls to use without converting */ - movq %rbx,sys$__cenvp(%rip) - movq %r9,%rax - movq %rsp, %rcx - movq %r9,.envlen(%rip) - movq %rdx,.envbase(%rip) - call cvt - movq %rcx,%rdx - + movq %rcx,sys$__cenvp(%rip) + + /* stack allocate sizeof(byte[:])*argc */ + imulq $16,%rax,%rdx + subq %rdx,%rsp + movq %rsp,%rcx /* args[:] */ + /* convert argc, argv to byte[:][:] for args. */ - movq (%rbp), %rax /* argc */ - leaq 8(%rbp), %rbx /* argv */ - movq (%rbp), %rsi /* saved argc */ + pushq %rax + pushq %rcx call cvt - pushq %rsi - pushq %rdx xorq %rbp,%rbp /* call pre-main initializers */ |