| 1 |
Origin: https://github.com/chunkeey/carl9170fw/pull/8 |
| 2 |
From: Bastian Germann <[email protected]> |
| 3 |
Date: Thu, 30 Jul 2026 19:43:25 +0200 |
| 4 |
Subject: [PATCH 3/7] Use -nostdlib because linking with newlib is not |
| 5 |
necessary |
| 6 |
|
| 7 |
The SH-2 compiler emits calls to libgcc runtime helpers for operations the |
| 8 |
CPU lacks native instructions for — e.g. __udivsi3, __ashlsi3, __lshrsi3 for |
| 9 |
integer division and shifts. These live in libgcc, so that has to be |
| 10 |
linked also. |
| 11 |
|
| 12 |
Signed-off-by: Bastian Germann <[email protected]> |
| 13 |
--- |
| 14 |
carlfw/CMakeLists.txt | 2 +- |
| 15 |
minifw/CMakeLists.txt | 2 +- |
| 16 |
2 files changed, 2 insertions(+), 2 deletions(-) |
| 17 |
|
| 18 |
diff --git a/carlfw/CMakeLists.txt b/carlfw/CMakeLists.txt |
| 19 |
index ea7f9ab..2603c01 100644 |
| 20 |
--- a/carlfw/CMakeLists.txt |
| 21 |
+++ b/carlfw/CMakeLists.txt |
| 22 |
@@ -37,7 +37,7 @@ add_executable(carl9170.elf ${carl9170_src}) |
| 23 |
set_target_properties(carl9170.elf PROPERTIES LINKER_LANGUAGE C) |
| 24 |
|
| 25 |
set_target_properties(carl9170.elf PROPERTIES COMPILE_FLAGS "${CARLFW_CFLAGS}") |
| 26 |
-set_target_properties(carl9170.elf PROPERTIES LINK_FLAGS "${CARLFW_CFLAGS} -Wl,-Tcarl9170.lds") |
| 27 |
+set_target_properties(carl9170.elf PROPERTIES LINK_FLAGS "-nostdlib -lgcc ${CARLFW_CFLAGS} -Wl,-Tcarl9170.lds") |
| 28 |
|
| 29 |
add_custom_target(firmware ALL DEPENDS carl9170.elf) |
| 30 |
|
| 31 |
diff --git a/minifw/CMakeLists.txt b/minifw/CMakeLists.txt |
| 32 |
index 30addf4..a1e4d10 100644 |
| 33 |
--- a/minifw/CMakeLists.txt |
| 34 |
+++ b/minifw/CMakeLists.txt |
| 35 |
@@ -12,7 +12,7 @@ add_executable(miniboot.elf miniboot.S) |
| 36 |
|
| 37 |
set_target_properties(miniboot.elf PROPERTIES LINKER_LANGUAGE C) |
| 38 |
|
| 39 |
-set_target_properties(miniboot.elf PROPERTIES LINK_FLAGS "-Tminiboot.lds") |
| 40 |
+set_target_properties(miniboot.elf PROPERTIES LINK_FLAGS "-nostdlib -Tminiboot.lds") |
| 41 |
|
| 42 |
add_custom_target( |
| 43 |
miniboot.fw ALL |