public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: Work around gcc-4 warnings in elf64-ppc.c
Date: Wed, 9 Feb 2022 21:27:22 +1030	[thread overview]
Message-ID: <YgOeEopRJwqfSF0f@squeak.grove.modra.org> (raw)

elf64-ppc.c: In function 'ppc64_elf_size_dynamic_sections':
elf64-ppc.c:10309:45: error: value computed is not used [-Werror=unused-value]
     ++lgot_ents, ++lgot_masks, isym != NULL && isym++)

It is of course a silly warning, fixed in later versions of gcc.  I
wrote "isym != NULL && isym++" rather than the simpler "isym++" to
stop sanitisers complaining about incrementing a NULL pointer.  isym
is of course unused in any code path where it might start off as
NULL.  Sometimes you can't win.  So don't try to be clever in reading
local symbols only when needed.  99 times out of 100 they will be
cached anyway.

	* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Avoid annoying
	warnings by always reading local syms.
	(ppc64_elf_layout_multitoc): Likewise.

diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 7223c497d07..7b7bfa19506 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -10292,22 +10292,18 @@ ppc64_elf_size_dynamic_sections (bfd *output_bfd,
       local_plt = (struct plt_entry **) end_lgot_ents;
       end_local_plt = local_plt + locsymcount;
       lgot_masks = (unsigned char *) end_local_plt;
-      local_syms = NULL;
-      if (bfd_link_pic (info))
+      local_syms = (Elf_Internal_Sym *) symtab_hdr->contents;
+      if (local_syms == NULL && locsymcount != 0)
 	{
-	  local_syms = (Elf_Internal_Sym *) symtab_hdr->contents;
-	  if (local_syms == NULL && locsymcount != 0)
-	    {
-	      local_syms = bfd_elf_get_elf_syms (ibfd, symtab_hdr, locsymcount,
-						 0, NULL, NULL, NULL);
-	      if (local_syms == NULL)
-		return false;
-	    }
+	  local_syms = bfd_elf_get_elf_syms (ibfd, symtab_hdr, locsymcount,
+					     0, NULL, NULL, NULL);
+	  if (local_syms == NULL)
+	    return false;
 	}
       s = ppc64_elf_tdata (ibfd)->got;
       for (isym = local_syms;
 	   lgot_ents < end_lgot_ents;
-	   ++lgot_ents, ++lgot_masks, isym != NULL && isym++)
+	   ++lgot_ents, ++lgot_masks, isym++)
 	{
 	  struct got_entry **pent, *ent;
 
@@ -12828,22 +12824,18 @@ ppc64_elf_layout_multitoc (struct bfd_link_info *info)
       local_plt = (struct plt_entry **) end_lgot_ents;
       end_local_plt = local_plt + locsymcount;
       lgot_masks = (unsigned char *) end_local_plt;
-      local_syms = NULL;
-      if (bfd_link_pic (info))
+      local_syms = (Elf_Internal_Sym *) symtab_hdr->contents;
+      if (local_syms == NULL && locsymcount != 0)
 	{
-	  local_syms = (Elf_Internal_Sym *) symtab_hdr->contents;
-	  if (local_syms == NULL && locsymcount != 0)
-	    {
-	      local_syms = bfd_elf_get_elf_syms (ibfd, symtab_hdr, locsymcount,
-						 0, NULL, NULL, NULL);
-	      if (local_syms == NULL)
-		return false;
-	    }
+	  local_syms = bfd_elf_get_elf_syms (ibfd, symtab_hdr, locsymcount,
+					     0, NULL, NULL, NULL);
+	  if (local_syms == NULL)
+	    return false;
 	}
       s = ppc64_elf_tdata (ibfd)->got;
       for (isym = local_syms;
 	   lgot_ents < end_lgot_ents;
-	   ++lgot_ents, ++lgot_masks, isym != NULL && isym++)
+	   ++lgot_ents, ++lgot_masks, isym++)
 	{
 	  struct got_entry *ent;
 

-- 
Alan Modra
Australia Development Lab, IBM

                 reply	other threads:[~2022-02-09 10:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=YgOeEopRJwqfSF0f@squeak.grove.modra.org \
    --to=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).