summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2022-08-25 10:35:39 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-10 17:49:07 +0000
commitb6826411d184bc52d2afe9f4a5d369baca8e68f1 (patch)
tree284d76caab6f2b2a06fe94a3e7cb4700874abc66
parent85090d0d30c8569de4709f52580ce98dbb0217c6 (diff)
downloadchrome-ec-b6826411d184bc52d2afe9f4a5d369baca8e68f1.tar.gz
core/cortex-m: Disable C++ exceptions
__exidx_start and __exidx_end indicate the start and end of the exception index table, which is described in more detail in "Exception Handling ABI for ARM Architecture": https://github.com/ARM-software/abi-aa/blob/60a8eb8c55e999d74dac5e368fc9d7e36e38dda4/ehabi32/ehabi32.rst#54the-object-producer-interface __exidx_start and __exidx_end are referenced in libunwind, so they need to be defined. If __exidx_start and __exidx_end are equal, libunwind will interpret the exception index table as empty, which means the exception can not be caught, and std::terminate() is called, which is what we want. The test in https://crrev.com/c/3932262 verifies this behavior. See https://github.com/llvm/llvm-project/blob/b3c5da73b71908c59b12ef0feadfde56bad222b5/libunwind/src/AddressSpace.hpp#L515-L522 BRANCH=none BUG=b:234181908 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I8551ca94fce16ec34770f9204282af14667e7c43 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3857943 Reviewed-by: Andrea Grandi <agrandi@google.com>
-rw-r--r--Makefile.toolchain2
-rw-r--r--core/cortex-m/ec.lds.S8
2 files changed, 10 insertions, 0 deletions
diff --git a/Makefile.toolchain b/Makefile.toolchain
index fe7bfd7a83..8286be1e7c 100644
--- a/Makefile.toolchain
+++ b/Makefile.toolchain
@@ -115,6 +115,8 @@ C_WARN = -Wstrict-prototypes -Wdeclaration-after-statement -Wno-pointer-sign
COMMON_WARN = -Wall -Wundef -Werror-implicit-function-declaration \
-Wno-trigraphs -Wno-format-security -Wno-address-of-packed-member \
-fno-common -fno-strict-aliasing -fno-strict-overflow
+# See https://www.chromium.org/chromium-os/build/c-exception-support
+COMMON_WARN+=-fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables
ifndef ALLOW_WARNINGS
COMMON_WARN+=-Werror
diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S
index 8580e366b7..f5679a97f6 100644
--- a/core/cortex-m/ec.lds.S
+++ b/core/cortex-m/ec.lds.S
@@ -347,6 +347,14 @@ SECTIONS
. = ALIGN(64);
KEEP(*(.google))
#endif
+ /*
+ * Empty C++ exception index table. The exception index
+ * table is described in more detail in "Exception Handling
+ * ABI for ARM Architecture":
+ * https://github.com/ARM-software/abi-aa/blob/60a8eb8c55e999d74dac5e368fc9d7e36e38dda4/ehabi32/ehabi32.rst#54the-object-producer-interface
+ */
+ __exidx_start = 0;
+ __exidx_end = 0;
. = ALIGN(4);
} > EC_IMAGE_VMA_MEM_REGION AT > EC_IMAGE_LMA_MEM_REGION