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>
This commit is contained in:
Kito Cheng
2016-08-23 17:40:28 +08:00
committed by chrome-bot
parent 02b80c49f4
commit 6580e7f1a9

View File

@@ -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)
;