[U-Boot] [PATCH 5/6] cmd_nvedit.c: allow board-specific code before/after saving the environment

Timur Tabi timur at freescale.com
Thu May 17 23:18:49 CEST 2012


Mike Frysinger wrote:
> this is less bloat:
> int board_saveenv(void) __attribute__((weak, alias("saveenv")));
> 
> int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> {
> 	printf("Saving Environment to %s...\n", env_name_spec);
> 	return board_saveenv() ? 1 : 0;
> }

I don't think this can work:

cmd_nvedit.c:599:5: error: 'board_saveenv' aliased to undefined symbol
'saveenv'
cmd_nvedit.c:599:5: error: 'board_saveenv' aliased to undefined symbol
'saveenv'
make[1]: *** [/home/b04825/git/u-boot.0/1022/common/cmd_nvedit.o] Error 1

It looks like weak functions can't be in another source file?

If I change it to this, then it works:

static int __saveenv(void)
{
	return saveenv();
}

int board_saveenv(void) __attribute__((weak, alias("__saveenv")));

int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
	printf("Saving Environment to %s...\n", env_name_spec);
	return board_saveenv() ? 1 : 0;
}


-- 
Timur Tabi
Linux kernel developer at Freescale



More information about the U-Boot mailing list