GNU Binutils with patches for OS216
修訂 | f3a32a2d04af5bfb77b2cd2913f131b243cee0ec (tree) |
---|---|
時間 | 2003-06-11 17:54:54 |
作者 | Jim Blandy <jimb@code...> |
Commiter | 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.
@@ -1,5 +1,10 @@ | ||
1 | 1 | 2003-06-11 Jim Blandy <jimb@redhat.com> |
2 | 2 | |
3 | + * ppc-linux-tdep.c (ppc64_linux_convert_from_func_ptr_addr): New | |
4 | + function. | |
5 | + (ppc_linux_init_abi): Register it as the | |
6 | + CONVERT_FROM_FUNC_PTR_ADDR method under the PPC64 Linux ABI. | |
7 | + | |
3 | 8 | * ppc-linux-tdep.c (ppc_linux_init_abi): long doubles are 16 bytes |
4 | 9 | long. |
5 | 10 |
@@ -894,6 +894,39 @@ ppc64_skip_trampoline_code (CORE_ADDR pc) | ||
894 | 894 | } |
895 | 895 | |
896 | 896 | |
897 | +/* Support for CONVERT_FROM_FUNC_PTR_ADDR(ADDR). | |
898 | + | |
899 | + Usually a function pointer's representation is simply the address | |
900 | + of the function. On the RS/6000 however, a function pointer is | |
901 | + represented by a pointer to a TOC entry. This TOC entry contains | |
902 | + three words, the first word is the address of the function, the | |
903 | + second word is the TOC pointer (r2), and the third word is the | |
904 | + static chain value. Throughout GDB it is currently assumed that a | |
905 | + function pointer contains the address of the function, which is not | |
906 | + easy to fix. In addition, the conversion of a function address to | |
907 | + a function pointer would require allocation of a TOC entry in the | |
908 | + inferior's memory space, with all its drawbacks. To be able to | |
909 | + call C++ virtual methods in the inferior (which are called via | |
910 | + function pointers), find_function_addr uses this function to get the | |
911 | + function address from a function pointer. */ | |
912 | + | |
913 | +/* Return real function address if ADDR (a function pointer) is in the data | |
914 | + space and is therefore a special function pointer. */ | |
915 | + | |
916 | +static CORE_ADDR | |
917 | +ppc64_linux_convert_from_func_ptr_addr (CORE_ADDR addr) | |
918 | +{ | |
919 | + struct obj_section *s; | |
920 | + | |
921 | + s = find_pc_section (addr); | |
922 | + if (s && s->the_bfd_section->flags & SEC_CODE) | |
923 | + return addr; | |
924 | + | |
925 | + /* ADDR is in the data space, so it's a special function pointer. */ | |
926 | + return ppc64_desc_entry_point (addr); | |
927 | +} | |
928 | + | |
929 | + | |
897 | 930 | /* On 64-bit PowerPC Linux, the ELF header's e_entry field is the |
898 | 931 | address of a function descriptor for the entry point function, not |
899 | 932 | the actual entry point itself. So to find the actual address at |
@@ -1029,6 +1062,11 @@ ppc_linux_init_abi (struct gdbarch_info info, | ||
1029 | 1062 | { |
1030 | 1063 | set_gdbarch_long_double_bit (gdbarch, 16 * TARGET_CHAR_BIT); |
1031 | 1064 | |
1065 | + /* Handle PPC64 Linux function pointers (which are really | |
1066 | + function descriptors). */ | |
1067 | + set_gdbarch_convert_from_func_ptr_addr | |
1068 | + (gdbarch, ppc64_linux_convert_from_func_ptr_addr); | |
1069 | + | |
1032 | 1070 | set_gdbarch_call_dummy_address (gdbarch, ppc64_call_dummy_address); |
1033 | 1071 | |
1034 | 1072 | set_gdbarch_in_solib_call_trampoline |