public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] PR32067, ld -Wl,--oformat,binary crash in _bfd_elf_link_keep_memory
@ 2024-08-10  1:00 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2024-08-10  1:00 UTC (permalink / raw)
  To: binutils-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ec8f5671b4e70806fe3053636426a8d179dfef55

commit ec8f5671b4e70806fe3053636426a8d179dfef55
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Aug 10 08:41:16 2024 +0930

    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.

Diff:
---
 bfd/elflink.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/bfd/elflink.c b/bfd/elflink.c
index a180e59e8ca..2430d606c30 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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-08-10  1:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-10  1:00 [binutils-gdb] PR32067, ld -Wl,--oformat,binary crash in _bfd_elf_link_keep_memory Alan Modra

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).