shithub: scc

Download patch

ref: 7e737ab9f7d62562c927a6af15dfc8eb78ecaec8
parent: a165af3d8406d98aaf6bb86048690ca3d4e6648d
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Oct 7 17:22:53 EDT 2019

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

--- 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
+	.globl	_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,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/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
--- /dev/null
+++ b/src/libc/arch/i386/crt-posix.s
@@ -1,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
--- a/src/libc/arch/i386/linux/Makefile
+++ b/src/libc/arch/i386/linux/Makefile
@@ -15,11 +15,14 @@
 	_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
--- /dev/null
+++ b/src/libc/arch/i386/linux/crt.s
@@ -1,0 +1,1 @@
+	.include	"../crt-posix.s"
--- 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)
--- a/src/libcrt/amd64/crt-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/amd64/crt-dragonfly.s
+++ /dev/null
@@ -1,1 +1,0 @@
-	.include	"crt-posix.s"
--- a/src/libcrt/amd64/crt-linux.s
+++ /dev/null
@@ -1,1 +1,0 @@
-	.include	"crt-posix.s"
--- a/src/libcrt/amd64/crt-netbsd.s
+++ /dev/null
@@ -1,2 +1,0 @@
-	.include	"../netbsd-ident.s"
-	.include	"crt-posix.s"
--- a/src/libcrt/amd64/crt-openbsd.s
+++ /dev/null
@@ -1,2 +1,0 @@
-	.include	"../openbsd-ident.s"
-	.include	"crt-posix.s"
--- a/src/libcrt/amd64/crt-posix.s
+++ /dev/null
@@ -1,19 +1,0 @@
-	.bss
-	.globl	_environ
-_environ:
-	.quad	0
-
-	.text
-	.globl	_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/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)
--- a/src/libcrt/arm32/crt-linux.s
+++ /dev/null
@@ -1,1 +1,0 @@
-	.include	"crt-posix.s"
--- a/src/libcrt/arm32/crt-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/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)
--- a/src/libcrt/arm64/crt-linux.s
+++ /dev/null
@@ -1,1 +1,0 @@
-	.include	"crt-posix.c"
--- a/src/libcrt/arm64/crt-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/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)
--- a/src/libcrt/i386/crt-linux.s
+++ /dev/null
@@ -1,1 +1,0 @@
-	.include	"crt-posix.s"
--- a/src/libcrt/i386/crt-posix.s
+++ /dev/null
@@ -1,18 +1,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
--- a/src/libcrt/netbsd-ident.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/openbsd-ident.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