board: common: cmd_bootqca: Add missing symbol to enable stack-protection

The symbol __stack_guard & __stack_fail_check not present so add
these symbols explicitly in u-boot source code as per defined in kernel
source code.

The symbol __stack_guard is defined with a magic value for stack canary.
Whenever u-boot source code build with "fstack-protector" enabled then
stack canary appiled for specific function and it saved on stack.

Whenever stack canary value get currupted then __stack_fail_check
function will get called and after that programs behaves as per pre
defined behaviour.

Change-Id: Ia0575a26ab43aa2177af127e59c67a41873748c3
Signed-off-by: Md Sadre Alam <mdalam@codeaurora.org>
This commit is contained in:
Md Sadre Alam 2019-05-06 19:21:53 +05:30
parent 1f10c52b39
commit 305ca3b4d5
2 changed files with 9 additions and 0 deletions

View file

@ -35,6 +35,7 @@
#define ELF_HDR_PLUS_PHDR_SIZE sizeof(Elf32_Ehdr) + \
(NO_OF_PROGRAM_HDRS * sizeof(Elf32_Phdr))
unsigned long __stack_chk_guard = 0x000a0dff;
static int debug = 0;
static char mtdids[256];
DECLARE_GLOBAL_DATA_PTR;
@ -78,6 +79,10 @@ typedef struct {
} image_info;
#endif
void __stack_chk_fail(void)
{
printf("stack-protector: U-boot stack is corrupted.\n");
}
/*
* Set the root device and bootargs for mounting root filesystem.
*/
@ -88,6 +93,8 @@ static int set_fs_bootargs(int *fs_on_nand)
int ret = 0;
char boot_args[MAX_BOOT_ARGS_SIZE] = {'\0'};
#define nand_rootfs "ubi.mtd=" QCA_ROOT_FS_PART_NAME " root=mtd:ubi_rootfs rootfstype=squashfs"
if (sfi->flash_type == SMEM_BOOT_SPI_FLASH) {

View file

@ -305,7 +305,9 @@ static inline int print_cpuinfo(void)
#endif
int update_flash_size(int flash_size);
int arch_early_init_r(void);
extern unsigned long __stack_chk_guard;
void __stack_chk_fail(void);
/**
* arch_cpu_init_dm() - init CPU after driver model is available
*