scc

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

commit fe5a501cb8debef6f049dbe28dd6674483bafaf1
parent ae3d788c5b30c40ccc7e2a83734c82f49f17c3d0
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon,  7 Oct 2019 21:22:53 +0200

[libc] Revert crt.o changes

Crt.o cannot go in libcrt.o because it has a dependency
with exit() and it makes a circular dependency.

Diffstat:
Msrc/libc/Makefile.libc | 9+++++++--
Rsrc/libcrt/amd64/crt-posix.s -> src/libc/arch/amd64/crt-posix.s | 0
Msrc/libc/arch/amd64/darwin/Makefile | 3+++
Rsrc/libcrt/amd64/crt-darwin.s -> src/libc/arch/amd64/darwin/crt.s | 0
Msrc/libc/arch/amd64/dragonfly/Makefile | 3+++
Asrc/libc/arch/amd64/dragonfly/crt.s | 1+
Msrc/libc/arch/amd64/linux/Makefile | 3+++
Asrc/libc/arch/amd64/linux/crt.s | 1+
Msrc/libc/arch/amd64/netbsd/Makefile | 3+++
Asrc/libc/arch/amd64/netbsd/crt.s | 2++
Msrc/libc/arch/amd64/openbsd/Makefile | 3+++
Asrc/libc/arch/amd64/openbsd/crt.s | 2++
Rsrc/libcrt/arm32/crt-posix.s -> src/libc/arch/arm32/crt-posix.s | 0
Msrc/libc/arch/arm32/linux/Makefile | 3+++
Asrc/libc/arch/arm32/linux/crt.s | 1+
Rsrc/libcrt/arm64/crt-posix.s -> src/libc/arch/arm64/crt-posix.s | 0
Msrc/libc/arch/arm64/linux/Makefile | 3+++
Asrc/libc/arch/arm64/linux/crt.s | 1+
Rsrc/libcrt/netbsd-ident.s -> src/libc/arch/crt-netbsd.s | 0
Rsrc/libcrt/openbsd-ident.s -> src/libc/arch/crt-openbsd.s | 0
Asrc/libc/arch/i386/crt-posix.s | 18++++++++++++++++++
Msrc/libc/arch/i386/linux/Makefile | 3+++
Asrc/libc/arch/i386/linux/crt.s | 1+
Msrc/libcrt/amd64/Makefile | 2+-
Dsrc/libcrt/amd64/crt-dragonfly.s | 1-
Dsrc/libcrt/amd64/crt-linux.s | 1-
Dsrc/libcrt/amd64/crt-netbsd.s | 2--
Dsrc/libcrt/amd64/crt-openbsd.s | 2--
Asrc/libcrt/amd64/dummy.s | 0
Msrc/libcrt/arm32/Makefile | 2+-
Dsrc/libcrt/arm32/crt-linux.s | 1-
Asrc/libcrt/arm32/dummy.c | 0
Msrc/libcrt/arm64/Makefile | 2+-
Dsrc/libcrt/arm64/crt-linux.s | 1-
Asrc/libcrt/arm64/dummy.s | 0
Msrc/libcrt/i386/Makefile | 2+-
Dsrc/libcrt/i386/crt-linux.s | 1-
Dsrc/libcrt/i386/crt-posix.s | 18------------------
38 files changed, 62 insertions(+), 33 deletions(-)

diff --git a/src/libc/Makefile.libc b/src/libc/Makefile.libc @@ -4,9 +4,14 @@ include $(PROJECTDIR)/scripts/rules.mk include rules.mk include objlst.mk -TARGET = $(LIBCDIR)/libc.a +LIBC = $(LIBCDIR)/libc.a +CRT = $(LIBCDIR)/crt.o +TARGET = $(LIBC) $(CRT) all: $(TARGET) -$(TARGET): $(OBJS) +$(LIBC): $(OBJS) mklib -o $@ $? + +$(CRT): arch/$(ARCH)/$(SYS)/crt.o + cp arch/$(ARCH)/$(SYS)/crt.o $@ diff --git a/src/libcrt/amd64/crt-posix.s b/src/libc/arch/amd64/crt-posix.s diff --git a/src/libc/arch/amd64/darwin/Makefile b/src/libc/arch/amd64/darwin/Makefile @@ -19,12 +19,15 @@ OBJS = __Exit.o \ signal.o \ time.o \ _sys_errlist.o \ + crt.o \ all: syscall $(MAKE) objs objs: $(OBJS) +crt.o: ../crt-posix.s + syscall: syscall.lst gensys.sh syscall.lst touch syscall diff --git a/src/libcrt/amd64/crt-darwin.s b/src/libc/arch/amd64/darwin/crt.s diff --git a/src/libc/arch/amd64/dragonfly/Makefile b/src/libc/arch/amd64/dragonfly/Makefile @@ -20,12 +20,15 @@ OBJS = _Exit.o \ signal.o \ time.o \ _sys_errlist.o \ + crt.o \ all: syscall $(MAKE) objs objs: $(OBJS) +crt.o: crt-posix.s + syscall: syscall.lst gensys.sh syscall.lst touch syscall diff --git a/src/libc/arch/amd64/dragonfly/crt.s b/src/libc/arch/amd64/dragonfly/crt.s @@ -0,0 +1 @@ + .include "../crt-posix.s" diff --git a/src/libc/arch/amd64/linux/Makefile b/src/libc/arch/amd64/linux/Makefile @@ -22,12 +22,15 @@ OBJS = _Exit.o \ signal.o \ time.o \ _sys_errlist.o \ + crt.o \ all: syscall $(MAKE) objs objs: $(OBJS) +crt.o: ../crt-posix.s + syscall: syscall.lst gensys.sh syscall.lst touch syscall diff --git a/src/libc/arch/amd64/linux/crt.s b/src/libc/arch/amd64/linux/crt.s @@ -0,0 +1 @@ + .include "../crt-posix.s" diff --git a/src/libc/arch/amd64/netbsd/Makefile b/src/libc/arch/amd64/netbsd/Makefile @@ -23,12 +23,15 @@ OBJS = _Exit.o \ signal.o \ time.o \ _sys_errlist.o \ + crt.o \ all: syscall $(MAKE) objs objs: $(OBJS) +crt.o: ../crt-posix.s ../../crt-netbsd.s + syscall: syscall.lst gensys.sh syscall.lst touch syscall diff --git a/src/libc/arch/amd64/netbsd/crt.s b/src/libc/arch/amd64/netbsd/crt.s @@ -0,0 +1,2 @@ + .include "../../crt-netbsd.s" + .include "../crt-posix.s" diff --git a/src/libc/arch/amd64/openbsd/Makefile b/src/libc/arch/amd64/openbsd/Makefile @@ -20,12 +20,15 @@ OBJS = _Exit.o \ signal.o \ time.o \ _sys_errlist.o \ + crt.o \ all: syscall $(MAKE) objs objs: $(OBJS) +crt.o: ../crt-posix.s ../../crt-openbsd.s + syscall: syscall.lst gensys.sh syscall.lst touch syscall diff --git a/src/libc/arch/amd64/openbsd/crt.s b/src/libc/arch/amd64/openbsd/crt.s @@ -0,0 +1,2 @@ + .include "../../crt-openbsd.s" + .include "../crt-posix.s" diff --git a/src/libcrt/arm32/crt-posix.s b/src/libc/arch/arm32/crt-posix.s diff --git a/src/libc/arch/arm32/linux/Makefile b/src/libc/arch/arm32/linux/Makefile @@ -22,12 +22,15 @@ OBJS = _Exit.o \ signal.o \ time.o \ _sys_errlist.o \ + crt.o \ all: syscall $(MAKE) objs objs: $(OBJS) +crt.o: ../crt-posix.s + syscall: syscall.lst gensys.sh syscall.lst touch syscall diff --git a/src/libc/arch/arm32/linux/crt.s b/src/libc/arch/arm32/linux/crt.s @@ -0,0 +1 @@ + .include "../crt-posix.s" diff --git a/src/libcrt/arm64/crt-posix.s b/src/libc/arch/arm64/crt-posix.s diff --git a/src/libc/arch/arm64/linux/Makefile b/src/libc/arch/arm64/linux/Makefile @@ -22,12 +22,15 @@ OBJS = _Exit.o \ signal.o \ time.o \ _sys_errlist.o \ + crt.o \ all: syscall $(MAKE) objs objs: $(OBJS) +crt.o: ../crt-posix.s + syscall: syscall.lst gensys.sh syscall.lst touch syscall diff --git a/src/libc/arch/arm64/linux/crt.s b/src/libc/arch/arm64/linux/crt.s @@ -0,0 +1 @@ + .include "../crt-posix.c" diff --git a/src/libcrt/netbsd-ident.s b/src/libc/arch/crt-netbsd.s diff --git a/src/libcrt/openbsd-ident.s b/src/libc/arch/crt-openbsd.s diff --git a/src/libc/arch/i386/crt-posix.s b/src/libc/arch/i386/crt-posix.s @@ -0,0 +1,18 @@ + .bss + .globl _environ +_environ: + .long 0 + + .text + .global start +_start: + movl %esp,%ebp + + movl (%ebp),%edi + leal 8(%ebp),%esi + leal 16(%ebp,%edi,8),%edx + movl %edx,_environ + + call main + movl %eax,%edi + jmp exit diff --git a/src/libc/arch/i386/linux/Makefile b/src/libc/arch/i386/linux/Makefile @@ -15,12 +15,15 @@ OBJS =\ _getpid.o\ _Exit.o\ _kill.o\ + crt.o\ all: syscall $(MAKE) objs objs: $(OBJS) +crt.o: ../crt-posix.s + syscall: syscall.lst gensys.sh syscall.lst touch syscall diff --git a/src/libc/arch/i386/linux/crt.s b/src/libc/arch/i386/linux/crt.s @@ -0,0 +1 @@ + .include "../crt-posix.s" diff --git a/src/libcrt/amd64/Makefile b/src/libcrt/amd64/Makefile @@ -2,7 +2,7 @@ PROJECTDIR=../../.. include $(PROJECTDIR)/scripts/rules.mk -OBJS = crt-$(SYS).o +OBJS = dummy.o TARGET = $(LIBCDIR)/libcrt.a all: $(TARGET) diff --git a/src/libcrt/amd64/crt-dragonfly.s b/src/libcrt/amd64/crt-dragonfly.s @@ -1 +0,0 @@ - .include "crt-posix.s" diff --git a/src/libcrt/amd64/crt-linux.s b/src/libcrt/amd64/crt-linux.s @@ -1 +0,0 @@ - .include "crt-posix.s" diff --git a/src/libcrt/amd64/crt-netbsd.s b/src/libcrt/amd64/crt-netbsd.s @@ -1,2 +0,0 @@ - .include "../netbsd-ident.s" - .include "crt-posix.s" diff --git a/src/libcrt/amd64/crt-openbsd.s b/src/libcrt/amd64/crt-openbsd.s @@ -1,2 +0,0 @@ - .include "../openbsd-ident.s" - .include "crt-posix.s" diff --git a/src/libcrt/amd64/dummy.s b/src/libcrt/amd64/dummy.s diff --git a/src/libcrt/arm32/Makefile b/src/libcrt/arm32/Makefile @@ -2,7 +2,7 @@ PROJECTDIR=../../.. include $(PROJECTDIR)/scripts/rules.mk -OBJS = crt-$(SYS).o +OBJS = dummy.o TARGET = $(LIBCDIR)/libcrt.a all: $(TARGET) diff --git a/src/libcrt/arm32/crt-linux.s b/src/libcrt/arm32/crt-linux.s @@ -1 +0,0 @@ - .include "crt-posix.s" diff --git a/src/libcrt/arm32/dummy.c b/src/libcrt/arm32/dummy.c diff --git a/src/libcrt/arm64/Makefile b/src/libcrt/arm64/Makefile @@ -2,7 +2,7 @@ PROJECTDIR=../../.. include $(PROJECTDIR)/scripts/rules.mk -OBJS = crt-$(SYS).o +OBJS = dummy.o TARGET = $(LIBCDIR)/libcrt.a all: $(TARGET) diff --git a/src/libcrt/arm64/crt-linux.s b/src/libcrt/arm64/crt-linux.s @@ -1 +0,0 @@ - .include "crt-posix.c" diff --git a/src/libcrt/arm64/dummy.s b/src/libcrt/arm64/dummy.s diff --git a/src/libcrt/i386/Makefile b/src/libcrt/i386/Makefile @@ -2,7 +2,7 @@ PROJECTDIR=../../.. include $(PROJECTDIR)/scripts/rules.mk -OBJS = crt-$(SYS).o +OBJS = dummy.o TARGET = $(LIBCDIR)/libcrt.a all: $(TARGET) diff --git a/src/libcrt/i386/crt-linux.s b/src/libcrt/i386/crt-linux.s @@ -1 +0,0 @@ - .include "crt-posix.s" diff --git a/src/libcrt/i386/crt-posix.s b/src/libcrt/i386/crt-posix.s @@ -1,18 +0,0 @@ - .bss - .globl _environ -_environ: - .long 0 - - .text - .global _start -_start: - movl %esp,%ebp - - movl (%ebp),%edi - leal 8(%ebp),%esi - leal 16(%ebp,%edi,8),%edx - movl %edx,_environ - - call main - movl %eax,%edi - jmp exit