summaryrefslogtreecommitdiff
path: root/core/cortex-m
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2018-08-16 10:24:30 +0200
committerchrome-bot <chrome-bot@chromium.org>2018-10-16 10:30:36 -0700
commit9a16a6b9cf701d43ba0e7e8f71ac081e15430be3 (patch)
tree2a6ef97c2a80e3c4bc1cf27c369d85ba5cd04ff3 /core/cortex-m
parent35720d34cb1b853dce0f04e2909e2c7d92f324bc (diff)
downloadchrome-ec-9a16a6b9cf701d43ba0e7e8f71ac081e15430be3.tar.gz
cortex-m0: Generate vector table in C
Different versions of the linker behave differently when mixing object built with lto enabled (desirable for code size reduction) and disabled (assembler code), especially when they refer to each other symbols: The file evaluation order of the linker becomes important as it eliminates dead code at various points in time, and LTO code referring to non-LTO code or vice versa, is not visible at early runs. Sadly, just changing the order on the command line isn't sufficient: What works for gcc8 breaks gcc6 (and may behave different in even more ways on gcc4 or other versions). Therefore, implement the vector table in C, so it's compiled in LTO mode, just like the code it refers to. This is a port of Change-Id: I9b75f6558f0357e18000ff1161096c8f9c94a8ac BUG=b:65441143 BRANCH=none TEST=with this change the vector table for whiskers looks much more reasonable (ie. not mostly empty) Change-Id: Ifd39289ecb16b81cdf41427ce190984510d3fd3c Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://chromium-review.googlesource.com/1120333 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-by: Stefan Reinauer <reinauer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1177382 Reviewed-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org>
Diffstat (limited to 'core/cortex-m')
-rw-r--r--core/cortex-m/panic-internal.h11
-rw-r--r--core/cortex-m/panic.c2
-rw-r--r--core/cortex-m/vecttable.c2
3 files changed, 13 insertions, 2 deletions
diff --git a/core/cortex-m/panic-internal.h b/core/cortex-m/panic-internal.h
new file mode 100644
index 0000000000..2ed21912a0
--- /dev/null
+++ b/core/cortex-m/panic-internal.h
@@ -0,0 +1,11 @@
+/* Copyright (c) 2018 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.
+ */
+
+#ifndef __CROS_EC_PANIC_INTERNAL_H
+#define __CROS_EC_PANIC_INTERNAL_H
+
+void exception_panic(void) __attribute__((naked));
+
+#endif /* __CROS_EC_PANIC_INTERNAL_H */
diff --git a/core/cortex-m/panic.c b/core/cortex-m/panic.c
index bc049bd698..7daedbf7ab 100644
--- a/core/cortex-m/panic.c
+++ b/core/cortex-m/panic.c
@@ -8,6 +8,7 @@
#include "cpu.h"
#include "host_command.h"
#include "panic.h"
+#include "panic-internal.h"
#include "printf.h"
#include "system.h"
#include "task.h"
@@ -355,7 +356,6 @@ void __keep report_panic(void)
*
* Declare this as a naked call so we can extract raw LR and IPSR values.
*/
-void __keep exception_panic(void) __attribute__((naked));
void exception_panic(void)
{
/* Save registers and branch directly to panic handler */
diff --git a/core/cortex-m/vecttable.c b/core/cortex-m/vecttable.c
index ac0ef4c79a..0f11d03d10 100644
--- a/core/cortex-m/vecttable.c
+++ b/core/cortex-m/vecttable.c
@@ -19,7 +19,7 @@ typedef void (*func)(void);
#if PASS == 1
/* Default exception handler */
-void __attribute__((used,naked)) default_handler(void);
+void __attribute__((used, naked)) default_handler(void);
void default_handler()
{
asm(