mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2025-12-10 07:44:53 +01:00
This change will add stack canary test command in u-boot command list. The stack canary test command format like as : canary <string>. The string must be 10 bytes long. e.g " #canary Helloworldhelloworld". After this command we can see the below print. Stack Canary test start. stack-protector: U-boot stack is corrupted. Resetting CPU ... If stack-protection not enabled and stack overflow occure then we will get the following print. prefetch abort pc : [<4a006f72>] lr : [<4a90faf0>] reloc pc : [<4a006f72>] lr : [<4a90faf0>] sp : 4a77f948 ip : 20f14495 fp : 4a90fab4 r10: 00000002 r9 : 4a77fea0 r8 : 00000000 r7 : 4a983d20 r6 : 6f6f6f6f r5 : 6f6f6f6f r4 : 6f6f6f6f r3 : 00000000 r2 : 4a77f946 r1 : 4a78233b r0 : 00000000 Flags: nZCv IRQs off FIQs off Mode SVC_32 Resetting CPU ... Change-Id: If36d1da3ecc1d0038cd1a6bad6ab3d265b47dac8 Signed-off-by: Md Sadre Alam <mdalam@codeaurora.org>
82 lines
1.6 KiB
C
82 lines
1.6 KiB
C
/*
|
|
* (C) Copyright 2000-2003
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
*/
|
|
|
|
/*
|
|
* Misc boot support
|
|
*/
|
|
#include <common.h>
|
|
#include <command.h>
|
|
#include <net.h>
|
|
|
|
#ifdef CONFIG_CMD_GO
|
|
|
|
/* Allow ports to override the default behavior */
|
|
__attribute__((weak))
|
|
unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
|
|
char * const argv[])
|
|
{
|
|
return entry (argc, argv);
|
|
}
|
|
|
|
static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|
{
|
|
ulong addr, rc;
|
|
int rcode = 0;
|
|
|
|
if (argc < 2)
|
|
return CMD_RET_USAGE;
|
|
|
|
addr = simple_strtoul(argv[1], NULL, 16);
|
|
|
|
printf ("## Starting application at 0x%08lX ...\n", addr);
|
|
|
|
/*
|
|
* pass address parameter as argv[0] (aka command name),
|
|
* and all remaining args
|
|
*/
|
|
rc = do_go_exec ((void *)addr, argc - 1, argv + 1);
|
|
if (rc != 0) rcode = 1;
|
|
|
|
printf ("## Application terminated, rc = 0x%lX\n", rc);
|
|
return rcode;
|
|
}
|
|
static int do_canary(cmd_tbl_t *cmdtp, int flag, int argc,
|
|
char * const argv[])
|
|
{
|
|
char Buffer[10] = {'\0'};
|
|
printf("Stack Canary test start.\n");
|
|
|
|
if (argc < 2 || argc > 2)
|
|
return CMD_RET_USAGE;
|
|
|
|
strlcpy(Buffer, argv[1], strlen(argv[1]));
|
|
|
|
return 0;
|
|
}
|
|
|
|
U_BOOT_CMD(
|
|
canary, 2, 0, do_canary,
|
|
"test stack canary",
|
|
"\n canary HelloworldHelloWorld \n"
|
|
);
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
U_BOOT_CMD(
|
|
go, CONFIG_SYS_MAXARGS, 1, do_go,
|
|
"start application at address 'addr'",
|
|
"addr [arg ...]\n - start application at address 'addr'\n"
|
|
" passing 'arg' as arguments"
|
|
);
|
|
|
|
#endif
|
|
|
|
U_BOOT_CMD(
|
|
reset, 1, 0, do_reset,
|
|
"Perform RESET of the CPU",
|
|
""
|
|
);
|