From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: PR29540, R_PPC64_NONE in .rela.dyn when linking Linux vdso
Date: Wed, 14 Sep 2022 10:07:34 +0930 [thread overview]
Message-ID: <YyEiTgHS2mrmpvwr@squeak.grove.modra.org> (raw)
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
reply other threads:[~2022-09-14 0:37 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=YyEiTgHS2mrmpvwr@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).