From 624077b98c7344284f9ec4ff1a534e210c45909b Mon Sep 17 00:00:00 2001 From: Zihao Yu Date: Wed, 24 May 2023 14:29:16 +0800 Subject: [PATCH] bsp,abstract-machine: fix the order of .rti_fn* sections * now initcall can work successfully, and msh can show prompt --- bsp/abstract-machine/Makefile | 1 + bsp/abstract-machine/extra.ld | 19 +++++++++++++++++++ bsp/abstract-machine/src/init.c | 3 +++ bsp/abstract-machine/src/libc.c | 9 +++++++++ 4 files changed, 32 insertions(+) create mode 100644 bsp/abstract-machine/extra.ld create mode 100644 bsp/abstract-machine/src/libc.c diff --git a/bsp/abstract-machine/Makefile b/bsp/abstract-machine/Makefile index 9818028..eb227e9 100644 --- a/bsp/abstract-machine/Makefile +++ b/bsp/abstract-machine/Makefile @@ -6,6 +6,7 @@ RTCONFIG_H = rtconfig.h NAME = rtthread SRCS = $(shell find src -name "*.c") CFLAGS += -DHAVE_CCONFIG_H -D__RTTHREAD__ +LDFLAGS += extra.ld -include $(FILE_MK) include $(AM_HOME)/Makefile diff --git a/bsp/abstract-machine/extra.ld b/bsp/abstract-machine/extra.ld new file mode 100644 index 0000000..38e4e13 --- /dev/null +++ b/bsp/abstract-machine/extra.ld @@ -0,0 +1,19 @@ +SECTIONS { + . = ALIGN(8); + + .myextra : { + /* section information for initial. */ + . = ALIGN(8); + __rt_init_start = .; + KEEP(*(SORT(.rti_fn*))) + __rt_init_end = .; + . = ALIGN(8); + + __rt_utest_tc_tab_start = .; + KEEP(*(UtestTcTab)) + __rt_utest_tc_tab_end = .; + } + end = .; + _end = .; + _heap_start = ALIGN(0x1000); +} diff --git a/bsp/abstract-machine/src/init.c b/bsp/abstract-machine/src/init.c index 26fa5b9..3121a5c 100644 --- a/bsp/abstract-machine/src/init.c +++ b/bsp/abstract-machine/src/init.c @@ -1,6 +1,9 @@ #include #include +void *__fsymtab_start = NULL; +void *__fsymtab_end = NULL; + #define RT_HW_HEAP_BEGIN heap.start #define RT_HW_HEAP_END heap.end diff --git a/bsp/abstract-machine/src/libc.c b/bsp/abstract-machine/src/libc.c new file mode 100644 index 0000000..a85f3b4 --- /dev/null +++ b/bsp/abstract-machine/src/libc.c @@ -0,0 +1,9 @@ +#include + +char *strchr(const char *s, int c) { + assert(0); +} + +char *strstr(const char *haystack, const char *needle) { + assert(0); +}