shithub: scc

Download patch

ref: 08d10710ffe6dd68c327983b794f2d2dbe183441
parent: ff9c7adf8c9068f8be72f7b1cff723224bb03719
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Jan 16 17:31:35 EST 2019

[libc] Remove libcrt

Libc gets now all the functionality of libcrt.
In the current targets supported it is only
the crt.o.

diff: cannot open a/src/libcrt//null: file does not exist: 'a/src/libcrt//null'
--- a/src/Makefile
+++ b/src/Makefile
@@ -3,7 +3,7 @@
 PROJECTDIR = ..
 include $(PROJECTDIR)/scripts/rules.mk
 
-LIBS  = libscc libc libcrt libmach
+LIBS  = libscc libc libmach
 DIRS  = cmd $(LIBS)
 
 all: cmd
--- a/src/libc/Makefile.libc
+++ b/src/libc/Makefile.libc
@@ -4,9 +4,14 @@
 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 $@
--- /dev/null
+++ b/src/libc/arch/amd64/crt-posix.s
@@ -1,0 +1,19 @@
+	.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
--- a/src/libc/arch/amd64/darwin/Makefile
+++ b/src/libc/arch/amd64/darwin/Makefile
@@ -19,11 +19,14 @@
         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
--- /dev/null
+++ b/src/libc/arch/amd64/darwin/crt.s
@@ -1,0 +1,1 @@
+	.include	"../crt-posix.s"
--- a/src/libc/arch/amd64/dragonfly/Makefile
+++ b/src/libc/arch/amd64/dragonfly/Makefile
@@ -20,11 +20,14 @@
         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
--- /dev/null
+++ b/src/libc/arch/amd64/dragonfly/crt.s
@@ -1,0 +1,1 @@
+	.include	"../crt-posix.s"
--- a/src/libc/arch/amd64/linux/Makefile
+++ b/src/libc/arch/amd64/linux/Makefile
@@ -22,11 +22,14 @@
         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
--- /dev/null
+++ b/src/libc/arch/amd64/linux/crt.s
@@ -1,0 +1,1 @@
+	.include	"../crt-posix.s"
--- a/src/libc/arch/amd64/netbsd/Makefile
+++ b/src/libc/arch/amd64/netbsd/Makefile
@@ -23,11 +23,14 @@
         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
--- /dev/null
+++ b/src/libc/arch/amd64/netbsd/crt.s
@@ -1,0 +1,2 @@
+	.include	"../../crt-netbsd.s"
+	.include	"../crt-posix.s"
--- a/src/libc/arch/amd64/openbsd/Makefile
+++ b/src/libc/arch/amd64/openbsd/Makefile
@@ -20,11 +20,14 @@
         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
--- /dev/null
+++ b/src/libc/arch/amd64/openbsd/crt.s
@@ -1,0 +1,2 @@
+	.include	"../../crt-openbsd.s"
+	.include	"../crt-posix.s"
--- /dev/null
+++ b/src/libc/arch/arm32/crt-posix.s
@@ -1,0 +1,16 @@
+	.bss
+	.globl	_environ
+_environ:
+	.word	0
+
+	.text
+	.globl	_start
+_start:
+	ldr	r0,[sp]		/* argc */
+	add	r1,sp,#4	/* argv */
+	add	r2,r1,r0,lsl #2	/* argv = argc + 4*argc + 4 */
+	add	r2,r2,#4
+	ldr	r3,=_environ
+	str	r2,[r3]
+	bl	main
+	b	exit
--- a/src/libc/arch/arm32/linux/Makefile
+++ b/src/libc/arch/arm32/linux/Makefile
@@ -22,11 +22,14 @@
         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
--- /dev/null
+++ b/src/libc/arch/arm32/linux/crt.s
@@ -1,0 +1,1 @@
+	.include	"../crt-posix.s"
--- /dev/null
+++ b/src/libc/arch/arm64/crt-posix.s
@@ -1,0 +1,16 @@
+	.bss
+	.globl	_environ
+_environ:
+	.quad	0
+
+	.text
+	.globl	_start
+_start:
+	ldr	x0,[sp]		/* argc */
+	add	x1,sp,#8	/* argv */
+	add	x2,x1,x0,lsl #3	/* argv = argc + 8*argc + 8 */
+	add	x2,x2,#8
+	adr	x3,_environ
+	str	x2,[x3]
+	bl	main
+	b	exit
--- a/src/libc/arch/arm64/linux/Makefile
+++ b/src/libc/arch/arm64/linux/Makefile
@@ -22,11 +22,14 @@
         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
--- /dev/null
+++ b/src/libc/arch/arm64/linux/crt.s
@@ -1,0 +1,1 @@
+	.include	"../crt-posix.c"
--- /dev/null
+++ b/src/libc/arch/crt-netbsd.s
@@ -1,0 +1,9 @@
+	.file	"crt-netbsd.s"
+	.section	".note.netbsd.ident", "a"
+	.p2align	2
+
+	.long	7
+	.long	4
+	.long	1
+	.ascii	"NetBSD\0\0"
+	.long	800000000
--- /dev/null
+++ b/src/libc/arch/crt-openbsd.s
@@ -1,0 +1,9 @@
+	.file	"crt-openbsd.s"
+	.section	".note.openbsd.ident", "a"
+	.p2align	2
+	.long	8
+	.long	4
+	.long	1
+	.ascii	"OpenBSD\0"
+	.long	0
+	.p2align	2
--- a/src/libcrt/Makefile
+++ /dev/null
@@ -1,11 +1,0 @@
-.POSIX:
-PROJECTDIR=../..
-include $(PROJECTDIR)/scripts/rules.mk
-
-OBJS   = crt-$(SYS).o crt-$(ABI).o
-TARGET = $(CRTDIR)/$(ARCH)-$(SYS)/crt.o
-
-all: $(TARGET)
-
-$(TARGET): $(OBJS)
-	$(LD) -r -o $@ $(OBJS)
--- a/src/libcrt/crt-amd64-darwin.s
+++ /dev/null
@@ -1,19 +1,0 @@
-	.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
--- a/src/libcrt/crt-amd64-posix.s
+++ /dev/null
@@ -1,19 +1,0 @@
-	.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
-
-	call	main
-	movl	%eax,%edi
-	jmp	exit
--- a/src/libcrt/crt-arm32-posix.s
+++ /dev/null
@@ -1,16 +1,0 @@
-	.bss
-	.globl	_environ
-_environ:
-	.word	0
-
-	.text
-	.globl	_start
-_start:
-	ldr	r0,[sp]		/* argc */
-	add	r1,sp,#4	/* argv */
-	add	r2,r1,r0,lsl #2	/* argv = argc + 4*argc + 4 */
-	add	r2,r2,#4
-	ldr	r3,=_environ
-	str	r2,[r3]
-	bl	main
-	b	exit
--- a/src/libcrt/crt-arm64-posix.s
+++ /dev/null
@@ -1,16 +1,0 @@
-	.bss
-	.globl	_environ
-_environ:
-	.quad	0
-
-	.text
-	.globl	_start
-_start:
-	ldr	x0,[sp]		/* argc */
-	add	x1,sp,#8	/* argv */
-	add	x2,x1,x0,lsl #3	/* argv = argc + 8*argc + 8 */
-	add	x2,x2,#8
-	adr	x3,_environ
-	str	x2,[x3]
-	bl	main
-	b	exit
--- a/src/libcrt/crt-darwin.s
+++ /dev/null
@@ -1,1 +1,0 @@
-	.file	"crt-darwin.s"
--- a/src/libcrt/crt-dragonfly.s
+++ /dev/null
@@ -1,1 +1,0 @@
-	.file	"crt-dragonfly.s"
--- a/src/libcrt/crt-linux.s
+++ /dev/null
@@ -1,1 +1,0 @@
-	.file	"crt-linux.s"
--- a/src/libcrt/crt-netbsd.s
+++ /dev/null
@@ -1,9 +1,0 @@
-	.file	"crt-netbsd.s"
-	.section	".note.netbsd.ident", "a"
-	.p2align	2
-
-	.long	7
-	.long	4
-	.long	1
-	.ascii	"NetBSD\0\0"
-	.long	800000000
--- a/src/libcrt/crt-openbsd.s
+++ /dev/null
@@ -1,9 +1,0 @@
-	.file	"crt-openbsd.s"
-	.section	".note.openbsd.ident", "a"
-	.p2align	2
-	.long	8
-	.long	4
-	.long	1
-	.ascii	"OpenBSD\0"
-	.long	0
-	.p2align	2