public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Force mips16 disassembled addresses to odd values
@ 2006-04-28 16:37 Thiemo Seufer
  2006-04-28 19:29 ` Eric Christopher
  0 siblings, 1 reply; 6+ messages in thread
From: Thiemo Seufer @ 2006-04-28 16:37 UTC (permalink / raw)
  To: binutils

Hello All,

this patch forces some disassembled mips16 addresses to odd values,
this helps gdb to handle mips16 code better.


Thiemo


2006-04-28  Thiemo Seufer  <ths@mips.com>
            Nigel Stevens  <nigel@mips.com>
            David Ung  <davidu@mips.com>

	* mips-dis.c (print_insn_args): Add mips_opcode argument. Use
	it to keep mips16 addresses odd.
	(print_insn_mips):  Adjust print_insn_args call.
	(print_mips16_insn_arg): Force mips16 to odd addresses.


Index: opcodes/mips-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/mips-dis.c,v
retrieving revision 1.55
diff -u -p -r1.55 mips-dis.c
--- opcodes/mips-dis.c	14 Nov 2005 02:25:39 -0000	1.55
+++ opcodes/mips-dis.c	27 Apr 2006 12:53:39 -0000
@@ -688,7 +714,8 @@ static void
 print_insn_args (const char *d,
 		 register unsigned long int l,
 		 bfd_vma pc,
-		 struct disassemble_info *info)
+		 struct disassemble_info *info,
+		 const struct mips_opcode *opp)
 {
   int op, delta;
   unsigned int lsb, msb, msbd;
@@ -939,6 +966,10 @@ print_insn_args (const char *d,
 	case 'a':
 	  info->target = (((pc + 4) & ~(bfd_vma) 0x0fffffff)
 			  | (((l >> OP_SH_TARGET) & OP_MASK_TARGET) << 2));
+	  /* For gdb disassembler, force odd address on jalx.  */
+	  if (info->flavour == bfd_target_unknown_flavour
+	      && strcmp (opp->name, "jalx") == 0)
+	    info->target |= 1;
 	  (*info->print_address_func) (info->target, info);
 	  break;
 
@@ -1247,7 +1280,7 @@ print_insn_mips (bfd_vma memaddr,
 	      if (d != NULL && *d != '\0')
 		{
 		  (*info->fprintf_func) (info->stream, "\t");
-		  print_insn_args (d, word, memaddr, info);
+		  print_insn_args (d, word, memaddr, info, op);
 		}
 
 	      return INSNLEN;
@@ -1585,15 +1618,26 @@ print_mips16_insn_arg (char type,
 		  }
 	      }
 	    info->target = (baseaddr & ~((1 << shift) - 1)) + immed;
+	    if (pcrel && branch
+		&& info->flavour == bfd_target_unknown_flavour)
+	      /* For gdb disassembler, maintain odd address.  */
+	      info->target |= 1;
 	    (*info->print_address_func) (info->target, info);
 	  }
       }
       break;
 
     case 'a':
-      if (! use_extend)
-	extend = 0;
-      l = ((l & 0x1f) << 23) | ((l & 0x3e0) << 13) | (extend << 2);
+      {
+	int jalx = l & 0x400;
+
+	if (! use_extend)
+	  extend = 0;
+	l = ((l & 0x1f) << 23) | ((l & 0x3e0) << 13) | (extend << 2);
+	if (!jalx && info->flavour == bfd_target_unknown_flavour)
+	  /* For gdb disassembler, maintain odd address.  */
+	  l |= 1;
+      }
       info->target = ((memaddr + 4) & ~(bfd_vma) 0x0fffffff) | l;
       (*info->print_address_func) (info->target, info);
       info->insn_type = dis_jsr;

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-04-28 20:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-28 16:37 [PATCH] Force mips16 disassembled addresses to odd values Thiemo Seufer
2006-04-28 19:29 ` Eric Christopher
2006-04-28 19:39   ` Thiemo Seufer
2006-04-28 20:36     ` Eric Christopher
2006-04-29  3:12       ` Daniel Jacobowitz
2006-04-29  6:14         ` Eric Christopher

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