From 887c6f4cffe02975cb5b1786baa5a21b041cd6d3 Mon Sep 17 00:00:00 2001 From: Fox Snowpatch Date: Fri, 29 Nov 2024 11:22:16 +0000 Subject: [PATCH] From patchwork series 434662 https://patchwork.ozlabs.org//project/linuxppc-dev/list/?series=434662 --- arch/powerpc/boot/wrapper | 1 + tools/lib/subcmd/parse-options.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper index 1db60fe13802..d25ad8c622f4 100755 --- a/arch/powerpc/boot/wrapper +++ b/arch/powerpc/boot/wrapper @@ -267,6 +267,7 @@ pseries) link_address='0x4000000' if [ "$format" != "elf32ppc" ]; then link_address= + notext='-z notext' pie=-pie fi make_space=n diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c index 555d617c1f50..f85b642bc9aa 100644 --- a/tools/lib/subcmd/parse-options.c +++ b/tools/lib/subcmd/parse-options.c @@ -360,8 +360,7 @@ static int parse_short_opt(struct parse_opt_ctx_t *p, const struct option *optio return -2; } -static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg, - const struct option *options) +static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg, const struct option *options) { const char *arg_end = strchr(arg, '='); const struct option *abbrev_option = NULL, *ambiguous_option = NULL; @@ -828,9 +827,10 @@ static struct option *options__order(const struct option *opts) nr_parent = nr_opts; } - /* copy the last OPTION_END */ - memcpy(&ordered[nr_opts], o, sizeof(*o)); - + /* Check whether o is valid before using it to copy the last OPTION_END. */ + if (o && o->type == OPTION_END) { + memcpy(&ordered[nr_opts], o, sizeof(*o)); + } /* sort each option group individually */ for (opt = group = ordered; opt->type != OPTION_END; opt++) { if (opt->type == OPTION_GROUP) {