This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] MIPS: Fix the PIC trampoline interpreter


Hi,

 I have committed the change below fixing a problem where the PIC 
trampoline interpreter did not properly sign-extend the 16-bit low part of 
the address retrieved from the immediate field of the ADDIU instruction 
from the LUI/ADDIU pair used by PIC stubs.  This caused incorrect 
calculation of the PC where the address had the bit #15 set (no borrow 
from the high part).  Found by code inspection while working on some 
issues around MIPS16 thunks.

2011-04-10  Maciej W. Rozycki  <macro@codesourcery.com>

	gdb/
	* mips-tdep.c (mips_skip_pic_trampoline_code): Correct sign 
	extension in jump target calculation.

  Maciej

gdb-mips-pic-stub.diff
Index: gdb-fsf-trunk-quilt/gdb/mips-tdep.c
===================================================================
--- gdb-fsf-trunk-quilt.orig/gdb/mips-tdep.c	2012-04-05 19:43:22.275612436 +0100
+++ gdb-fsf-trunk-quilt/gdb/mips-tdep.c	2012-04-05 19:43:24.775614289 +0100
@@ -6089,8 +6089,8 @@ mips_skip_pic_trampoline_code (struct fr
 	  && (stub_words[1] & 0xfc000000U) == 0x08000000
 	  && (stub_words[2] & 0xffff0000U) == 0x27390000
 	  && stub_words[3] == 0x00000000)
-	return (((stub_words[0] & 0x0000ffff) << 16)
-		+ (stub_words[2] & 0x0000ffff));
+	return ((((stub_words[0] & 0x0000ffff) << 16)
+		 + (stub_words[2] & 0x0000ffff)) ^ 0x8000) - 0x8000;
     }
 
   /* Not a recognized stub.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]