From e71f9867e209400ee6c6afab88a94e9e51c1ced4 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Sun, 7 Nov 2021 18:05:33 +0100 Subject: [PATCH] support for shared libgcc in vhex --- CMakeLists.txt | 5 +++-- cmake/toolchain-vhex.cmake | 27 ++++++++++++++++++++++++++ src/libc/signal/raise.c | 4 ---- src/libc/stdlib/target/vhex-sh/_Exit.S | 12 ++++++++++++ 4 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 cmake/toolchain-vhex.cmake create mode 100644 src/libc/stdlib/target/vhex-sh/_Exit.S diff --git a/CMakeLists.txt b/CMakeLists.txt index c341883..b7598d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,14 +20,14 @@ if(FXLIBC_TARGET STREQUAL vhex-sh) list(APPEND TARGET_FOLDERS vhex-generic sh-generic) set(FXLIBC_ARCH sh) add_definitions(-D__SUPPORT_VHEX_KERNEL) - set(FXLIBC_SHARED ON) + # set(FXLIBC_SHARED ON) endif() if(FXLIBC_TARGET STREQUAL vhex-x86) list(APPEND TARGET_FOLDERS vhex-generic x86-generic) set(FXLIBC_ARCH x86) add_definitions(-D__SUPPORT_VHEX_KERNEL) - set(FXLIBC_SHARED ON) + # set(FXLIBC_SHARED ON) # TODO: Maybe add -nostdinc (but that removes compiler-provided headers like # ), or use another compiler than the system one? endif() @@ -206,6 +206,7 @@ if(vhex-sh IN_LIST TARGET_FOLDERS) list(APPEND SOURCES src/libc/signal/target/vhex-sh/kill.S src/libc/signal/target/vhex-sh/signal.S + src/libc/stdlib/target/vhex-sh/_Exit.S src/libc/stdlib/target/vhex-sh/free.S src/libc/stdlib/target/vhex-sh/malloc.S src/libc/stdlib/target/vhex-sh/realloc.S diff --git a/cmake/toolchain-vhex.cmake b/cmake/toolchain-vhex.cmake new file mode 100644 index 0000000..a7de855 --- /dev/null +++ b/cmake/toolchain-vhex.cmake @@ -0,0 +1,27 @@ +# Vhex toolchain file for chad Casio graphing calculators + +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_VERSION 1) +set(CMAKE_SYSTEM_PROCESSOR sh) + +set(CMAKE_C_COMPILER sh-elf-vhex-gcc) +set(CMAKE_CXX_COMPILER sh-elf-vhex-g++) + +set(CMAKE_C_FLAGS_INIT "") +set(CMAKE_CXX_FLAGS_INIT "") + +add_compile_options(-nostdlib) +add_link_options(-nostdlib) +link_libraries(-lgcc) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + +# Determine compiler install path +execute_process( + COMMAND ${CMAKE_C_COMPILER} --print-file-name=. + OUTPUT_VARIABLE FXSDK_COMPILER_INSTALL + OUTPUT_STRIP_TRAILING_WHITESPACE +) diff --git a/src/libc/signal/raise.c b/src/libc/signal/raise.c index 573c654..8878b1f 100644 --- a/src/libc/signal/raise.c +++ b/src/libc/signal/raise.c @@ -3,8 +3,6 @@ #include #include "signal_p.h" -#ifndef __SUPPORT_VHEX_KERNEL - int raise(int sig) { if(sig < 0 || sig >= _NSIG) @@ -31,5 +29,3 @@ int raise(int sig) signal(sig, handler); return 0; } - -#endif /*! __SUPPORT_VHEX_KERNEL*/ diff --git a/src/libc/stdlib/target/vhex-sh/_Exit.S b/src/libc/stdlib/target/vhex-sh/_Exit.S new file mode 100644 index 0000000..931d81f --- /dev/null +++ b/src/libc/stdlib/target/vhex-sh/_Exit.S @@ -0,0 +1,12 @@ +#include +.text +.global __Exit +.type __Exit, @function + + +.align 2 +__Exit: + trapa #__NR_exit + rts + nop +.end