From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: PR29566, objdump -p considers an empty .gnu.version_r invalid
Date: Wed, 21 Sep 2022 22:09:51 +0930 [thread overview]
Message-ID: <YysGF4VY5Vz7EP3a@squeak.grove.modra.org> (raw)
Allow and ignore an empty section.
PR 29566
* elf.c (bfd_section_from_shdr): Don't set elf_dynverdef or
elf_dynverref for empty sections.
(_bfd_elf_slurp_version_tables): Remove now redundant tests.
diff --git a/bfd/elf.c b/bfd/elf.c
index 2eb2a97370a..bc433cf516c 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2479,7 +2479,8 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
}
case SHT_GNU_verdef:
- elf_dynverdef (abfd) = shindex;
+ if (hdr->sh_info != 0)
+ elf_dynverdef (abfd) = shindex;
elf_tdata (abfd)->dynverdef_hdr = *hdr;
ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
goto success;
@@ -2494,7 +2495,8 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
goto success;
case SHT_GNU_verneed:
- elf_dynverref (abfd) = shindex;
+ if (hdr->sh_info != 0)
+ elf_dynverref (abfd) = shindex;
elf_tdata (abfd)->dynverref_hdr = *hdr;
ret = _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
goto success;
@@ -8877,8 +8879,7 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
hdr = &elf_tdata (abfd)->dynverref_hdr;
- if (hdr->sh_info == 0
- || hdr->sh_info > hdr->sh_size / sizeof (Elf_External_Verneed))
+ if (hdr->sh_info > hdr->sh_size / sizeof (Elf_External_Verneed))
{
error_return_bad_verref:
_bfd_error_handler
@@ -9011,7 +9012,7 @@ _bfd_elf_slurp_version_tables (bfd *abfd, bool default_imported_symver)
hdr = &elf_tdata (abfd)->dynverdef_hdr;
- if (hdr->sh_info == 0 || hdr->sh_size < sizeof (Elf_External_Verdef))
+ if (hdr->sh_size < sizeof (Elf_External_Verdef))
{
error_return_bad_verdef:
_bfd_error_handler
--
Alan Modra
Australia Development Lab, IBM
reply other threads:[~2022-09-21 12:39 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=YysGF4VY5Vz7EP3a@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).