public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: PR29626, Segfault when disassembling ARM code
Date: Fri, 30 Sep 2022 10:32:36 +0930	[thread overview]
Message-ID: <YzZALNAOwb0TtzN7@squeak.grove.modra.org> (raw)

Note: -w diff shown.  The actual patch applied reindents.

	PR 29626
	* arm-dis.c (mapping_symbol_for_insn): Return false on zero
	symtab_size.  Delete later symtab_size test.

diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c
index 684c74f7f20..caf3531ae3d 100644
--- a/opcodes/arm-dis.c
+++ b/opcodes/arm-dis.c
@@ -11865,14 +11865,13 @@ mapping_symbol_for_insn (bfd_vma pc, struct disassemble_info *info,
   struct arm_private_data *private_data;
 
   if (info->private_data == NULL
+      || info->symtab_size == 0
       || bfd_asymbol_flavour (*info->symtab) != bfd_target_elf_flavour)
     return false;
 
   private_data = info->private_data;
 
   /* First, look for mapping symbols.  */
-  if (info->symtab_size != 0)
-  {
   if (pc <= private_data->last_mapping_addr)
     private_data->last_mapping_sym = -1;
 
@@ -11884,8 +11883,8 @@ mapping_symbol_for_insn (bfd_vma pc, struct disassemble_info *info,
      are disassembling a different glob of bytes.  As such the optimization
      would not be safe and we should start over.  */
   can_use_search_opt_p
-      = private_data->last_mapping_sym >= 0
-	&& info->stop_offset == private_data->last_stop_offset;
+    = (private_data->last_mapping_sym >= 0
+       && info->stop_offset == private_data->last_stop_offset);
 
   if (n >= private_data->last_mapping_sym && can_use_search_opt_p)
     n = private_data->last_mapping_sym;
@@ -11935,7 +11934,6 @@ mapping_symbol_for_insn (bfd_vma pc, struct disassemble_info *info,
 	    }
 	}
     }
-  }
 
   /* If no mapping symbol was found, try looking up without a mapping
      symbol.  This is done by walking up from the current PC to the nearest

-- 
Alan Modra
Australia Development Lab, IBM

                 reply	other threads:[~2022-09-30  1:02 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=YzZALNAOwb0TtzN7@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).