diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2023-08-30 08:49:15 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2023-08-30 17:17:31 -0700 |
commit | bac5753ca24bbbd601b6be93faa40e9458d8baa5 (patch) | |
tree | 983bde7bc19ed3f6c1eedaef6e7c681ed1b796c3 | |
parent | 48abc08d13eab39d3db931352990e409174d5b9f (diff) | |
download | gdb-bac5753ca24bbbd601b6be93faa40e9458d8baa5.zip gdb-bac5753ca24bbbd601b6be93faa40e9458d8baa5.tar.gz gdb-bac5753ca24bbbd601b6be93faa40e9458d8baa5.tar.bz2 |
elf: Check DT_SYMTAB only on non-IR object
Check DT_SYMTAB only on non-IR object of archive member to avoid crash
on LLVM IR object with NULL elf_tdata.
PR ld/30811
* elflink.c (elf_link_is_defined_archive_symbol): Check
DT_SYMTAB only on non-IR object.
-rw-r--r-- | bfd/elflink.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index c4f286e..ca16214 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -3571,12 +3571,6 @@ elf_link_is_defined_archive_symbol (bfd * abfd, carsym * symdef) if (! bfd_check_format (abfd, bfd_object)) return false; - if (elf_use_dt_symtab_p (abfd)) - { - bfd_set_error (bfd_error_wrong_format); - return false; - } - /* Select the appropriate symbol table. If we don't know if the object file is an IR object, give linker LTO plugin a chance to get the correct symbol table. */ @@ -3592,10 +3586,19 @@ elf_link_is_defined_archive_symbol (bfd * abfd, carsym * symdef) abfd = abfd->plugin_dummy_bfd; hdr = &elf_tdata (abfd)->symtab_hdr; } - else if ((abfd->flags & DYNAMIC) == 0 || elf_dynsymtab (abfd) == 0) - hdr = &elf_tdata (abfd)->symtab_hdr; else - hdr = &elf_tdata (abfd)->dynsymtab_hdr; + { + if (elf_use_dt_symtab_p (abfd)) + { + bfd_set_error (bfd_error_wrong_format); + return false; + } + + if ((abfd->flags & DYNAMIC) == 0 || elf_dynsymtab (abfd) == 0) + hdr = &elf_tdata (abfd)->symtab_hdr; + else + hdr = &elf_tdata (abfd)->dynsymtab_hdr; + } symcount = hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym; |