Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfa/ppc64] Only map descriptors to code addresses
@ 2003-09-19 18:51 Andrew Cagney
  2003-09-22 22:07 ` Kevin Buettner
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2003-09-19 18:51 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 424 bytes --]

Hello,

This patch modifies ppc64's convert_from_func_ptr_addr so that it only 
converts a descriptor to the code address when it's sure it's got a 
descriptor.  This way, of the function gets fed a random address, it 
doesn't map it onto something even more random - I encountered this when 
trying to debug "break main" with only a minimal symbol table.

This also makes the behavior consistent with the ia64.

ok?
Andrew

[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 1574 bytes --]

2003-09-19  Andrew Cagney  <cagney@redhat.com>

	* ppc-linux-tdep.c (ppc64_linux_convert_from_func_ptr_addr): Only
	convert a descriptor to a function when it's in the ".opd"
	section.

Index: ppc-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
retrieving revision 1.40
diff -u -r1.40 ppc-linux-tdep.c
--- ppc-linux-tdep.c	16 Sep 2003 23:33:17 -0000	1.40
+++ ppc-linux-tdep.c	19 Sep 2003 18:42:20 -0000
@@ -925,8 +925,10 @@
    find_function_addr uses this function to get the function address
    from a function pointer.  */
 
-/* Return real function address if ADDR (a function pointer) is in the data
-   space and is therefore a special function pointer.  */
+/* If ADDR points at what is clearly a function descriptor, transform
+   it into the address of the corresponding function.  Be
+   conservative, otherwize GDB will do the transformation on any
+   random addresses such as occures when there is no symbol table.  */
 
 static CORE_ADDR
 ppc64_linux_convert_from_func_ptr_addr (CORE_ADDR addr)
@@ -934,12 +936,12 @@
   struct obj_section *s;
 
   s = find_pc_section (addr);
-  if (s && s->the_bfd_section->flags & SEC_CODE)
-    return addr;
 
-  /* ADDR is in the data space, so it's a pointer to a descriptor, not
-     the entry point.  */
-  return ppc64_desc_entry_point (addr);
+  /* Check if ADDR points to a function descriptor.  */
+  if (s && strcmp (s->the_bfd_section->name, ".opd") == 0)
+    return read_memory_unsigned_integer (addr, 8);
+
+  return addr;
 }
 
 

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

end of thread, other threads:[~2003-10-03 20:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-19 18:51 [rfa/ppc64] Only map descriptors to code addresses Andrew Cagney
2003-09-22 22:07 ` Kevin Buettner
2003-10-03 20:49   ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox