From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id 2AF953858407 for ; Wed, 14 Sep 2022 00:37:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2AF953858407 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-x52f.google.com with SMTP id q63so12844841pga.9 for ; Tue, 13 Sep 2022 17:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date; bh=9Y1Fa+E+MyOV7eYr1bsLnNcuQRuKrJFX6Z5nlpyvtwM=; b=BuV9VNVovbl9zRmcQCxgjL00ND1qxFyCphFcyJjHKzDVvprxJa4asFZZE/w8qPp0MY fOvObxEHrCARGCQKNsUbVDcnI0OfZokzFZq0xUYkPj252s3WLLv2kDQO4DUkJ40z64Jj QS2pcEm03pvTNqB9lYovwpLyv6pQpvrz/UUk4ll9Zpse42klk5FBAp03NtW++2qldupC rLYjWM0N/SfBXwJWfCzoC5PvpA//M0wzPpu3EuMwgUAbHjyK+9d9GA0gOPBQhotdXeLh XkfiKi44EwLXBGYA7fgc77G1AQtgXHGS1EPVMSud9r31R3mHShinGT2Ge2j02uWbwLA/ BLcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=9Y1Fa+E+MyOV7eYr1bsLnNcuQRuKrJFX6Z5nlpyvtwM=; b=QY6SP4YXzb4AQhyCt74+ft2oOH3uavcVss97z5oOBBWbGcR58m/qsTidb3PQKP5Afb V+VzNJ214uXyGjg6MYHK0Ju1Kwk+gn+OhNjLYLI/Sd4F5n35x0OK4jbIVfIs4ag2xhm5 cGYMubkr67aLJJxFXzQtg5BsCF0c3+1zEDd/opfUdeEghAs2fYNhRLHm40x7wFbCfxP4 UBv7kjmCWVuQmL4dxxhIxNq+voQivUNztxXcu+dUGMrgjbZuo0IBvX24m4FceZeOk2SP 8MnTOHu33ib+2MPHCNVNwrlXhmHXUQpHvuRFyelWWqyPPdBLUx9QSDIHt6CrAkVcoYyI n3/A== X-Gm-Message-State: ACgBeo0gfzwzTvUU5Tg5YZ8+9p92inBPSxoJ6+IyJDyGjaEll29xQB7w kUQ9JduhawchaI7FgXOmwlLtOTOE4fk= X-Google-Smtp-Source: AA6agR6NahPdG7ly3XhmaNTjLzHKnMwSMJciOPXYypN0mSxPgCRXSCru+ydH3Y9vjbC2UxKyt0+5zw== X-Received: by 2002:a62:8345:0:b0:53e:a1bf:8df9 with SMTP id h66-20020a628345000000b0053ea1bf8df9mr31288660pfe.68.1663115857958; Tue, 13 Sep 2022 17:37:37 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id d8-20020a170903230800b001781cad59e3sm8180291plh.108.2022.09.13.17.37.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 17:37:37 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 97B611140ABA; Wed, 14 Sep 2022 10:07:34 +0930 (ACST) Date: Wed, 14 Sep 2022 10:07:34 +0930 From: Alan Modra To: binutils@sourceware.org Subject: PR29540, R_PPC64_NONE in .rela.dyn when linking Linux vdso Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3035.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_STOCKGEN,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: There is code in the ppc backend to ignore relocs against local symbols defined in discarded sections (search for local_dynrel), but somehow not for global symbols. Add the missing support. PR 29540 * elf64-ppc.c (allocate_dynrelocs): Don't alloc space for relocs against discarded sections. (ppc64_elf_size_dynamic_sections): Use standard test for discarded sections. * elf32-ppc.c (allocate_dynrelocs): Don't alloc space for relocs against discarded sections. (ppc_elf_size_dynamic_sections): Use standard test for discarded sections. diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 1f77e18133a..0eebadc1e37 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -5268,12 +5268,13 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) /* Allocate space. */ for (p = h->dyn_relocs; p != NULL; p = p->next) - { - asection *sreloc = elf_section_data (p->sec)->sreloc; - if (eh->elf.type == STT_GNU_IFUNC) - sreloc = htab->elf.irelplt; - sreloc->size += p->count * sizeof (Elf32_External_Rela); - } + if (!discarded_section (p->sec)) + { + asection *sreloc = elf_section_data (p->sec)->sreloc; + if (eh->elf.type == STT_GNU_IFUNC) + sreloc = htab->elf.irelplt; + sreloc->size += p->count * sizeof (Elf32_External_Rela); + } /* Handle PLT relocs. Done last, after dynindx has settled. We might need a PLT entry when the symbol @@ -5535,8 +5536,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd, p != NULL; p = p->next) { - if (!bfd_is_abs_section (p->sec) - && bfd_is_abs_section (p->sec->output_section)) + if (discarded_section (p->sec)) { /* Input section has been discarded, either because it is a copy of a linkonce section or due to diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index f1e482faed4..5329bb64afb 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -10000,20 +10000,21 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) /* Finally, allocate space. */ for (p = (struct ppc_dyn_relocs *) h->dyn_relocs; p != NULL; p = p->next) - { - unsigned int count; - asection *sreloc = elf_section_data (p->sec)->sreloc; - if (eh->elf.type == STT_GNU_IFUNC) - sreloc = htab->elf.irelplt; - count = p->count; - if (info->enable_dt_relr - && ((!NO_OPD_RELOCS - && ppc64_elf_section_data (p->sec)->sec_type == sec_opd) - || (eh->elf.type != STT_GNU_IFUNC - && SYMBOL_REFERENCES_LOCAL (info, h)))) - count -= p->rel_count; - sreloc->size += count * sizeof (Elf64_External_Rela); - } + if (!discarded_section (p->sec)) + { + unsigned int count; + asection *sreloc = elf_section_data (p->sec)->sreloc; + if (eh->elf.type == STT_GNU_IFUNC) + sreloc = htab->elf.irelplt; + count = p->count; + if (info->enable_dt_relr + && ((!NO_OPD_RELOCS + && ppc64_elf_section_data (p->sec)->sec_type == sec_opd) + || (eh->elf.type != STT_GNU_IFUNC + && SYMBOL_REFERENCES_LOCAL (info, h)))) + count -= p->rel_count; + sreloc->size += count * sizeof (Elf64_External_Rela); + } } /* We might need a PLT entry when the symbol @@ -10248,8 +10249,7 @@ ppc64_elf_size_dynamic_sections (bfd *output_bfd, for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next) { - if (!bfd_is_abs_section (p->sec) - && bfd_is_abs_section (p->sec->output_section)) + if (discarded_section (p->sec)) { /* Input section has been discarded, either because it is a copy of a linkonce section or due to -- Alan Modra Australia Development Lab, IBM