diff options
author | Kito Cheng <kito.cheng@gmail.com> | 2016-08-23 17:40:28 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-09-01 19:52:37 -0700 |
commit | 6580e7f1a9dd0949dda354f463e778241ea73861 (patch) | |
tree | 50250db3da10d2dd3b30628e2f591bc404715c37 | |
parent | 02b80c49f473b872360a782f6a95c607c6734717 (diff) | |
download | chrome-ec-6580e7f1a9dd0949dda354f463e778241ea73861.tar.gz |
panic: Fix unaligned memory access panic
Some target's gcc will detect the address is unaligned and then
expand to byte load sequence, make the address to volatile can
prevent gcc optimize it.
BUG=none
BRANCH=none
TEST=make buildall;
Verified that "crash unaligned" causes a panic on it83xx.
Change-Id: Ieb4f5f8fc65854aefe307fa675fe87d7581452ed
Signed-off-by: Kito Cheng <kito.cheng@gmail.com>
Reviewed-on: https://chromium-review.googlesource.com/374281
Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r-- | common/panic_output.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/common/panic_output.c b/common/panic_output.c index b278ac1acb..269f08db6c 100644 --- a/common/panic_output.c +++ b/common/panic_output.c @@ -177,8 +177,9 @@ static int command_crash(int argc, char **argv) stack_overflow_recurse(1); #endif } else if (!strcasecmp(argv[1], "unaligned")) { + volatile intptr_t unaligned_ptr = 0xcdef; cflush(); - ccprintf("%08x", *(volatile int *)0xcdef); + ccprintf("%08x", *(volatile int *)unaligned_ptr); } else if (!strcasecmp(argv[1], "watchdog")) { while (1) ; |