scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 10f5b25b7e6e3fda240c7b7046712c33e667fc33
parent 7e92426be219acb2543239eff0b3a6fb3b7750da
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 22 Jan 2019 14:32:42 +0000

[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.

Diffstat:
Msrc/libc/arch/amd64/crt-posix.s | 12++++++------
Msrc/libc/arch/amd64/darwin/crt.s | 20+++++++++++++++++++-
2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/src/libc/arch/amd64/crt-posix.s b/src/libc/arch/amd64/crt-posix.s @@ -1,19 +1,19 @@ .bss - .globl __environ -__environ: + .globl _environ +_environ: .quad 0 .text .global start -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) + movq %rdx,_environ(%rip) - call _main + call main movl %eax,%edi - jmp _exit + jmp exit diff --git a/src/libc/arch/amd64/darwin/crt.s b/src/libc/arch/amd64/darwin/crt.s @@ -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