scc

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

commit cd06c9058ca8de3c2b3b7602b3a610690fbe9e0a
parent 0a748d8bedd9299ef1917a458d6b7b753b79e17c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun,  6 Oct 2019 09:51:11 +0200

[libcrt] Add libcrt

This library is intended for the C runtime. The C runtime must
supply the code needed to support the language.

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

diff --git a/src/Makefile b/src/Makefile @@ -3,7 +3,7 @@ PROJECTDIR = .. include $(PROJECTDIR)/scripts/rules.mk -LIBS = libscc libc libmach +LIBS = libcrt libscc libc libmach DIRS = cmd $(LIBS) all: cmd diff --git a/src/libc/Makefile.libc b/src/libc/Makefile.libc @@ -4,14 +4,9 @@ include $(PROJECTDIR)/scripts/rules.mk include rules.mk include objlst.mk -LIBC = $(LIBCDIR)/libc.a -CRT = $(LIBCDIR)/crt.o -TARGET = $(LIBC) $(CRT) +TARGET = $(LIBCDIR)/libc.a all: $(TARGET) -$(LIBC): $(OBJS) +$(TARGET): $(OBJS) mklib -o $@ $? - -$(CRT): arch/$(ARCH)/$(SYS)/crt.o - cp arch/$(ARCH)/$(SYS)/crt.o $@ diff --git a/src/libc/arch/amd64/darwin/Makefile b/src/libc/arch/amd64/darwin/Makefile @@ -19,15 +19,12 @@ 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/Makefile b/src/libc/arch/amd64/dragonfly/Makefile @@ -20,15 +20,12 @@ 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 @@ -1 +0,0 @@ - .include "../crt-posix.s" diff --git a/src/libc/arch/amd64/linux/Makefile b/src/libc/arch/amd64/linux/Makefile @@ -22,15 +22,12 @@ 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 @@ -1 +0,0 @@ - .include "../crt-posix.s" diff --git a/src/libc/arch/amd64/netbsd/Makefile b/src/libc/arch/amd64/netbsd/Makefile @@ -23,15 +23,12 @@ 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 @@ -1,2 +0,0 @@ - .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,15 +20,12 @@ 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 @@ -1,2 +0,0 @@ - .include "../../crt-openbsd.s" - .include "../crt-posix.s" diff --git a/src/libc/arch/arm32/linux/Makefile b/src/libc/arch/arm32/linux/Makefile @@ -22,15 +22,12 @@ 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 @@ -1 +0,0 @@ - .include "../crt-posix.s" diff --git a/src/libc/arch/arm64/linux/Makefile b/src/libc/arch/arm64/linux/Makefile @@ -22,15 +22,12 @@ 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 @@ -1 +0,0 @@ - .include "../crt-posix.c" diff --git a/src/libc/arch/i386/crt-posix.s b/src/libc/arch/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 diff --git a/src/libc/arch/i386/linux/Makefile b/src/libc/arch/i386/linux/Makefile @@ -15,15 +15,12 @@ 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 @@ -1 +0,0 @@ - .include "../crt-posix.s" diff --git a/src/libcrt/Makefile b/src/libcrt/Makefile @@ -0,0 +1,6 @@ +.POSIX: +PROJECTDIR=../.. +include $(PROJECTDIR)/scripts/rules.mk + +all clean dep: + cd $(ARCH) && $(MAKE) $@ diff --git a/src/libcrt/amd64/Makefile b/src/libcrt/amd64/Makefile @@ -0,0 +1,11 @@ +.POSIX: +PROJECTDIR=../../.. +include $(PROJECTDIR)/scripts/rules.mk + +OBJS = crt-$(SYS).o +TARGET = $(LIBCDIR)/libcrt.a + +all: $(TARGET) + +$(TARGET): $(OBJS) + mklib -o $@ $? diff --git a/src/libc/arch/amd64/darwin/crt.s b/src/libcrt/amd64/crt-darwin.s diff --git a/src/libcrt/amd64/crt-dragonfly.s b/src/libcrt/amd64/crt-dragonfly.s @@ -0,0 +1 @@ + .include "crt-posix.s" diff --git a/src/libcrt/amd64/crt-linux.s b/src/libcrt/amd64/crt-linux.s @@ -0,0 +1 @@ + .include "crt-posix.s" diff --git a/src/libcrt/amd64/crt-netbsd.s b/src/libcrt/amd64/crt-netbsd.s @@ -0,0 +1,2 @@ + .include "../netbsd-ident.s" + .include "crt-posix.s" diff --git a/src/libcrt/amd64/crt-openbsd.s b/src/libcrt/amd64/crt-openbsd.s @@ -0,0 +1,2 @@ + .include "../openbsd-ident.s" + .include "crt-posix.s" diff --git a/src/libc/arch/amd64/crt-posix.s b/src/libcrt/amd64/crt-posix.s diff --git a/src/libcrt/arm32/Makefile b/src/libcrt/arm32/Makefile @@ -0,0 +1,11 @@ +.POSIX: +PROJECTDIR=../../.. +include $(PROJECTDIR)/scripts/rules.mk + +OBJS = crt-$(SYS).o +TARGET = $(LIBCDIR)/libcrt.a + +all: $(TARGET) + +$(TARGET): $(OBJS) + mklib -o $@ $? diff --git a/src/libcrt/arm32/crt-linux.s b/src/libcrt/arm32/crt-linux.s @@ -0,0 +1 @@ + .include "crt-posix.s" diff --git a/src/libc/arch/arm32/crt-posix.s b/src/libcrt/arm32/crt-posix.s diff --git a/src/libcrt/arm64/Makefile b/src/libcrt/arm64/Makefile @@ -0,0 +1,11 @@ +.POSIX: +PROJECTDIR=../../.. +include $(PROJECTDIR)/scripts/rules.mk + +OBJS = crt-$(SYS).o +TARGET = $(LIBCDIR)/libcrt.a + +all: $(TARGET) + +$(TARGET): $(OBJS) + mklib -o $@ $? diff --git a/src/libcrt/arm64/crt-linux.s b/src/libcrt/arm64/crt-linux.s @@ -0,0 +1 @@ + .include "crt-posix.c" diff --git a/src/libc/arch/arm64/crt-posix.s b/src/libcrt/arm64/crt-posix.s diff --git a/src/libcrt/i386/Makefile b/src/libcrt/i386/Makefile @@ -0,0 +1,11 @@ +.POSIX: +PROJECTDIR=../../.. +include $(PROJECTDIR)/scripts/rules.mk + +OBJS = crt-$(SYS).o +TARGET = $(LIBCDIR)/libcrt.a + +all: $(TARGET) + +$(TARGET): $(OBJS) + mklib -o $@ $? diff --git a/src/libcrt/i386/crt-linux.s b/src/libcrt/i386/crt-linux.s @@ -0,0 +1 @@ + .include "crt-posix.s" diff --git a/src/libcrt/i386/crt-posix.s b/src/libcrt/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/crt-netbsd.s b/src/libcrt/netbsd-ident.s diff --git a/src/libc/arch/crt-openbsd.s b/src/libcrt/openbsd-ident.s