diff --git a/user/apps/about/about.c b/user/apps/about/about.c index c4dc2ca2c..be2e16097 100644 --- a/user/apps/about/about.c +++ b/user/apps/about/about.c @@ -25,7 +25,8 @@ int main() // printf("Hello World!\n"); print_ascii_logo(); print_copyright(); - exit(0); - while (1) - ; + // exit(0); + // while (1) + // ; + return 0; } \ No newline at end of file diff --git a/user/apps/about/about.lds b/user/apps/about/about.lds index 0074c8a27..c9f7f159a 100644 --- a/user/apps/about/about.lds +++ b/user/apps/about/about.lds @@ -1,7 +1,7 @@ OUTPUT_FORMAT("elf64-x86-64","elf64-x86-64","elf64-x86-64") OUTPUT_ARCH(i386:x86-64) -ENTRY(main) +ENTRY(_start) SECTIONS { diff --git a/user/libs/libc/Makefile b/user/libs/libc/Makefile index 1b7b1541b..d56b6314c 100644 --- a/user/libs/libc/Makefile +++ b/user/libs/libc/Makefile @@ -4,6 +4,10 @@ CFLAGS += -I . libc_sub_dirs=math sys +ifeq ($(ARCH), __x86_64__) +libc_sub_dirs += sysdeps/x86_64 +endif + libc: unistd.o fcntl.o malloc.o errno.o printf.o stdlib.o ctype.o string.o dirent.o @list='$(libc_sub_dirs)'; for subdir in $$list; do \ diff --git a/user/libs/libc/sysdeps/x86_64/Makefile b/user/libs/libc/sysdeps/x86_64/Makefile new file mode 100644 index 000000000..a66a3ef6a --- /dev/null +++ b/user/libs/libc/sysdeps/x86_64/Makefile @@ -0,0 +1,12 @@ + + +all: start.o + +ifeq ($(ARCH), __x86_64__) +start.o: + gcc $(CFLAGS) -c elf/start.c -o elf/start.o +endif + +clean: + + echo "Done." \ No newline at end of file diff --git a/user/libs/libc/sysdeps/x86_64/elf/start.c b/user/libs/libc/sysdeps/x86_64/elf/start.c new file mode 100644 index 000000000..c9c270f65 --- /dev/null +++ b/user/libs/libc/sysdeps/x86_64/elf/start.c @@ -0,0 +1,10 @@ + +extern int main(int, char**); +#include +void _start(int argc, char** argv) +{ + printf("before main\n"); + int retval = main(argc, argv); + printf("before exit, code=%d\n", retval); + exit(retval); +} \ No newline at end of file