aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2024-08-10 08:41:16 +0930
committerAlan Modra <amodra@gmail.com>2024-08-10 10:28:32 +0930
commitec8f5671b4e70806fe3053636426a8d179dfef55 (patch)
treeec122d4f0c25cca1cc5fb5c2abee4b6c99e8595b /bfd/elflink.c
parente34f53c5e6f3f2367fe1588b5a38954a76fec253 (diff)
downloadgdb-ec8f5671b4e70806fe3053636426a8d179dfef55.zip
gdb-ec8f5671b4e70806fe3053636426a8d179dfef55.tar.gz
gdb-ec8f5671b4e70806fe3053636426a8d179dfef55.tar.bz2
PR32067, ld -Wl,--oformat,binary crash in _bfd_elf_link_keep_memory
The direct fix for this segfault is to test for a non-NULL bed in _bfd_elf_link_keep_memory, but also there isn't much point in running code for LTO if the output is binary. PR 32067 * elflink.c (_bfd_elf_link_keep_memory): Test for non-NULL bed. (elf_link_add_object_symbols): Don't run the loop setting non_ir_ref_regular if the output hash table is not ELF.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index a180e59..2430d60 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -64,7 +64,7 @@ _bfd_elf_link_keep_memory (struct bfd_link_info *info)
this is opt-in by each backend. */
const struct elf_backend_data *bed
= get_elf_backend_data (info->output_bfd);
- if (bed->use_mmap)
+ if (bed != NULL && bed->use_mmap)
return false;
#endif
bfd *abfd;
@@ -5694,7 +5694,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
&& !bfd_link_relocatable (info)
&& (abfd->flags & BFD_PLUGIN) == 0
&& !just_syms
- && extsymcount)
+ && extsymcount != 0
+ && is_elf_hash_table (&htab->root))
{
int r_sym_shift;