summaryrefslogtreecommitdiff
path: root/rt/start-osx.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-osx.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-osx.s')
-rw-r--r--rt/start-osx.s51
1 files changed, 16 insertions, 35 deletions
diff --git a/rt/start-osx.s b/rt/start-osx.s
index 3d7952f..d904746 100644
--- a/rt/start-osx.s
+++ b/rt/start-osx.s
@@ -1,58 +1,39 @@
.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
+ .quad 0
.text
/*
* 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[:] */
- /* convert envp to byte[:][:] for sys._environment */
- movq (%rbp),%rax
- leaq 16(%rbp,%rax,8), %rbx /* envp = argv + 8*argc + 8 */
- movq %rbx,_sys$__cenvp(%rip)
- movq %r9,%rax
- movq %rsp, %rcx
- movq %r9,.envlen(%rip)
- movq %rdx,.envbase(%rip)
- call cvt
- movq %rcx,%rdx
+ /* 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 */
+
+ /* store envp for some syscalls to use without converting */
+ 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 ___init__