From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 050FB3858D28 for ; Wed, 9 Feb 2022 10:57:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 050FB3858D28 Received: by mail-pf1-x429.google.com with SMTP id y8so855970pfa.11 for ; Wed, 09 Feb 2022 02:57:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=oKyY7YwFyWYGijja7hYabT3SXfwtni4dAZQW/DHINqw=; b=H8bQ2qN5p2NCVTG2qpENBb5BPpMIlftu/WiNzt+Qggr0Ot5uoWX00vPBJgO1TXKEOR BxzPaDvj6j0+iKghgcGnO5UFOaer7nmKMHacbS8I48hUHPiKyReLtZ7TIZeqvloZypY1 GkG3f3TB5vxplkIhBq162KsrCMahZYI0Yd2j5ClBc1njurLcm21u3ndIxqg6xTfWJE5+ /QVb2k5ggtIaS7UgAQU51rMTo9wz1lhB1w6aydyl8QXHvEEERdV65eWuRt4FevQyVogl mub+OJ73iaq4NQwJO3c+Dd3fnqUnymojXWOJ7VaJ9AeX0aZTLmZ+Mhu3CIHl5NPFZqyt wd4g== X-Gm-Message-State: AOAM531CL6AIaG7eZ/OZswvMKqMIZPuulzEghmxiwjkETn9yhbBZbu1d ck2D6CBC5UmDjOGy7MN+wVqvrQOmkjA= X-Google-Smtp-Source: ABdhPJzBZtmUYRa4egudAru7ZDjUr3u3oHcSyTe9AIA+XjhkgcQDwm0mxG4e1XOfQSIc7PuxpzU84g== X-Received: by 2002:a63:924c:: with SMTP id s12mr1411389pgn.257.1644404245640; Wed, 09 Feb 2022 02:57:25 -0800 (PST) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:fdf1:97a7:98ae:9f1d]) by smtp.gmail.com with ESMTPSA id u2sm20268383pfk.15.2022.02.09.02.57.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 02:57:24 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 1339A1140296; Wed, 9 Feb 2022 21:27:22 +1030 (ACDT) Date: Wed, 9 Feb 2022 21:27:22 +1030 From: Alan Modra To: binutils@sourceware.org Subject: Work around gcc-4 warnings in elf64-ppc.c Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3037.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Feb 2022 10:57:29 -0000 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