aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-09-21 19:34:08 +0930
committerAlan Modra <amodra@gmail.com>2022-09-21 22:10:14 +0930
commitf9a59eea78428159a9522bd64ec354a872f1dc31 (patch)
tree68c6e1c900ed8a8d1a538a27e7368f3cd3ddee29
parentacab2a6872db8e6ebab3e91bc22a4df384d1c8ed (diff)
downloadgdb-f9a59eea78428159a9522bd64ec354a872f1dc31.zip
gdb-f9a59eea78428159a9522bd64ec354a872f1dc31.tar.gz
gdb-f9a59eea78428159a9522bd64ec354a872f1dc31.tar.bz2
PR29566, objdump -p considers an empty .gnu.version_r invalid
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.
-rw-r--r--bfd/elf.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 2eb2a97..bc433cf 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