Compare commits
2 Commits
master
...
feature-li
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00666d8f11 | ||
|
|
e96409f3af |
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@@ -45,8 +45,8 @@
|
||||
"cwd": "${fileDirname}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
// "miDebuggerPath": "/opt/homebrew/bin/arm-none-eabi-gdb",
|
||||
"miDebuggerPath": "/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb",
|
||||
"miDebuggerPath": "/opt/homebrew/bin/arm-none-eabi-gdb",
|
||||
// "miDebuggerPath": "/home/zhangzheng/mkrtos-tools/gcc/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gdb",
|
||||
// "miDebuggerPath": "/home/zhangzheng/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gdb",
|
||||
"miDebuggerServerAddress": "127.0.0.1:3333",
|
||||
"MIMode": "gdb",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
CONFIG_KNL_INFO=y
|
||||
CONFIG_KNL_TEXT_ADDR=0x8000000
|
||||
CONFIG_KNL_TEXT_SIZE=0x100000
|
||||
CONFIG_KNL_TEXT_SIZE=0x800000
|
||||
CONFIG_KNL_DATA_ADDR=0x20000000
|
||||
CONFIG_KNL_DATA_SIZE=0x800000
|
||||
CONFIG_KNL_OFFSET=0x2000
|
||||
@@ -109,5 +109,6 @@ CONFIG_RT_USING_PIN=y
|
||||
|
||||
CONFIG_CPU_TYPE="stm32f2"
|
||||
CONFIG_RTT_DIR="./"
|
||||
CONFIG_FLOAT_TYPE="soft"
|
||||
CONFIG_ARCH="cortex-m3"
|
||||
CONFIG_BOARD_NAME="STM32F205"
|
||||
@@ -27,6 +27,6 @@ add_dependencies(mkrtos_img_dump
|
||||
# app_dump
|
||||
shell_dump
|
||||
# fatfs_dump
|
||||
# cpiofs_dump
|
||||
cpiofs_dump
|
||||
# tcc_dump
|
||||
)
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
# export TOOLCHAIN=/home/zhangzheng/mkrtos-tools/gcc/gcc-arm-none-eabi-5_4-2016q3/bin/
|
||||
# export TOOLCHAIN_LIB=/home/zhangzheng/mkrtos-tools/gcc/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv7-m/
|
||||
export TOOLCHAIN=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/bin/
|
||||
export TOOLCHAIN_LIB=/Users/zhangzheng/gcc-arm-none-eabi-10.3-2021.10/lib/gcc/arm-none-eabi/10.3.1/thumb/v7-m/nofp
|
||||
# export TOOLCHAIN=/opt/homebrew/bin/
|
||||
# export TOOLCHAIN_LIB=/opt/homebrew/lib/gcc/arm-none-eabi/13.2.0/
|
||||
export TOOLCHAIN=/Users/zhangzheng/Downloads/gcc-arm-none-eabi-5_4-2016q3/bin/
|
||||
export TOOLCHAIN_LIB=/Users/zhangzheng/Downloads/gcc-arm-none-eabi-5_4-2016q3/lib/gcc/arm-none-eabi/5.4.1/armv7-m/
|
||||
export BOARD=STM32F205
|
||||
|
||||
set -e
|
||||
|
||||
@@ -13,10 +13,13 @@ add_subdirectory(modbus)
|
||||
add_subdirectory(stm32f1_bsp)
|
||||
add_subdirectory(libc_backend)
|
||||
add_subdirectory(mlibc)
|
||||
add_subdirectory(mlibc_shared)
|
||||
add_subdirectory(ldso_shared)
|
||||
add_subdirectory(cpio)
|
||||
add_subdirectory(util)
|
||||
add_subdirectory(mr)
|
||||
add_subdirectory(lwip)
|
||||
add_subdirectory(printf)
|
||||
add_subdirectory(so_lib)
|
||||
add_subdirectory(letter-shell/demo/mkrtos)
|
||||
# add_subdirectory(at_device)
|
||||
|
||||
47
mkrtos_user/lib/ldso_shared/CMakeLists.txt
Normal file
47
mkrtos_user/lib/ldso_shared/CMakeLists.txt
Normal file
@@ -0,0 +1,47 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-e,_dlstart -w -D_XOPEN_SOURCE=700 ")
|
||||
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -w -D_XOPEN_SOURCE=700 ")
|
||||
|
||||
file(GLOB deps
|
||||
../mlibc/ldso/*.c
|
||||
)
|
||||
|
||||
add_library(ld SHARED ${deps})
|
||||
target_link_libraries(
|
||||
ld
|
||||
PUBLIC
|
||||
libc_be
|
||||
muslc
|
||||
)
|
||||
set_target_properties(ld PROPERTIES LINK_FLAGS "-z max-page-size=0x8 -z common-page-size=0x8 \
|
||||
-T ${CMAKE_CURRENT_LIST_DIR}/link.lds \
|
||||
-pie")
|
||||
target_include_directories(
|
||||
ld
|
||||
BEFORE
|
||||
PUBLIC
|
||||
# ${CMAKE_SOURCE_DIR}/user/libc/backend
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys_svr/inc
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/arch/arm/
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/arch/generic
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/obj/src/internal
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/include
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/internal
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/obj/include
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/include
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
ld_dump ALL
|
||||
${CMAKE_OBJDUMP} -s -S libld.so > ${CMAKE_SOURCE_DIR}/build/output/libld.S
|
||||
COMMAND
|
||||
${CMAKE_STRIP} libld.so
|
||||
COMMAND
|
||||
${CMAKE_SIZE} libld.so
|
||||
COMMAND
|
||||
cp libld.so ${CMAKE_SOURCE_DIR}/build/output/cpio/
|
||||
)
|
||||
add_dependencies(ld_dump ld)
|
||||
|
||||
|
||||
0
mkrtos_user/lib/ldso_shared/dummy.c
Normal file
0
mkrtos_user/lib/ldso_shared/dummy.c
Normal file
121
mkrtos_user/lib/ldso_shared/link.lds
Normal file
121
mkrtos_user/lib/ldso_shared/link.lds
Normal file
@@ -0,0 +1,121 @@
|
||||
ENTRY(_start_)
|
||||
PHDRS {
|
||||
mk_text PT_LOAD;
|
||||
mk_data PT_LOAD;
|
||||
}
|
||||
SECTIONS
|
||||
{
|
||||
.text : {
|
||||
. = ALIGN(4);
|
||||
__text_start__ = .;
|
||||
KEEP(*(.first))
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
|
||||
/* .ctors */
|
||||
*crtbegin.o(.ctors)
|
||||
*crtbegin?.o(.ctors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
|
||||
/* .dtors */
|
||||
*crtbegin.o(.dtors)
|
||||
*crtbegin?.o(.dtors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
|
||||
*(SORT(.rodata.*))
|
||||
*(.rodata)
|
||||
|
||||
KEEP(*(.eh_frame*))
|
||||
|
||||
. = ALIGN(4);
|
||||
__rel_start__ = .;
|
||||
*(.rel.data .rel.data.* .rel.plt .rel.gnu.linkonce.d.*)
|
||||
__rel_end__ = .;
|
||||
} :mk_text
|
||||
|
||||
.permissions_table : {
|
||||
. = ALIGN(4);
|
||||
__permissions_table_start__ = .;
|
||||
KEEP(*(.permissions_table))
|
||||
__permissions_table_end__ = .;
|
||||
} :mk_text
|
||||
.rel.plt : {
|
||||
. = ALIGN(4);
|
||||
*(.rel.plt)
|
||||
} :mk_text
|
||||
|
||||
PROVIDE(__ram_size__ = __bss_end__ - __data_start__);
|
||||
.data : {
|
||||
. = ALIGN(4);
|
||||
__data_start__ = .;
|
||||
|
||||
. = ALIGN(4);
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
|
||||
*(vtable)
|
||||
*(.data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
/* preinit data */
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init data */
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* finit data */
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* All data end */
|
||||
__data_end__ = .;
|
||||
} :mk_data
|
||||
.got : {
|
||||
__got_start__ = .;
|
||||
*(.got)
|
||||
__got_end__ = .;
|
||||
} :mk_data
|
||||
|
||||
PROVIDE(__heap_size__ = __heap_end__ - __heap_start__);
|
||||
PROVIDE(__stack_size__ = __stack_end__ - __stack_start__);
|
||||
.bss : {
|
||||
. = ALIGN(4);
|
||||
/* This is used by the startup in order to initialize the .bss secion */
|
||||
__bss_start__ = .;
|
||||
*(.bss)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
__heap_start__ = .;
|
||||
KEEP(*(.bss.heap))
|
||||
__heap_end__ = .;
|
||||
|
||||
. = ALIGN(4);
|
||||
__stack_start__ = .;
|
||||
KEEP(*(.bss.stack))
|
||||
__stack_end__ = .;
|
||||
|
||||
*(.bss.*)
|
||||
/* This is used by the startup in order to initialize the .bss secion */
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
} :mk_data
|
||||
_end = .;
|
||||
}
|
||||
@@ -16,6 +16,7 @@ int ls(int argc, char *agrv[])
|
||||
DIR *dir;
|
||||
struct dirent *ptr;
|
||||
int i;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
return -1;
|
||||
@@ -26,6 +27,7 @@ int ls(int argc, char *agrv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
while ((ptr = readdir(dir)) != NULL)
|
||||
{
|
||||
printf("%s \n", ptr->d_name);
|
||||
|
||||
@@ -1168,7 +1168,11 @@ static void *dl_mmap(size_t n)
|
||||
p = (void *)be_mmap2(0, n, prot, flags, -1, 0);
|
||||
#endif
|
||||
#else
|
||||
#ifdef NO_LITTLE_MODE
|
||||
p = (void *)__syscall(SYS_mmap, 0, n, prot, flags, -1, 0);
|
||||
#else
|
||||
p = (void *)be_mmap2(0, n, prot, flags, -1, 0);
|
||||
#endif
|
||||
#endif
|
||||
return (unsigned long)p > -4096UL ? 0 : p;
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
#if !__ARM_PCS_VFP
|
||||
#include "../fenv.c"
|
||||
#endif
|
||||
@@ -1,38 +0,0 @@
|
||||
#include <fenv.h>
|
||||
|
||||
/* Dummy functions for archs lacking fenv implementation */
|
||||
|
||||
int feclearexcept(int mask)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int feraiseexcept(int mask)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fetestexcept(int mask)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fegetround(void)
|
||||
{
|
||||
return FE_TONEAREST;
|
||||
}
|
||||
|
||||
int __fesetround(int r)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fegetenv(fenv_t *envp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fesetenv(const fenv_t *envp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
/* __fesetround wrapper for arch independent argument check */
|
||||
|
||||
hidden int __fesetround(int);
|
||||
weak hidden int __fesetround(int);
|
||||
|
||||
int fesetround(int r)
|
||||
{
|
||||
|
||||
34
mkrtos_user/lib/mlibc/src/fenv/fetestexcept.c
Normal file
34
mkrtos_user/lib/mlibc/src/fenv/fetestexcept.c
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
|
||||
void fetestexcept(void)
|
||||
{
|
||||
|
||||
}
|
||||
void feraiseexcept(void)
|
||||
{
|
||||
|
||||
}
|
||||
void __a_gettp_cp15(void)
|
||||
{
|
||||
|
||||
}
|
||||
void fegetround(void)
|
||||
{
|
||||
|
||||
}
|
||||
void fesetenv(void)
|
||||
{
|
||||
|
||||
}
|
||||
void fegetenv(void)
|
||||
{
|
||||
|
||||
}
|
||||
void feclearexcept(void)
|
||||
{
|
||||
|
||||
}
|
||||
void __a_cas_dummy(void)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
.syntax unified
|
||||
.text
|
||||
.global dlsym
|
||||
.hidden __dlsym
|
||||
.type dlsym,%function
|
||||
dlsym:
|
||||
mov r2,lr
|
||||
b __dlsym
|
||||
@@ -1,3 +0,0 @@
|
||||
#define __dlsym __dlsym_redir_time64
|
||||
#define dlsym __dlsym_time64
|
||||
#include "dlsym.s"
|
||||
@@ -1,9 +0,0 @@
|
||||
#include <stddef.h>
|
||||
#include <dynlink.h>
|
||||
|
||||
ptrdiff_t __tlsdesc_static()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
weak_alias(__tlsdesc_static, __tlsdesc_dynamic);
|
||||
@@ -10,6 +10,6 @@ double fabs(double x)
|
||||
|
||||
#else
|
||||
|
||||
#include "../fabs.c"
|
||||
#include "../fabs.cx"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,6 @@ float fabsf(float x)
|
||||
|
||||
#else
|
||||
|
||||
#include "../fabsf.c"
|
||||
#include "../fabsf.cx"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,6 @@ double fma(double x, double y, double z)
|
||||
|
||||
#else
|
||||
|
||||
#include "../fma.c"
|
||||
#include "../fma.cx"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,6 @@ float fmaf(float x, float y, float z)
|
||||
|
||||
#else
|
||||
|
||||
#include "../fmaf.c"
|
||||
#include "../fmaf.cx"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,6 @@ double sqrt(double x)
|
||||
|
||||
#else
|
||||
|
||||
#include "../sqrt.c"
|
||||
#include "../sqrt.cx"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,6 @@ float sqrtf(float x)
|
||||
|
||||
#else
|
||||
|
||||
#include "../sqrtf.c"
|
||||
#include "../sqrtf.cx"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
.syntax unified
|
||||
.global vfork
|
||||
.type vfork,%function
|
||||
vfork:
|
||||
mov ip, r7
|
||||
mov r7, 190
|
||||
svc 0
|
||||
mov r7, ip
|
||||
.hidden __syscall_ret
|
||||
b __syscall_ret
|
||||
@@ -1,15 +0,0 @@
|
||||
.syntax unified
|
||||
|
||||
.global __restore
|
||||
.hidden __restore
|
||||
.type __restore,%function
|
||||
__restore:
|
||||
mov r7,#119
|
||||
swi 0x0
|
||||
|
||||
.global __restore_rt
|
||||
.hidden __restore_rt
|
||||
.type __restore_rt,%function
|
||||
__restore_rt:
|
||||
mov r7,#173
|
||||
swi 0x0
|
||||
@@ -1,9 +0,0 @@
|
||||
.syntax unified
|
||||
.text
|
||||
.global __unmapself
|
||||
.type __unmapself,%function
|
||||
__unmapself:
|
||||
mov r7,#91
|
||||
svc 0
|
||||
mov r7,#1
|
||||
svc 0
|
||||
@@ -1,25 +1,22 @@
|
||||
@ .syntax unified
|
||||
@ .text
|
||||
|
||||
@ .global __a_barrier_dummy
|
||||
@ .hidden __a_barrier_dummy
|
||||
@ .type __a_barrier_dummy,%function
|
||||
@ __a_barrier_dummy:
|
||||
@ bx lr
|
||||
|
||||
@ .global __a_barrier_oldkuser
|
||||
@ .hidden __a_barrier_oldkuser
|
||||
@ .type __a_barrier_oldkuser,%function
|
||||
@ __a_barrier_oldkuser:
|
||||
@ push {r0,r1,r2,r3,ip,lr}
|
||||
@ mov r1,r0
|
||||
@ mov r2,sp
|
||||
@ ldr ip,=0xffff0fc0
|
||||
@ bl 1f
|
||||
@ pop {r0,r1,r2,r3,ip,lr}
|
||||
@ bx lr
|
||||
@ 1: bx ip
|
||||
|
||||
.syntax unified
|
||||
.text
|
||||
.global __a_barrier_dummy
|
||||
.hidden __a_barrier_dummy
|
||||
.type __a_barrier_dummy,%function
|
||||
__a_barrier_dummy:
|
||||
bx lr
|
||||
.global __a_barrier_oldkuser
|
||||
.hidden __a_barrier_oldkuser
|
||||
.type __a_barrier_oldkuser,%function
|
||||
__a_barrier_oldkuser:
|
||||
push {r0,r1,r2,r3,ip,lr}
|
||||
mov r1,r0
|
||||
mov r2,sp
|
||||
ldr ip,=0xffff0fc0
|
||||
bl 1f
|
||||
pop {r0,r1,r2,r3,ip,lr}
|
||||
bx lr
|
||||
1: bx ip
|
||||
@ .global __a_barrier_v6
|
||||
@ .hidden __a_barrier_v6
|
||||
@ .type __a_barrier_v6,%function
|
||||
@@ -27,7 +24,6 @@
|
||||
@ .arch armv6t2
|
||||
@ mcr p15,0,r0,c7,c10,5
|
||||
@ bx lr
|
||||
|
||||
@ .global __a_barrier_v7
|
||||
@ .hidden __a_barrier_v7
|
||||
@ .type __a_barrier_v7,%function
|
||||
@@ -35,7 +31,6 @@
|
||||
@ .arch armv7-a
|
||||
@ dmb ish
|
||||
@ bx lr
|
||||
|
||||
@ .global __a_cas_dummy
|
||||
@ .hidden __a_cas_dummy
|
||||
@ .type __a_cas_dummy,%function
|
||||
@@ -45,7 +40,6 @@
|
||||
@ subs r0,r3,r0
|
||||
@ streq r1,[r2]
|
||||
@ bx lr
|
||||
|
||||
@ .global __a_cas_v6
|
||||
@ .hidden __a_cas_v6
|
||||
@ .type __a_cas_v6,%function
|
||||
@@ -60,7 +54,6 @@
|
||||
@ beq 1b
|
||||
@ mcr p15,0,r0,c7,c10,5
|
||||
@ bx lr
|
||||
|
||||
@ .global __a_cas_v7
|
||||
@ .hidden __a_cas_v7
|
||||
@ .type __a_cas_v7,%function
|
||||
@@ -75,32 +68,26 @@
|
||||
@ beq 1b
|
||||
@ dmb ish
|
||||
@ bx lr
|
||||
|
||||
@ .global __a_gettp_cp15
|
||||
@ .hidden __a_gettp_cp15
|
||||
@ .type __a_gettp_cp15,%function
|
||||
@ __a_gettp_cp15:
|
||||
@ mrc p15,0,r0,c13,c0,3
|
||||
@ bx lr
|
||||
|
||||
@ /* Tag this file with minimum ISA level so as not to affect linking. */
|
||||
@ .object_arch armv4t
|
||||
@ .eabi_attribute 6,2
|
||||
|
||||
@ .data
|
||||
@ .align 2
|
||||
|
||||
@ .global __a_barrier_ptr
|
||||
@ .hidden __a_barrier_ptr
|
||||
@ __a_barrier_ptr:
|
||||
@ .word __a_barrier_dummy
|
||||
|
||||
@ .global __a_cas_ptr
|
||||
@ .hidden __a_cas_ptr
|
||||
@ __a_cas_ptr:
|
||||
@ .word __a_cas_dummy
|
||||
|
||||
@ .global __a_gettp_ptr
|
||||
@ .hidden __a_gettp_ptr
|
||||
@ __a_gettp_ptr:
|
||||
@ .word __a_gettp_cp15
|
||||
/* Tag this file with minimum ISA level so as not to affect linking. */
|
||||
.object_arch armv4t
|
||||
.eabi_attribute 6,2
|
||||
.data
|
||||
.align 2
|
||||
.global __a_barrier_ptr
|
||||
.hidden __a_barrier_ptr
|
||||
__a_barrier_ptr:
|
||||
.word __a_barrier_dummy
|
||||
.global __a_cas_ptr
|
||||
.hidden __a_cas_ptr
|
||||
__a_cas_ptr:
|
||||
.word __a_cas_dummy
|
||||
.global __a_gettp_ptr
|
||||
.hidden __a_gettp_ptr
|
||||
__a_gettp_ptr:
|
||||
.word __a_gettp_cp15
|
||||
|
||||
58
mkrtos_user/lib/mlibc_shared/CMakeLists.txt
Normal file
58
mkrtos_user/lib/mlibc_shared/CMakeLists.txt
Normal file
@@ -0,0 +1,58 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-e,_dlstart -w -D_XOPEN_SOURCE=700 ")
|
||||
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -w -D_XOPEN_SOURCE=700 ")
|
||||
|
||||
file(GLOB_RECURSE deps
|
||||
../mlibc/src/*.C
|
||||
../mlibc/src/*.c
|
||||
../mlibc/src/*.S
|
||||
../mlibc/src/*.s
|
||||
# ../mlibc/crt/*.c
|
||||
# ../mlibc/crt/*.C
|
||||
# ../mlibc/crt/*.S
|
||||
# ../mlibc/crt/*.s
|
||||
../mlibc/ldso/*.c
|
||||
)
|
||||
# list(REMOVE_ITEM deps ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/crt/start_init.S)
|
||||
# list(REMOVE_ITEM deps ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/crt/start.S)
|
||||
# list(REMOVE_ITEM deps ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/crt/start_tiny.S)
|
||||
# list(REMOVE_ITEM deps ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/ldso/dlstart.c)
|
||||
# list(REMOVE_ITEM deps ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/ldso/dynlink.c)
|
||||
# list(REMOVE_ITEM deps ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/crt/rcrt1.c)
|
||||
# list(REMOVE_ITEM deps ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/fcntl/posix_fadvise.c)
|
||||
# list(REMOVE_ITEM deps ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/math/fabs.c)
|
||||
# list(REMOVE_ITEM deps ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/math/fabsf.c)
|
||||
# list(REMOVE_ITEM deps ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/math/fabsf.c)
|
||||
# list(REMOVE_ITEM deps ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/math/fma.c)
|
||||
# list(REMOVE_ITEM deps ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/math/fmaf.c)
|
||||
# list(REMOVE_ITEM deps ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/math/sqrt.c)
|
||||
# list(REMOVE_ITEM deps ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/math/sqrtf.c)
|
||||
# list(REMOVE_ITEM deps ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/ldso/arm/dlsym.s)
|
||||
|
||||
# add_library(start_init ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/crt/start_init.S)
|
||||
# add_library(start ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/crt/start.S)
|
||||
# add_library(start_tiny ${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/crt/start_tiny.S)
|
||||
add_library(c SHARED ${deps})
|
||||
target_link_libraries(
|
||||
c
|
||||
PUBLIC
|
||||
libc_be
|
||||
sys_svr
|
||||
${GCC_LIB_PATH}/libgcc.a
|
||||
)
|
||||
set_target_properties(c PROPERTIES LINK_FLAGS "-pie ")
|
||||
target_include_directories(
|
||||
c
|
||||
BEFORE
|
||||
PUBLIC
|
||||
# ${CMAKE_SOURCE_DIR}/user/libc/backend
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys_svr/inc
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/arch/arm/
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/arch/generic
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/obj/src/internal
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/include
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/internal
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/obj/include
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/include
|
||||
)
|
||||
0
mkrtos_user/lib/mlibc_shared/dummy.c
Normal file
0
mkrtos_user/lib/mlibc_shared/dummy.c
Normal file
39
mkrtos_user/lib/so_lib/CMakeLists.txt
Normal file
39
mkrtos_user/lib/so_lib/CMakeLists.txt
Normal file
@@ -0,0 +1,39 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --shared " )
|
||||
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} ")
|
||||
|
||||
file(GLOB_RECURSE deps *.c *.S)
|
||||
add_library(
|
||||
so_list
|
||||
SHARED
|
||||
${deps}
|
||||
)
|
||||
target_include_directories(
|
||||
so_list
|
||||
PUBLIC
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/so_list/inc
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/sys/inc
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/cpio
|
||||
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/arch/arm/
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/arch/generic
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/obj/src/internal
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/include
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/src/internal
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/obj/include
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/mlibc/include
|
||||
)
|
||||
target_link_libraries(
|
||||
so_list
|
||||
PUBLIC
|
||||
sys
|
||||
muslc
|
||||
cpio
|
||||
)
|
||||
set_target_properties(so_list PROPERTIES LINK_FLAGS "-pie ")
|
||||
add_dependencies(so_list sys)
|
||||
add_dependencies(so_list muslc)
|
||||
|
||||
|
||||
7
mkrtos_user/lib/so_lib/src/test.c
Normal file
7
mkrtos_user/lib/so_lib/src/test.c
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
int a = 1234;
|
||||
|
||||
int i(int b)
|
||||
{
|
||||
return a;
|
||||
}
|
||||
@@ -104,7 +104,22 @@ static void *app_stack_push_array(obj_handler_t task_obj, umword_t **stack, uint
|
||||
|
||||
return *stack;
|
||||
}
|
||||
#include <elf.h>
|
||||
typedef struct exec_app_info {
|
||||
mword_t data_size;
|
||||
mword_t entry;
|
||||
mword_t stack_offset;
|
||||
} exec_app_info_t;
|
||||
int app_elf_load(void *data)
|
||||
{
|
||||
Elf32_Ehdr *ehdr = data;
|
||||
|
||||
if (!(ehdr->e_ident[0] == 'E' && ehdr->e_ident[1] == 'L' && ehdr->e_ident[2] == 'F')) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* @brief 加载并执行一个app
|
||||
*
|
||||
|
||||
@@ -2,9 +2,7 @@ cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
file(GLOB_RECURSE deps *.c *.S)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_STDPERIPH_DRIVER=1 \
|
||||
")
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_STDPERIPH_DRIVER=1 ")
|
||||
|
||||
add_executable(hello.elf
|
||||
${deps}
|
||||
@@ -12,12 +10,17 @@ add_executable(hello.elf
|
||||
target_link_libraries(hello.elf
|
||||
PUBLIC
|
||||
start_tiny
|
||||
printf
|
||||
muslc
|
||||
# printf
|
||||
sys
|
||||
sys_util
|
||||
sys_svr
|
||||
${GCC_LIB_PATH}/libgcc.a
|
||||
|
||||
)
|
||||
target_link_libraries(hello.elf
|
||||
PUBLIC
|
||||
-Bdynamic
|
||||
c
|
||||
)
|
||||
target_include_directories(
|
||||
hello.elf
|
||||
@@ -40,12 +43,9 @@ target_include_directories(
|
||||
|
||||
${CMAKE_SOURCE_DIR}/mkrtos_user/lib/printf/src/printf
|
||||
)
|
||||
add_dependencies(hello.elf
|
||||
muslc
|
||||
printf
|
||||
)
|
||||
set_target_properties(hello.elf PROPERTIES LINK_FLAGS
|
||||
"-T ${CMAKE_CURRENT_LIST_DIR}/link.lds -pie --gc-section -no-dynamic-linker "
|
||||
"-z max-page-size=0x8 -z common-page-size=0x8 \
|
||||
-T ${CMAKE_CURRENT_LIST_DIR}/link.lds -pie --gc-section -no-dynamic-linker "
|
||||
#--no-warn-rwx-segments
|
||||
)
|
||||
add_custom_target(
|
||||
@@ -55,6 +55,8 @@ add_custom_target(
|
||||
COMMAND
|
||||
${CMAKE_READELF} -a hello.elf > ${CMAKE_SOURCE_DIR}/build/output/hello.txt
|
||||
COMMAND
|
||||
${CMAKE_STRIP} hello.elf
|
||||
COMMAND
|
||||
${CMAKE_OBJCOPY} -O binary -S hello.elf hello.bin
|
||||
COMMAND
|
||||
${CMAKE_SIZE} hello.elf
|
||||
@@ -67,10 +69,10 @@ add_custom_target(
|
||||
)
|
||||
|
||||
add_dependencies(hello_dump hello.elf)
|
||||
add_dependencies(hello_dump sys)
|
||||
add_dependencies(hello_dump sys_util)
|
||||
add_dependencies(hello_dump mr)
|
||||
add_dependencies(hello_dump sys_svr)
|
||||
add_dependencies(hello_dump start)
|
||||
add_dependencies(hello_dump muslc)
|
||||
add_dependencies(hello.elf sys)
|
||||
add_dependencies(hello.elf sys_util)
|
||||
add_dependencies(hello.elf mr)
|
||||
add_dependencies(hello.elf sys_svr)
|
||||
add_dependencies(hello.elf start)
|
||||
add_dependencies(hello.elf c)
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
ENTRY(_start_)
|
||||
|
||||
PHDRS {
|
||||
mk_text PT_LOAD;
|
||||
mk_data PT_LOAD;
|
||||
}
|
||||
SECTIONS
|
||||
{
|
||||
.text : {
|
||||
@@ -33,32 +36,26 @@ SECTIONS
|
||||
|
||||
. = ALIGN(4);
|
||||
__rel_start__ = .;
|
||||
*(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
|
||||
*(.rel.data .rel.data.* .rel.plt .rel.gnu.linkonce.d.*)
|
||||
__rel_end__ = .;
|
||||
}
|
||||
.ARM.exidx : {
|
||||
. = ALIGN(4);
|
||||
__exdix_start = .;
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
/* This is used by the startup in order to initialize the .data secion */
|
||||
__exdix_end = .;
|
||||
}
|
||||
} :mk_text
|
||||
|
||||
.permissions_table : {
|
||||
. = ALIGN(4);
|
||||
__permissions_table_start__ = .;
|
||||
KEEP(*(.permissions_table))
|
||||
__permissions_table_end__ = .;
|
||||
}
|
||||
|
||||
|
||||
} :mk_text
|
||||
.rel.plt : {
|
||||
. = ALIGN(4);
|
||||
*(.rel.plt)
|
||||
} :mk_text
|
||||
|
||||
PROVIDE(__ram_size__ = __bss_end__ - __data_start__);
|
||||
.data : {
|
||||
. = ALIGN(4);
|
||||
__data_start__ = .;
|
||||
__got_start__ = .;
|
||||
*(.got)
|
||||
__got_end__ = .;
|
||||
|
||||
. = ALIGN(4);
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
@@ -89,7 +86,12 @@ SECTIONS
|
||||
. = ALIGN(4);
|
||||
/* All data end */
|
||||
__data_end__ = .;
|
||||
}
|
||||
} :mk_data
|
||||
.got : {
|
||||
__got_start__ = .;
|
||||
*(.got)
|
||||
__got_end__ = .;
|
||||
} :mk_data
|
||||
|
||||
PROVIDE(__heap_size__ = __heap_end__ - __heap_start__);
|
||||
PROVIDE(__stack_size__ = __stack_end__ - __stack_start__);
|
||||
@@ -114,6 +116,6 @@ SECTIONS
|
||||
/* This is used by the startup in order to initialize the .bss secion */
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
}
|
||||
} :mk_data
|
||||
_end = .;
|
||||
}
|
||||
|
||||
@@ -1,22 +1,34 @@
|
||||
|
||||
#include <printf.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
int main(int argc, char *args[])
|
||||
{
|
||||
mk_printf("print test0.\n");
|
||||
mk_printf("print test1.\n");
|
||||
mk_printf("print test2.\n");
|
||||
printf("print test0.\n");
|
||||
printf("print test1.\n");
|
||||
printf("print test2.\n");
|
||||
printf("print test2.\n");
|
||||
printf("print test2.\n");
|
||||
printf("print test2.\n");
|
||||
printf("print test2.\n");
|
||||
printf("print test2.\n");
|
||||
printf("print test2.\n");
|
||||
printf("print test2.\n");
|
||||
printf("print test2.\n");
|
||||
printf("print test2.\n");
|
||||
printf("print test2.\n");
|
||||
printf("print test2.\n");
|
||||
printf("print test2.\n");
|
||||
float a = 1.1;
|
||||
float b = 1.2;
|
||||
float c;
|
||||
|
||||
// fprintf(stdout, "123");
|
||||
while (1)
|
||||
{
|
||||
c = a + b;
|
||||
// mk_printf("%c %d %f\n", 'a', 1234, 1.1);
|
||||
// c = a + b;
|
||||
printf("%c %d %f\n", 'a', 1234, 1.1);
|
||||
// mk_printf("%c %d %lf\n", 'a', 1234, a * b);
|
||||
mk_printf("%c %d %d\n", 'a', 1234, (int)1.1);
|
||||
mk_printf("%c %d %d\n", 'a', 1234, (int)(a * b));
|
||||
// mk_printf("%c %d %d\n", 'a', 1234, (int)1.1);
|
||||
// mk_printf("%c %d %d\n", 'a', 1234, (int)(a * b));
|
||||
sleep(1);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*/
|
||||
#define HEAP_SIZE 1024
|
||||
#define STACK_SIZE (1024 + 256)
|
||||
#define HEAP_SIZE 2048
|
||||
#define STACK_SIZE (1024 + 512)
|
||||
|
||||
#if defined(__CC_ARM)
|
||||
#define HEAP_ATTR SECTION("HEAP") __attribute__((zero_init))
|
||||
|
||||
@@ -28,7 +28,7 @@ message(=======${CONFIG_CPU_TYPE})
|
||||
# -mfloat-abi=soft -u _printf_float -lc -lrdimon
|
||||
#-mfpu=fpv5-sp-d16
|
||||
set(CMAKE_C_FLAGS "-mcpu=${CONFIG_ARCH} -O0 -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -mno-thumb-interwork -D=MKRTOS \
|
||||
-std=gnu11 -ffunction-sections -fdata-sections -fno-builtin -u _printf_float \
|
||||
-std=gnu11 -ffunction-sections -fdata-sections -fno-builtin -u=_printf_float \
|
||||
-nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker \
|
||||
-fno-stack-protector -Wl,--gc-sections \
|
||||
-include ${CMAKE_SOURCE_DIR}/build/autoconf.h \
|
||||
@@ -36,13 +36,13 @@ set(CMAKE_C_FLAGS "-mcpu=${CONFIG_ARCH} -O0 -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE}
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-mcpu=${CONFIG_ARCH} -O2 -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -mno-thumb-interwork -D=MKRTOS -std=c++11 \
|
||||
-fmessage-length=0 -Xlinker --print-map -Wall -W -fno-stack-protector -g \
|
||||
-u _printf_float \
|
||||
-u=_printf_float \
|
||||
-ffunction-sections -fdata-sections -fno-builtin -nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker \
|
||||
-include ${CMAKE_SOURCE_DIR}/build/autoconf.h \
|
||||
" CACHE STRING "" FORCE)
|
||||
|
||||
set(CMAKE_ASM_FLAGS "-mcpu=${CONFIG_ARCH} -O2 -g3 -mfloat-abi=${CONFIG_FLOAT_TYPE} -mthumb -mno-thumb-interwork -D=MKRTOS \
|
||||
-u _printf_float -std=gnu11 -ffunction-sections -fdata-sections -fno-builtin \
|
||||
-u=_printf_float -std=gnu11 -ffunction-sections -fdata-sections -fno-builtin \
|
||||
-nostartfiles -nodefaultlibs -nostdlib -nostdinc -Xlinker -fno-stack-protector \
|
||||
-include ${CMAKE_SOURCE_DIR}/build/autoconf.h \
|
||||
" CACHE STRING "" FORCE)
|
||||
|
||||
Reference in New Issue
Block a user