From 07b23ecbb1b1845bb166bc35368493a26ab8be82 Mon Sep 17 00:00:00 2001 From: Shell Date: Fri, 20 Oct 2023 13:27:38 +0800 Subject: [PATCH] [libcpu] fix symbol of kernel entry point (#8159) Signed-off-by: Shell --- bsp/qemu-virt64-aarch64/rtconfig.py | 2 +- libcpu/aarch64/SConscript | 2 ++ libcpu/aarch64/common/mmu.c | 4 ++-- libcpu/aarch64/cortex-a/entry_point.S | 8 ++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bsp/qemu-virt64-aarch64/rtconfig.py b/bsp/qemu-virt64-aarch64/rtconfig.py index 98d1a38cec..c363513a18 100644 --- a/bsp/qemu-virt64-aarch64/rtconfig.py +++ b/bsp/qemu-virt64-aarch64/rtconfig.py @@ -30,7 +30,7 @@ if PLATFORM == 'gcc': CXXFLAGS= DEVICE + CFPFLAGS + ' -Wall -fdiagnostics-color=always' CFLAGS = DEVICE + CFPFLAGS + ' -Wall -Wno-cpp -std=gnu99 -fdiagnostics-color=always' AFLAGS = ' -c' + AFPFLAGS + ' -x assembler-with-cpp' - LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,system_vectors -T link.lds' + ' -lsupc++ -lgcc -static' + LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,system_vectors -T link.lds' + ' -lsupc++ -lgcc -static' CPATH = '' LPATH = '' diff --git a/libcpu/aarch64/SConscript b/libcpu/aarch64/SConscript index d726d2d1f2..52de02a27b 100644 --- a/libcpu/aarch64/SConscript +++ b/libcpu/aarch64/SConscript @@ -12,6 +12,8 @@ bsp_path = Dir('#').abspath if not os.path.exists(bsp_path + "/link.lds"): Env['LINKFLAGS'] = Env['LINKFLAGS'].replace('link.lds', cwd + "/link.lds") + # fix the linker with crtx.o + Env['LINKFLAGS'] += ' -nostartfiles' Preprocessing("link.lds.S", ".lds", CPPPATH=[bsp_path]) # add common code files diff --git a/libcpu/aarch64/common/mmu.c b/libcpu/aarch64/common/mmu.c index 1426dc7fef..82bdce6820 100644 --- a/libcpu/aarch64/common/mmu.c +++ b/libcpu/aarch64/common/mmu.c @@ -803,8 +803,8 @@ void rt_hw_mem_setup_early(unsigned long *tbl0, unsigned long *tbl1, #ifdef RT_USING_SMART unsigned long va = KERNEL_VADDR_START; #else - extern unsigned char __start; - unsigned long va = (unsigned long) &__start; + extern unsigned char _start; + unsigned long va = (unsigned long) &_start; va = RT_ALIGN_DOWN(va, 0x200000); #endif diff --git a/libcpu/aarch64/cortex-a/entry_point.S b/libcpu/aarch64/cortex-a/entry_point.S index 3c79fdebbc..53c2920355 100644 --- a/libcpu/aarch64/cortex-a/entry_point.S +++ b/libcpu/aarch64/cortex-a/entry_point.S @@ -38,8 +38,8 @@ boot_arg1 .req x23 boot_arg2 .req x24 stack_top .req x25 -.global __start -__start: +.global _start +_start: /* * Boot CPU general-purpose register settings: * x0 = physical address of device tree blob (dtb) in system RAM. @@ -165,8 +165,8 @@ __start: dsb sy #ifdef RT_USING_SMART - ldr x2, =__start - GET_PHY x3, __start + ldr x2, =_start + GET_PHY x3, _start sub x3, x3, x2 #else mov x3,0