mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-20 14:16:33 +00:00
🆕 libc新增_start函数,实现main的返回值的捕获
This commit is contained in:
@ -25,7 +25,8 @@ int main()
|
|||||||
// printf("Hello World!\n");
|
// printf("Hello World!\n");
|
||||||
print_ascii_logo();
|
print_ascii_logo();
|
||||||
print_copyright();
|
print_copyright();
|
||||||
exit(0);
|
// exit(0);
|
||||||
while (1)
|
// while (1)
|
||||||
;
|
// ;
|
||||||
|
return 0;
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
OUTPUT_FORMAT("elf64-x86-64","elf64-x86-64","elf64-x86-64")
|
OUTPUT_FORMAT("elf64-x86-64","elf64-x86-64","elf64-x86-64")
|
||||||
OUTPUT_ARCH(i386:x86-64)
|
OUTPUT_ARCH(i386:x86-64)
|
||||||
ENTRY(main)
|
ENTRY(_start)
|
||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,10 @@ CFLAGS += -I .
|
|||||||
|
|
||||||
libc_sub_dirs=math sys
|
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
|
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 \
|
@list='$(libc_sub_dirs)'; for subdir in $$list; do \
|
||||||
|
12
user/libs/libc/sysdeps/x86_64/Makefile
Normal file
12
user/libs/libc/sysdeps/x86_64/Makefile
Normal file
@ -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."
|
10
user/libs/libc/sysdeps/x86_64/elf/start.c
Normal file
10
user/libs/libc/sysdeps/x86_64/elf/start.c
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
extern int main(int, char**);
|
||||||
|
#include<libc/stdio.h>
|
||||||
|
void _start(int argc, char** argv)
|
||||||
|
{
|
||||||
|
printf("before main\n");
|
||||||
|
int retval = main(argc, argv);
|
||||||
|
printf("before exit, code=%d\n", retval);
|
||||||
|
exit(retval);
|
||||||
|
}
|
Reference in New Issue
Block a user