]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* ppc-linux-tdep.c (ppc64_linux_convert_from_func_ptr_addr): New
authorJim Blandy <jimb@codesourcery.com>
Fri, 13 Jun 2003 23:10:03 +0000 (23:10 +0000)
committerJim Blandy <jimb@codesourcery.com>
Fri, 13 Jun 2003 23:10:03 +0000 (23:10 +0000)
function.
(ppc_linux_init_abi): Register it as the
CONVERT_FROM_FUNC_PTR_ADDR method under the PPC64 Linux ABI.

gdb/ChangeLog
gdb/ppc-linux-tdep.c

index 990f5d23be5ddb7ae4eaba89d570637e75a0fe3b..666d50f1735773259368cf89815d44b48bf6c81f 100644 (file)
@@ -1,5 +1,10 @@
 2003-06-13  Jim Blandy  <jimb@redhat.com>
 
+       * ppc-linux-tdep.c (ppc64_linux_convert_from_func_ptr_addr): New
+       function.
+       (ppc_linux_init_abi): Register it as the
+       CONVERT_FROM_FUNC_PTR_ADDR method under the PPC64 Linux ABI.
+
        * ppc-linux-tdep.c (ppc64_call_dummy_address): New function.
        (ppc_linux_init_abi): Set it as the gdbarch's call_dummy_address
        method.
index 600f5f20e3d302ddae3a041e9ace32f8cdde2c9a..54d5d9ae9e8d9efb3ed4100b7ef25a3b2eb11f9c 100644 (file)
@@ -894,6 +894,41 @@ ppc64_skip_trampoline_code (CORE_ADDR pc)
 }
 
 
+/* Support for CONVERT_FROM_FUNC_PTR_ADDR(ADDR) on PPC64 Linux.
+
+   Usually a function pointer's representation is simply the address
+   of the function. On Linux on the 64-bit PowerPC however, a function
+   pointer is represented by a pointer to a TOC entry. This TOC entry
+   contains three words, the first word is the address of the
+   function, the second word is the TOC pointer (r2), and the third
+   word is the static chain value.  Throughout GDB it is currently
+   assumed that a function pointer contains the address of the
+   function, which is not easy to fix.  In addition, the conversion of
+   a function address to a function pointer would require allocation
+   of a TOC entry in the inferior's memory space, with all its
+   drawbacks.  To be able to call C++ virtual methods in the inferior
+   (which are called via function pointers), 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.  */
+
+static CORE_ADDR
+ppc64_linux_convert_from_func_ptr_addr (CORE_ADDR addr)
+{
+  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);
+}
+
+
 /* On 64-bit PowerPC Linux, the ELF header's e_entry field is the
    address of a function descriptor for the entry point function, not
    the actual entry point itself.  So to find the actual address at
@@ -1027,6 +1062,11 @@ ppc_linux_init_abi (struct gdbarch_info info,
   
   if (tdep->wordsize == 8)
     {
+      /* Handle PPC64 Linux function pointers (which are really
+         function descriptors).  */
+      set_gdbarch_convert_from_func_ptr_addr
+        (gdbarch, ppc64_linux_convert_from_func_ptr_addr);
+
       set_gdbarch_call_dummy_address (gdbarch, ppc64_call_dummy_address);
 
       set_gdbarch_in_solib_call_trampoline