summaryrefslogtreecommitdiff
path: root/rt/start-netbsd.s
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2017-07-04 12:25:39 -0700
committerOri Bernstein <ori@eigenstate.org>2017-07-04 23:27:34 -0700
commit6e064ade4c10bce0127ebebf6cd1dc2bb24213f5 (patch)
tree2c9736734f0be29a352909667cc333afa1134b26 /rt/start-netbsd.s
parentceb89c2cd04c695188993fe029698e2e1ee6d457 (diff)
downloadmc-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-netbsd.s')
-rw-r--r--rt/start-netbsd.s50
1 files changed, 14 insertions, 36 deletions
diff --git a/rt/start-netbsd.s b/rt/start-netbsd.s
index bd2d576..a5eecc4 100644
--- a/rt/start-netbsd.s
+++ b/rt/start-netbsd.s
@@ -7,15 +7,7 @@
.long 200000000
.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
@@ -25,45 +17,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 */