cmd/elf.c: Support passing arguments with bootelf
PATCH 1/1 cmd/elf.c: Support passing arguments with bootelf
The bootelf command could, but does not, pass additional arguments along on the command line. Make do_bootelf consume bootelf/flags/address as needed and then pass along anything else to the ELF application we've launched.
---
Yes, this bug was reported back in 2009, and then not corrected. It was slightly more complex than Wolfgang had implied (even at the time) and I assume then slipped his mind. I ran into this myself now, and Thomas' post was one of the first things I found.
--- cmd/elf.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
cmd/elf.c +17 -17
@@ -147,25 +147,25 @@ int do_bootelf(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {unsigned long addr;/* Address of the ELF image */ unsigned long rc;/* Return value from user code */ -char *sload, *saddr; +char *sload =NULL ;const char *ep =getenv ("autostart" ); -int rcode =0 ; - sload = saddr =NULL ; -if (argc ==3 ) { - sload = argv[1 ]; - saddr = argv[2 ]; - }else if (argc ==2 ) { -if (argv[1 ][0 ] =='-' ) - sload = argv[1 ]; -else - saddr = argv[1 ]; - } +/* Consume 'bootelf' */ + argc--; argv++; -if (saddr) - addr =simple_strtoul (saddr,NULL ,16 ); -else +/* Check for flag. */ +if (argc >=1 && (argv[0 ][0 ] =='-' && \ + (argv[0 ][1 ] =='p' || argv[0 ][1 ] =='s' ))) { + sload = argv[0 ]; +/* Consume flag. */ + argc--; argv++; + } +/* Check for address. */ +if (argc >=1 &&strict_strtoul (argv[0 ],16 , &addr) != -EINVAL ) { +/* Consume address */ + argc--; argv++; + }else addr = load_addr;if (!valid_elf_image (addr))
@@ -185,7 +185,7 @@ int do_bootelf(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])* pass address parameter as argv[0] (aka command name), * and all remaining args */ - rc =do_bootelf_exec ((void *)addr, argc -1 , argv +1 ); + rc =do_bootelf_exec ((void *)addr, argc, argv);if (rc !=0 ) rcode =1 ;
@@ -385,7 +385,7 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) }U_BOOT_CMD ( - bootelf,3 ,0 , do_bootelf, + bootelf,CONFIG_SYS_MAXARGS ,0 , do_bootelf,"Boot from an ELF image in memory" ,"[-p|-s] [address]\n" "\t- load ELF image at [address] via program headers (-p)\n"
Signature · 1 line
1.9.1
Quoted 7 lines · Tom Rini
The bootelf command could, but does not, pass additional arguments along on the command line. Make
do_bootelfconsume bootelf/flags/address as needed and then pass along anything else to the ELF application we've launched.Reported-by Thomas Doerfler <[email protected]>Signed-off-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170605/4e4f3d17/attachment.sig>