Origin: https://github.com/chunkeey/carl9170fw/pull/8 From: Bastian Germann Date: Thu, 30 Jul 2026 19:43:25 +0200 Subject: [PATCH 3/7] Use -nostdlib because linking with newlib is not necessary The SH-2 compiler emits calls to libgcc runtime helpers for operations the CPU lacks native instructions for — e.g. __udivsi3, __ashlsi3, __lshrsi3 for integer division and shifts. These live in libgcc, so that has to be linked also. Signed-off-by: Bastian Germann --- carlfw/CMakeLists.txt | 2 +- minifw/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/carlfw/CMakeLists.txt b/carlfw/CMakeLists.txt index ea7f9ab..2603c01 100644 --- a/carlfw/CMakeLists.txt +++ b/carlfw/CMakeLists.txt @@ -37,7 +37,7 @@ add_executable(carl9170.elf ${carl9170_src}) set_target_properties(carl9170.elf PROPERTIES LINKER_LANGUAGE C) set_target_properties(carl9170.elf PROPERTIES COMPILE_FLAGS "${CARLFW_CFLAGS}") -set_target_properties(carl9170.elf PROPERTIES LINK_FLAGS "${CARLFW_CFLAGS} -Wl,-Tcarl9170.lds") +set_target_properties(carl9170.elf PROPERTIES LINK_FLAGS "-nostdlib -lgcc ${CARLFW_CFLAGS} -Wl,-Tcarl9170.lds") add_custom_target(firmware ALL DEPENDS carl9170.elf) diff --git a/minifw/CMakeLists.txt b/minifw/CMakeLists.txt index 30addf4..a1e4d10 100644 --- a/minifw/CMakeLists.txt +++ b/minifw/CMakeLists.txt @@ -12,7 +12,7 @@ add_executable(miniboot.elf miniboot.S) set_target_properties(miniboot.elf PROPERTIES LINKER_LANGUAGE C) -set_target_properties(miniboot.elf PROPERTIES LINK_FLAGS "-Tminiboot.lds") +set_target_properties(miniboot.elf PROPERTIES LINK_FLAGS "-nostdlib -Tminiboot.lds") add_custom_target( miniboot.fw ALL