From: Jim Blandy <jimb@redhat.com>
To: Kevin Buettner <kevinb@redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [ppc64-linux]: register CONVERT_FROM_FUNC_PTR_ADDR method
Date: Thu, 12 Jun 2003 21:11:00 -0000 [thread overview]
Message-ID: <vt2he6vt30c.fsf@zenia.home> (raw)
In-Reply-To: <1030611224249.ZM27163@localhost.localdomain>
Kevin Buettner <kevinb@redhat.com> writes:
> On Jun 11, 3:53am, Jim Blandy wrote:
>
> > 2003-06-11 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.
>
> Okay, but could you revise the comment to not mention RS/6000 and
> to make it clear that the representation in question only pertains
> to the 64-bit ABI?
How's this?
2003-06-11 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.
Index: gdb/ppc-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
retrieving revision 1.28.8.17
diff -c -r1.28.8.17 ppc-linux-tdep.c
*** gdb/ppc-linux-tdep.c 12 Jun 2003 21:09:22 -0000 1.28.8.17
--- gdb/ppc-linux-tdep.c 12 Jun 2003 21:09:42 -0000
***************
*** 894,899 ****
--- 894,934 ----
}
+ /* 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,1032 ****
--- 1062,1072 ----
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
next prev parent reply other threads:[~2003-06-12 21:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-11 8:52 Jim Blandy
2003-06-11 22:42 ` Kevin Buettner
2003-06-12 21:11 ` Jim Blandy [this message]
2003-06-12 21:44 ` Kevin Buettner
2003-06-13 4:48 ` Richard Henderson
2003-06-13 6:17 ` Kevin Buettner
2003-06-13 22:54 ` Andrew Cagney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vt2he6vt30c.fsf@zenia.home \
--to=jimb@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=kevinb@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox