This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
sparc shared library gdb patch
- To: gdb-patches@cygnus.com
- Subject: sparc shared library gdb patch
- From: Per Bothner <bothner@cygnus.com>
- Date: Thu, 13 May 1999 14:49:12 -0700
Another patch that has been sitting in my tree.
This skips the shared library trampoline code.
However, I don't know if this is correct - it fixed one annoying
problem when I wrote it, but tha was a long time ago.
--Per Bothner
bothner@cygnus.com http://www.cygnus.com/~bothner
Index: config/sparc/tm-sun4sol2.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/config/sparc/tm-sun4sol2.h,v
retrieving revision 1.21
diff -u -p -r1.21 tm-sun4sol2.h
--- tm-sun4sol2.h 1998/04/11 05:43:33 1.21
+++ tm-sun4sol2.h 1999/05/13 21:18:24
@@ -92,3 +92,6 @@ extern char *procfs_pid_to_str PARAMS ((
#define target_pid_to_str(PID) procfs_pid_to_str (PID)
#endif
+
+#undef SKIP_TRAMPOLINE_CODE
+#define SKIP_TRAMPOLINE_CODE(pc) solaris2_skip_trampoline_code (pc)
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/sparc-tdep.c,v
retrieving revision 1.101
diff -u -p -r1.101 sparc-tdep.c
--- sparc-tdep.c 1999/04/28 10:04:15 1.101
+++ sparc-tdep.c 1999/05/13 21:18:24
@@ -1280,6 +1280,47 @@ sunos4_skip_trampoline_code (pc)
}
return find_solib_trampoline_target (pc);
}
+
+/* If pc is in a shared library trampoline, return its target.
+ The Solaris 2.x linker rewrites the jump table entries for PIC
+ compiled modules in the main executable to bypass the dynamic linker
+ with jumps of the form
+ sethi (. - .PLT0),%g1
+ sethi %hi(addr),%g1
+ jmp %g1+%lo(addr)
+ and removes the corresponding jump table relocation entry in the
+ dynamic relocations. */
+
+CORE_ADDR
+solaris2_skip_trampoline_code (pc)
+ CORE_ADDR pc;
+{
+ unsigned long insn0;
+ char buf[12];
+ int err;
+
+ err = target_read_memory (pc, buf, 12);
+ insn0 = extract_unsigned_integer (buf, 4);
+ if (err == 0 && (insn0 & 0xffc00000) == 0x03000000)
+ {
+ unsigned long insn1 = extract_unsigned_integer (buf+4, 4);
+ if ((insn1 & 0xffc00000) == 0x03000000)
+ {
+ unsigned long insn2 = extract_unsigned_integer (buf+8, 4);
+ if ((insn2 & 0xffffe000) == 0x81c06000)
+ {
+ CORE_ADDR target_pc = (insn1 & 0x3fffff) << 10;
+ int delta = insn2 & 0x1fff;
+
+ /* Sign extend the displacement. */
+ if (delta & 0x1000)
+ delta |= ~0x1fff;
+ return target_pc + delta;
+ }
+ }
+ }
+ return find_solib_trampoline_target (pc);
+}
#ifdef USE_PROC_FS /* Target dependent support for /proc */