scc

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

commit a4f85de611cb9d2a03a294833a95939d3a4a47af
parent dd194c252f66d8fe13bfe23d6bc4ac422f61eb64
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