ref: 10f5b25b7e6e3fda240c7b7046712c33e667fc33
parent: 7e92426be219acb2543239eff0b3a6fb3b7750da
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Jan 22 09:32:42 EST 2019
[libc] Fix amd64 crts Darwin doesn't follow the POSIX abi when it comes to the name of the symbols created by the C compiler, so it cannot share the same crt than other POSIX systems.
--- a/src/libc/arch/amd64/crt-posix.s
+++ b/src/libc/arch/amd64/crt-posix.s
@@ -1,11 +1,11 @@
.bss
- .globl __environ
-__environ:
+ .globl _environ
+_environ:
.quad 0
.text
.global start
-start:
+_start:
movq %rsp,%rbp
/* load argc, argv, envp from stack */
@@ -12,8 +12,8 @@
movq (%rbp),%rdi /* argc */
leaq 8(%rbp),%rsi /* argv */
leaq 16(%rbp,%rdi,8),%rdx /* envp = argv + 8*argc + 8 */
- movq %rdx,__environ(%rip)
+ movq %rdx,_environ(%rip)
- call _main
+ call main
movl %eax,%edi
- jmp _exit
+ jmp exit
--- a/src/libc/arch/amd64/darwin/crt.s
+++ b/src/libc/arch/amd64/darwin/crt.s
@@ -1,1 +1,19 @@
- .include "../crt-posix.s"
+ .bss
+ .globl __environ
+__environ:
+ .quad 0
+
+ .text
+ .global start
+start:
+ movq %rsp,%rbp
+
+ /* load argc, argv, envp from stack */
+ movq (%rbp),%rdi /* argc */
+ leaq 8(%rbp),%rsi /* argv */
+ leaq 16(%rbp,%rdi,8),%rdx /* envp = argv + 8*argc + 8 */
+ movq %rdx,__environ(%rip)
+
+ call _main
+ movl %eax,%edi
+ jmp _exit