public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Commit: PPC: Ignore hidden local no-type symbols when disassembling.
@ 2020-09-10 12:22 Nick Clifton
  0 siblings, 0 replies; only message in thread
From: Nick Clifton @ 2020-09-10 12:22 UTC (permalink / raw)
  To: binutils

Hi Guys,

  I am checking in the patch below to fix the PowerPC disassembler so
  that it will ignore hidden, local no-type symbols.  These are
  generated by the annobin plugin for gcc and if their placement does
  not coincide with an instruction boundary then they can break the
  disassembly.

Cheers
  Nick

opcodes/ChangeLog
2020-09-10  Nick Clifton  <nickc@redhat.com>

	* ppc-dis.c (ppc_symbol_is_valid): New function.  Returns false
	for hidden, local, no-type symbols.
	(disassemble_init_powerpc): Point the symbol_is_valid field in the
	info structure at the new function.

diff --git a/opcodes/ppc-dis.c b/opcodes/ppc-dis.c
index eca1f36710..4e8e3cb462 100644
--- a/opcodes/ppc-dis.c
+++ b/opcodes/ppc-dis.c
@@ -399,12 +399,36 @@ static unsigned short vle_opcd_indices[VLE_OPCD_SEGS + 1];
 #define SPE2_OPCD_SEGS (1 + SPE2_XOP_TO_SEG (SPE2_XOP (-1)))
 static unsigned short spe2_opcd_indices[SPE2_OPCD_SEGS + 1];
 
+static bfd_boolean
+ppc_symbol_is_valid (asymbol *sym,
+		     struct disassemble_info *info ATTRIBUTE_UNUSED)
+{
+  elf_symbol_type * est;
+
+  if (sym == NULL)
+    return FALSE;
+
+  est = elf_symbol_from (NULL, sym);
+  
+  /* Ignore ELF hidden, local, no-type symbols.
+     These are generated by annobin.  */
+  if (est != NULL
+      && ELF_ST_VISIBILITY (est->internal_elf_sym.st_other) == STV_HIDDEN
+      && ELF_ST_BIND (est->internal_elf_sym.st_info) == STB_LOCAL
+      && ELF_ST_TYPE (est->internal_elf_sym.st_info) == STT_NOTYPE)
+    return FALSE;
+
+  return TRUE;
+}
+
 /* Calculate opcode table indices to speed up disassembly,
    and init dialect.  */
 
 void
 disassemble_init_powerpc (struct disassemble_info *info)
 {
+  info->symbol_is_valid = ppc_symbol_is_valid;
+
   if (powerpc_opcd_indices[PPC_OPCD_SEGS] == 0)
     {
       unsigned seg, idx, op;


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

only message in thread, other threads:[~2020-09-10 12:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 12:22 Commit: PPC: Ignore hidden local no-type symbols when disassembling Nick Clifton

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