Re: [uClinux-dev] [PATCH] ld-elf2flt: fix option order when invoking children
Jivin Mike Frysinger lays it down ... Poor getopt() implementations as found in many BSD/Darwin systems will stop processing options after a non-option is encountered. That means ld-elf2flt has to be careful to not stick options after non-options when executing sub children. In a default setup, it will invoke `elf2flt` with the output followed by the -a option which subsequently fails: elf2flt: Can't open '-a': No such file or directory Applied, thanks, Davidm Signed-off-by: Mike Frysinger vap...@gentoo.org --- ld-elf2flt.c | 13 ++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ld-elf2flt.c b/ld-elf2flt.c index f9b0f1a..227c90b 100644 --- a/ld-elf2flt.c +++ b/ld-elf2flt.c @@ -76,7 +76,14 @@ static void append_sed(sed_commands_t *dst, const char *pattern, /* Execute an external program COMMAND. Write its stdout to OUTPUT, unless that is NULL. Pass the trailing NULL terminated list of - options, followed by all those in OPTIONS, if that is non-NULL. */ + options, followed by all those in OPTIONS, if that is non-NULL. + Order of options is important here as we may run on systems that + do not allow options after non-options (i.e. many BSDs). So the + final command line will look like: + command [options] [... va args ...] + This is because [options] will (should?) never contain non-options, + while non-options will always be passed via the [va args]. + */ static int execute(const char *command, const char *output, const options_t *options, ...) { @@ -92,12 +99,12 @@ execute(const char *command, const char *output, const options_t *options, ...) init_options(opts); append_option(opts, command); + if (options) + append_options(opts, options); va_start(args, options); while ((opt = va_arg(args, const char *))) append_option(opts, opt); va_end(args); - if (options) - append_options(opts, options); append_option(opts, NULL); fflush(stdout); -- 1.6.5.2 ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev -- David McCullough, david_mccullo...@securecomputing.com, Ph:+61 734352815 McAfee - SnapGear http://www.snapgear.comhttp://www.uCdot.org ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev
[uClinux-dev] [PATCH] ld-elf2flt: fix option order when invoking children
Poor getopt() implementations as found in many BSD/Darwin systems will stop processing options after a non-option is encountered. That means ld-elf2flt has to be careful to not stick options after non-options when executing sub children. In a default setup, it will invoke `elf2flt` with the output followed by the -a option which subsequently fails: elf2flt: Can't open '-a': No such file or directory Signed-off-by: Mike Frysinger vap...@gentoo.org --- ld-elf2flt.c | 13 ++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ld-elf2flt.c b/ld-elf2flt.c index f9b0f1a..227c90b 100644 --- a/ld-elf2flt.c +++ b/ld-elf2flt.c @@ -76,7 +76,14 @@ static void append_sed(sed_commands_t *dst, const char *pattern, /* Execute an external program COMMAND. Write its stdout to OUTPUT, unless that is NULL. Pass the trailing NULL terminated list of - options, followed by all those in OPTIONS, if that is non-NULL. */ + options, followed by all those in OPTIONS, if that is non-NULL. + Order of options is important here as we may run on systems that + do not allow options after non-options (i.e. many BSDs). So the + final command line will look like: + command [options] [... va args ...] + This is because [options] will (should?) never contain non-options, + while non-options will always be passed via the [va args]. + */ static int execute(const char *command, const char *output, const options_t *options, ...) { @@ -92,12 +99,12 @@ execute(const char *command, const char *output, const options_t *options, ...) init_options(opts); append_option(opts, command); + if (options) + append_options(opts, options); va_start(args, options); while ((opt = va_arg(args, const char *))) append_option(opts, opt); va_end(args); - if (options) - append_options(opts, options); append_option(opts, NULL); fflush(stdout); -- 1.6.5.2 ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev
Re: [uClinux-dev] [PATCH] ld-elf2flt: fix option order when invoking children
On Thu, Nov 05, 2009 at 15:20:50 -0500, Mike Frysinger wrote: Poor getopt() implementations as found in many BSD/Darwin systems will stop processing options after a non-option is encountered. That means ld-elf2flt has to be careful to not stick options after non-options when executing sub children. In a default setup, it will invoke `elf2flt` with the output followed by the -a option which subsequently fails: elf2flt: Can't open '-a': No such file or directory Signed-off-by: Mike Frysinger vap...@gentoo.org Acked-by: Oskar Schirmer o...@emlix.com --- ld-elf2flt.c | 13 ++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ld-elf2flt.c b/ld-elf2flt.c index f9b0f1a..227c90b 100644 --- a/ld-elf2flt.c +++ b/ld-elf2flt.c @@ -76,7 +76,14 @@ static void append_sed(sed_commands_t *dst, const char *pattern, /* Execute an external program COMMAND. Write its stdout to OUTPUT, unless that is NULL. Pass the trailing NULL terminated list of - options, followed by all those in OPTIONS, if that is non-NULL. */ + options, followed by all those in OPTIONS, if that is non-NULL. + Order of options is important here as we may run on systems that + do not allow options after non-options (i.e. many BSDs). So the + final command line will look like: + command [options] [... va args ...] + This is because [options] will (should?) never contain non-options, + while non-options will always be passed via the [va args]. + */ static int execute(const char *command, const char *output, const options_t *options, ...) { @@ -92,12 +99,12 @@ execute(const char *command, const char *output, const options_t *options, ...) init_options(opts); append_option(opts, command); + if (options) + append_options(opts, options); va_start(args, options); while ((opt = va_arg(args, const char *))) append_option(opts, opt); va_end(args); - if (options) - append_options(opts, options); append_option(opts, NULL); fflush(stdout); -- 1.6.5.2 ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev -- oskar schirmer, emlix gmbh, http://www.emlix.com fon +49 551 30664-0, fax -11, bahnhofsallee 1b, 37081 göttingen, germany sitz der gesellschaft: göttingen, amtsgericht göttingen hr b 3160 geschäftsführer: dr. uwe kracke, ust-idnr.: de 205 198 055 emlix - your embedded linux partner ___ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev