From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27561 invoked by alias); 11 Jun 2003 08:52:43 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 27429 invoked from network); 11 Jun 2003 08:52:42 -0000 Received: from unknown (HELO zenia.home) (12.223.225.216) by sources.redhat.com with SMTP; 11 Jun 2003 08:52:42 -0000 Received: by zenia.home (Postfix, from userid 5433) id 0DB9420FE6; Wed, 11 Jun 2003 03:53:54 -0500 (EST) To: gdb-patches@sources.redhat.com Subject: [ppc64-linux]: register CONVERT_FROM_FUNC_PTR_ADDR method From: Jim Blandy Date: Wed, 11 Jun 2003 08:52:00 -0000 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-06/txt/msg00356.txt.bz2 2003-06-11 Jim Blandy * 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.14 diff -c -r1.28.8.14 ppc-linux-tdep.c *** gdb/ppc-linux-tdep.c 11 Jun 2003 06:46:17 -0000 1.28.8.14 --- gdb/ppc-linux-tdep.c 11 Jun 2003 08:48:28 -0000 *************** *** 894,899 **** --- 894,932 ---- } + /* Support for CONVERT_FROM_FUNC_PTR_ADDR(ADDR). + + Usually a function pointer's representation is simply the address + of the function. On the RS/6000 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 special function pointer. */ + 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 *************** *** 1028,1033 **** --- 1061,1071 ---- if (tdep->wordsize == 8) { set_gdbarch_long_double_bit (gdbarch, 16 * TARGET_CHAR_BIT); + + /* 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);