public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Saagar Jha <saagar@saagarjha.com>
To: Alan Modra <amodra@gmail.com>
Cc: binutils@sourceware.org
Subject: Re: [PATCH] Fix a warning when initializing symbol_flags
Date: Tue, 29 Sep 2020 23:22:08 -0700	[thread overview]
Message-ID: <AC52009E-FE1E-49C6-B8FE-FD6DA720C772@saagarjha.com> (raw)
In-Reply-To: <20200930061253.GF15011@bubble.grove.modra.org>

Actually, you just reminded me of one more way to do this, although it’s a bit cryptic:

static struct symbol_flags zero_flags;
symbol_entry_t needle = { { zero_flags, hash, name, 0, 0, 0 } };

I had made a patch for this over the weekend but alas I forgot to send it to the list. But if you’re fine with the zeroes, that’s OK too.

Saagar Jha

> On Sep 29, 2020, at 23:12, Alan Modra <amodra@gmail.com> wrote:
> 
> On Sat, Sep 26, 2020 at 03:30:53PM -0700, Saagar Jha wrote:
>> Eleven zeroes is, as far as I can tell, the only widely-compatible,
>> guaranteed-to-work way to initialize this without warnings. 
> 
> Let's do that.  I had reason today to compile binutils on an older
> system with gcc-4.4.7 installed, and that warned on the current
> source.
> 
> 	* config/obj-elf.c (obj_elf_change_section): Rename variable to
> 	avoid shadowing warning.
> 	* symbols.c (symbol_entry_find): Init all symbol_flags fields.
> 
> diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
> index b1c99020a3..cd457abe5e 100644
> --- a/gas/config/obj-elf.c
> +++ b/gas/config/obj-elf.c
> @@ -762,8 +762,8 @@ obj_elf_change_section (const char *name,
> 	  /* We could be repurposing an undefined symbol here: make sure we
> 	     reset sy_value to look like other section symbols in order to avoid
> 	     trying to incorrectly resolve this section symbol later on.  */
> -	  static const expressionS expr = { .X_op = O_constant };
> -	  symbol_set_value_expression (secsym, &expr);
> +	  static const expressionS exp = { .X_op = O_constant };
> +	  symbol_set_value_expression (secsym, &exp);
> 	  symbol_set_bfdsym (secsym, sec->symbol);
> 	}
>       else
> diff --git a/gas/symbols.c b/gas/symbols.c
> index d6080886be..26dd84b126 100644
> --- a/gas/symbols.c
> +++ b/gas/symbols.c
> @@ -196,7 +196,8 @@ static void *
> symbol_entry_find (htab_t table, const char *name)
> {
>   hashval_t hash = htab_hash_string (name);
> -  symbol_entry_t needle = { { { 0 }, hash, name, 0, 0, 0 } };
> +  symbol_entry_t needle = { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
> +			      hash, name, 0, 0, 0 } };
>   return htab_find_with_hash (table, &needle, hash);
> }
> 
> 
> 
> -- 
> Alan Modra
> Australia Development Lab, IBM


      reply	other threads:[~2020-09-30  6:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-26  0:42 Saagar Jha
2020-09-26 13:06 ` Alan Modra
2020-09-26 19:21   ` Hans-Peter Nilsson
2020-09-26 22:30     ` Saagar Jha
2020-09-30  6:12       ` Alan Modra
2020-09-30  6:22         ` Saagar Jha [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AC52009E-FE1E-49C6-B8FE-FD6DA720C772@saagarjha.com \
    --to=saagar@saagarjha.com \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).