commit b737b36c3b858abef17d4380bed9aeacfdb12d60 parent c7cf28e0306f96e51e32e465255390199fd1ecca Author: Roberto Vargas <roberto.vargas@arm.com> Date: Tue, 22 Jan 2019 14:41:34 +0000 [libc] Update from scc Crts are moved to libc/arch folders as they are part of the libc. Change-Id: Ic19abf1f0beb940e04cf2cb2b1f2faebb482c3d9 Diffstat:
35 files changed, 78 insertions(+), 43 deletions(-)
diff --git a/src/libc/.gitignore b/src/libc/.gitignore @@ -1 +1 @@ -objlst +objlst.mk diff --git a/src/libc/Makefile b/src/libc/Makefile @@ -3,7 +3,6 @@ PROJECTDIR =../.. include $(PROJECTDIR)/scripts/rules.mk include rules.mk -TARGET = $(LIBDIR)/libc.a DIRS = arch\ assert\ ctype\ 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 = $(LIBDIR)/libc.a +LIBC = $(LIBDIR)/libc.a +CRT = $(LIBDIR)/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/libc/arch/amd64/crt-posix.s b/src/libc/arch/amd64/crt-posix.s @@ -0,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 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/target/hosted/crt/crt-amd64-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/target/hosted/crt/crt-arm32-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/target/hosted/crt/crt-arm64-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/target/hosted/crt/crt-netbsd.s b/src/libc/arch/crt-netbsd.s diff --git a/target/hosted/crt/crt-openbsd.s b/src/libc/arch/crt-openbsd.s diff --git a/src/libc/arch/rmode/rcode/Makefile b/src/libc/arch/rmode/rcode/Makefile @@ -9,6 +9,7 @@ OBJS = _Exit.o \ _sys_errlist.o \ _read.o \ getenv.o \ + crt.o \ all: $(OBJS) diff --git a/src/libc/arch/rmode/rcode/crt.s b/src/libc/arch/rmode/rcode/crt.s @@ -0,0 +1,7 @@ + .globl _start + +# dummy crt.s file needed for scc libc Makefile +# This file is not actually used anywhere. + +_start: + ret diff --git a/src/libc/mklst b/src/libc/mklst @@ -5,4 +5,5 @@ set -e rm -f $1 trap 'r=$?;rm -f $$.tmp;exit $r' HUP EXIT QUIT TERM -echo OBJS = `find . -name '*.o'` | sed 's/$/\\/' > $$.tmp && mv $$.tmp $1 +(echo OBJS=\\ + find . -name '*.o' | sed 's/$/\\/') > $$.tmp && mv $$.tmp $1 diff --git a/src/libc/stdio/__putc.c b/src/libc/stdio/__putc.c @@ -1,6 +1,7 @@ #include <errno.h> #include <stdio.h> #include <stdlib.h> + #include "../libc.h" int diff --git a/src/libc/stdio/fclose.c b/src/libc/stdio/fclose.c @@ -1,6 +1,8 @@ #include <stdlib.h> #include <stdio.h> + #include "../syscall.h" +#include "../libc.h" #undef fclose int diff --git a/src/libc/stdio/fseek.c b/src/libc/stdio/fseek.c @@ -1,5 +1,8 @@ #include <stdio.h> + #include "../syscall.h" +#include "../libc.h" + #undef fseek int diff --git a/src/libc/stdio/setvbuf.c b/src/libc/stdio/setvbuf.c @@ -1,6 +1,8 @@ #include <errno.h> #include <stdio.h> #include <stdlib.h> + +#include "../libc.h" #undef setvbuf int diff --git a/target/hosted/Makefile b/target/hosted/Makefile @@ -2,26 +2,25 @@ PROJECTDIR = ../.. include $(PROJECTDIR)/scripts/rules.mk +CRT = $(LIBDIR)/crt.o + ROMOBJS = arch.o \ rom.o \ - crt/crt.o \ romtab.o \ + $(CRT) \ $(DRVDIR)/builtin.o \ $(SRCDIR)/romfw/builtin.o \ RAMOBJS = arch.o \ ram.o \ - crt/crt.o \ ramtab.o \ + $(CRT) \ $(SRCDIR)/ramfw/builtin.o \ TARGET = $(BINDIR)/romfw.elf $(BINDIR)/ramfw.elf -DIRS = crt all: $(TARGET) -crt/crt.o: crt - $(DIRS): FORCE cd $@ && $(MAKE) @@ -38,5 +37,4 @@ $(BINDIR)/ramfw.elf: $(RAMOBJS) $(LIBDEP) $(LD) $(PROJ_LDFLAGS) $(RAMOBJS) $(PROJ_LDLIBS) -o $@ clean: - $(FORALL) rm -f romtab.c ramtab.c diff --git a/target/hosted/crt/Makefile b/target/hosted/crt/Makefile @@ -1,10 +0,0 @@ -.POSIX: -PROJECTDIR=../../.. -include $(PROJECTDIR)/scripts/rules.mk - -OBJS = crt-$(SYS).o crt-$(ABI).o - -all: crt.o - -crt.o: $(OBJS) - $(LD) $(RCODE_LDFLAGS) -r -o $@ $(OBJS) diff --git a/target/hosted/crt/crt-amd64-posix.s b/target/hosted/crt/crt-amd64-posix.s @@ -1,19 +0,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 diff --git a/target/hosted/crt/crt-darwin.s b/target/hosted/crt/crt-darwin.s @@ -1 +0,0 @@ - .file "crt-darwin.s" diff --git a/target/hosted/crt/crt-dragonfly.s b/target/hosted/crt/crt-dragonfly.s @@ -1 +0,0 @@ - .file "crt-dragonfly.s" diff --git a/target/hosted/crt/crt-linux.s b/target/hosted/crt/crt-linux.s @@ -1 +0,0 @@ - .file "crt-linux.s"