diff --git a/kernel/main.c b/kernel/main.c index e0806dec903a57a731fc6d24b6c47349ad53ace3..ba5f2df314f7bf2dbecdb7d67b58fb5f3b6495e3 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -170,7 +170,7 @@ static void run_sh() { int pid; if (!(pid=fork())) { printf("read to start shell\n"); - execve("/usr/bin/ls", argv,envp); + execve("/tmp/et", argv,envp); } } diff --git a/tools/tcc/Makefile b/tools/tcc/Makefile index 2bd6065b16d9f7d1c5166e18d27889b3b3462d9a..8d0e1c42b14d540052dbabc5cf65568d85af85e3 100644 --- a/tools/tcc/Makefile +++ b/tools/tcc/Makefile @@ -1,7 +1,7 @@ AR := ar GCC := gcc CCFLAG := -m32 -I./include -ffreestanding -fno-pic -Wall -fomit-frame-pointer -fno-stack-protector -c -OBJS := write.o errno.o printf.o vsprintf.o string.o +OBJS := write.o errno.o printf.o vsprintf.o string.o crt0.o libc.a: $(OBJS) $(AR) rcs $@ $^ @@ -22,6 +22,9 @@ vsprintf.o: runtime/vsprintf.c string.o: runtime/string.c $(GCC) $(CCFLAG) -o $@ $< +crt0.o: runtime/crt0.S + $(GCC) $(CCFLAG) -o $@ $< + clean: -rm *.o -rm libc.a diff --git a/tools/tcc/crt0.S b/tools/tcc/runtime/crt0.S similarity index 79% rename from tools/tcc/crt0.S rename to tools/tcc/runtime/crt0.S index bd5e46dc3b5e65649bdcf4c3691444e23823effa..d9973f184bd3698c7e76f7be193a76730e197ccd 100644 --- a/tools/tcc/crt0.S +++ b/tools/tcc/runtime/crt0.S @@ -1,5 +1,4 @@ .code32 - .text .globl _environ, _start @@ -8,7 +7,9 @@ _start: movl 8(%esp),%eax movl %eax,_environ call main - ret + pushl %eax +1: call exit + jmp 1b .data diff --git a/tools/tcc/runtime/write.c b/tools/tcc/runtime/write.c index 2613f17e37e2a26064bd13520d05c3dc0d147081..67b09f7a948f19b0147e8a5e2b36d9e45c55c946 100644 --- a/tools/tcc/runtime/write.c +++ b/tools/tcc/runtime/write.c @@ -2,3 +2,4 @@ #include _syscall3(int,write,int,fd,const char *,buf,off_t,count) +_syscall1(int,exit,int,fd); diff --git a/tools/tcc/test/test.c b/tools/tcc/test/test.c index 6248279c8c1327afdf48467297e23925a4ec06af..ccc6757dbf9123a2de5eaabcaf3129e9f6d038dd 100644 --- a/tools/tcc/test/test.c +++ b/tools/tcc/test/test.c @@ -2,14 +2,15 @@ int main(int argc, char** argv, char** envp) { printf("argc is %d\n", argc); + printf("argv:\n"); while (*argv) { - write(1, *argv, 3); + printf("%s\n", *argv); argv++; } - write(1, "envp\n", 5); + printf("envp:\n"); while (*envp) { - write(1, *envp, 4); + printf("%s\n", *envp); envp++; }