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

* Re: [PATCH] Force mips16 disassembled addresses to odd values
  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
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Christopher @ 2006-04-28 19:29 UTC (permalink / raw)
  To: Thiemo Seufer; +Cc: binutils


On Apr 28, 2006, at 5:33 AM, Thiemo Seufer wrote:

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

Uh. What on earth? Could you explain this one? :)

-eric

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

* Re: [PATCH] Force mips16 disassembled addresses to odd values
  2006-04-28 19:29 ` Eric Christopher
@ 2006-04-28 19:39   ` Thiemo Seufer
  2006-04-28 20:36     ` Eric Christopher
  0 siblings, 1 reply; 6+ messages in thread
From: Thiemo Seufer @ 2006-04-28 19:39 UTC (permalink / raw)
  To: Eric Christopher; +Cc: binutils

Eric Christopher wrote:
> 
> On Apr 28, 2006, at 5:33 AM, Thiemo Seufer wrote:
> 
> >Hello All,
> >
> >this patch forces some disassembled mips16 addresses to odd values,
> >this helps gdb to handle mips16 code better.
> 
> Uh. What on earth? Could you explain this one? :)

Gdb has to find out what part is MIPS16 in mixed MIPS32/MIPS16 code
binaries. The code is used in MIPS' SDE6 toolchain, I don't know if
there are better ways like relying on DWARF info (in a detached file
for raw binaries?).


Thiemo

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

* Re: [PATCH] Force mips16 disassembled addresses to odd values
  2006-04-28 19:39   ` Thiemo Seufer
@ 2006-04-28 20:36     ` Eric Christopher
  2006-04-29  3:12       ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Christopher @ 2006-04-28 20:36 UTC (permalink / raw)
  To: Thiemo Seufer; +Cc: binutils


On Apr 28, 2006, at 11:14 AM, Thiemo Seufer wrote:

> Eric Christopher wrote:
>>
>> On Apr 28, 2006, at 5:33 AM, Thiemo Seufer wrote:
>>
>>> Hello All,
>>>
>>> this patch forces some disassembled mips16 addresses to odd values,
>>> this helps gdb to handle mips16 code better.
>>
>> Uh. What on earth? Could you explain this one? :)
>
> Gdb has to find out what part is MIPS16 in mixed MIPS32/MIPS16 code
> binaries. The code is used in MIPS' SDE6 toolchain, I don't know if
> there are better ways like relying on DWARF info (in a detached file
> for raw binaries?).

Good question. What's done for arm/thumb?

-eric

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

* Re: [PATCH] Force mips16 disassembled addresses to odd values
  2006-04-28 20:36     ` Eric Christopher
@ 2006-04-29  3:12       ` Daniel Jacobowitz
  2006-04-29  6:14         ` Eric Christopher
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2006-04-29  3:12 UTC (permalink / raw)
  To: Eric Christopher; +Cc: Thiemo Seufer, binutils

On Fri, Apr 28, 2006 at 11:20:24AM -0700, Eric Christopher wrote:
> >Gdb has to find out what part is MIPS16 in mixed MIPS32/MIPS16 code
> >binaries. The code is used in MIPS' SDE6 toolchain, I don't know if
> >there are better ways like relying on DWARF info (in a detached file
> >for raw binaries?).
> 
> Good question. What's done for arm/thumb?

Complicated.  But ARM's been moving to something along the same lines
as what Thiemo is doing: indicate Thumb-ness of a symbol by setting the
low bit, consistently.

-- 
Daniel Jacobowitz
CodeSourcery

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

* Re: [PATCH] Force mips16 disassembled addresses to odd values
  2006-04-29  3:12       ` Daniel Jacobowitz
@ 2006-04-29  6:14         ` Eric Christopher
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Christopher @ 2006-04-29  6:14 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Thiemo Seufer, binutils


On Apr 28, 2006, at 12:29 PM, Daniel Jacobowitz wrote:

> On Fri, Apr 28, 2006 at 11:20:24AM -0700, Eric Christopher wrote:
>>> Gdb has to find out what part is MIPS16 in mixed MIPS32/MIPS16 code
>>> binaries. The code is used in MIPS' SDE6 toolchain, I don't know if
>>> there are better ways like relying on DWARF info (in a detached file
>>> for raw binaries?).
>>
>> Good question. What's done for arm/thumb?
>
> Complicated.  But ARM's been moving to something along the same lines
> as what Thiemo is doing: indicate Thumb-ness of a symbol by setting  
> the
> low bit, consistently.

OK. I was just curious. It seemed well, odd :)

-eric

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