summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2021-01-25 21:51:49 +0100
committerCommit Bot <commit-bot@chromium.org>2021-01-26 11:07:52 +0000
commite40faf973d39a9d30d1333a482ee60943dcf8283 (patch)
tree2397661527170b6bab09ab0898bd2717f28c89e2
parent774e4bfab7119909e04ecec6c34b6cc85d979c22 (diff)
downloadchrome-ec-e40faf973d39a9d30d1333a482ee60943dcf8283.tar.gz
zephyr: Use Chrome EC's libgcc implementation over the compiler's
gcc's libgcc is built with a compile time notion of what an architecture's ABI will look like. If that happens to be wrong, you're out of luck. Instead, use our own implementation which, while written in assembly (and as such not as flexible as it could be) is processed with the right set of flags. BUG=b:178363068 BRANCH=none TEST=zephyr boots on kohaku when built with coreboot-sdk. Signed-off-by: Patrick Georgi <pgeorgi@google.com> Change-Id: I6d27bb48478081b6c2ff8927734492282e55e898 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2648666 Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Patrick Georgi <pgeorgi@chromium.org>
-rw-r--r--zephyr/cmake/toolchain/coreboot-sdk/target.cmake8
-rw-r--r--zephyr/shim/src/CMakeLists.txt2
-rw-r--r--zephyr/shim/src/libgcc_arm.S11
3 files changed, 21 insertions, 0 deletions
diff --git a/zephyr/cmake/toolchain/coreboot-sdk/target.cmake b/zephyr/cmake/toolchain/coreboot-sdk/target.cmake
index cf3a6ec736..5f3d86459b 100644
--- a/zephyr/cmake/toolchain/coreboot-sdk/target.cmake
+++ b/zephyr/cmake/toolchain/coreboot-sdk/target.cmake
@@ -29,3 +29,11 @@ set(CMAKE_OBJCOPY "${CROSS_COMPILE}objcopy")
set(CMAKE_OBJDUMP "${CROSS_COMPILE}objdump")
set(CMAKE_RANLIB "${CROSS_COMPILE}ranlib")
set(CMAKE_READELF "${CROSS_COMPILE}readelf")
+
+# On ARM, we don't use libgcc: It's built against a fixed target (e.g.
+# used instruction set, ABI, ISA extensions) and doesn't adapt when
+# compiler flags change any of these assumptions. Use our own mini-libgcc
+# instead.
+if("${ARCH}" STREQUAL "arm")
+ set(no_libgcc True)
+endif()
diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt
index e5101e8dbd..be283829cc 100644
--- a/zephyr/shim/src/CMakeLists.txt
+++ b/zephyr/shim/src/CMakeLists.txt
@@ -7,6 +7,8 @@ zephyr_sources(gpio.c)
zephyr_sources(util.c)
zephyr_sources(crc.c)
+zephyr_sources_ifdef(no_libgcc libgcc_${ARCH}.S)
+
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_ESPI espi.c)
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_FLASH flash.c)
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_HOOKS hooks.c)
diff --git a/zephyr/shim/src/libgcc_arm.S b/zephyr/shim/src/libgcc_arm.S
new file mode 100644
index 0000000000..ffdbefc675
--- /dev/null
+++ b/zephyr/shim/src/libgcc_arm.S
@@ -0,0 +1,11 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "../../third_party/libaeabi-cortexm0/core/cortex-m/ldivmod.S"
+#include "../../third_party/libaeabi-cortexm0/core/cortex-m/uldivmod.S"
+
+exception_panic:
+ mov r0, #3 @ K_ERR_KERNEL_OOPS
+ b z_fatal_error