public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-jankratochvil-ifunc: fixup
@ 2010-02-14 19:16 jkratoch
  0 siblings, 0 replies; 4+ messages in thread
From: jkratoch @ 2010-02-14 19:16 UTC (permalink / raw)
  To: archer-commits

The branch, archer-jankratochvil-ifunc has been updated
       via  9784a199c6f322e993810adfb011db6437c50e37 (commit)
       via  a18b544afaa99ae26d3de6f74fd35f83090e0646 (commit)
      from  000b2824aeac703bb39f41fca1dc37233dd69ca3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 9784a199c6f322e993810adfb011db6437c50e37
Author: Jan Kratochvil <jkratoch@host1.dyn.jankratochvil.net>
Date:   Sun Feb 14 20:16:26 2010 +0100

    fixup

commit a18b544afaa99ae26d3de6f74fd35f83090e0646
Author: Jan Kratochvil <jkratoch@host1.dyn.jankratochvil.net>
Date:   Sun Feb 14 20:00:24 2010 +0100

    ChangeLog entry
    
    gdb/
    2010-02-14  Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	Transparent STT_GNU_IFUNC support.
    	* alpha-linux-tdep.c: Include linux-tdep.h.
    	(alpha_linux_init_abi): Install linux_convert_from_func_ptr_addr.
    	* amd64-linux-tdep.c (amd64_linux_init_abi): Install
    	linux_convert_from_func_ptr_addr.
    	* arm-linux-tdep.c (arm_linux_init_abi): Install
    	linux_convert_from_func_ptr_addr.
    	* configure.tgt (alpha*-*-linux*, am33_2.0*-*-linux*, ia64-*-linux*)
    	(m32r*-*-linux*, microblaze*-linux-*, mips*-*-linux*, sh*-*-linux*)
    	(sparc-*-linux*, sparc64-*-linux*, xtensa*-*-linux*): Add linux-tdep.o
    	to gdb_target_obs.
    	* elfread.c (record_minimal_symbol): Apply also for mst_text_gnu_ifunc.
    	(elf_symtab_read) <sym->flags & BSF_GNU_INDIRECT_FUNCTION>: New.
    	* frv-linux-tdep.c: Include linux-tdep.h.
    	(frv_linux_convert_from_func_ptr_addr): New.
    	(frv_linux_regset_from_core_section):
    	(frv_linux_init_abi):
    	* frv-tdep.c (find_func_descr):
    	* frv-tdep.h (CORE_ADDR):
    	* gdbtypes.c (init_type):
    	(gdbtypes_post_init):
    	(objfile_type):
    	* gdbtypes.h (enum):
    	(struct):
    	* hppa-linux-tdep.c (hppa_linux_regset_from_core_section):
    	(hppa_linux_init_abi):
    	* hppa-tdep.c (hppa64_return_value):
    	* hppa-tdep.h (extern):
    	* i386-linux-tdep.c (i386_linux_init_abi):
    	* ia64-linux-tdep.c (ia64_linux_init_abi):
    	* linux-tdep.c (linux_has_shared_address_space):
    	* linux-tdep.h:
    	* m32r-linux-tdep.c (m32r_linux_init_abi):
    	* microblaze-linux-tdep.c (microblaze_linux_init_abi):
    	* minsyms.c (lookup_minimal_symbol_text):
    	(lookup_minimal_symbol_by_pc):
    	(prim_record_minimal_symbol):
    	(find_solib_trampoline_target):
    	* mips-linux-tdep.c (mips_linux_init_abi):
    	* mn10300-linux-tdep.c (am33_linux_init_osabi):
    	* objc-lang.c (find_methods):
    	* parse.c (write_exp_msymbol):
    	* ppc-linux-tdep.c (ppc64_skip_trampoline_code):
    	(ppc64_linux_convert_from_func_ptr_addr):
    	(ppc_linux_init_abi):
    	* sh-linux-tdep.c (sh_linux_init_abi):
    	* solib-svr4.c (svr4_in_dynsym_resolve_code):
    	* sparc-linux-tdep.c (sparc32_linux_init_abi):
    	* sparc64-linux-tdep.c (sparc64_linux_init_abi):
    	* symmisc.c (dump_msymbols):
    	* symtab.c (search_symbols):
    	* symtab.h:
    	* xtensa-linux-tdep.c (xtensa_linux_init_abi):
    
    gdb/testsuite/
    2010-02-14  Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	Transparent STT_GNU_IFUNC support.
    	* gdb.base/gnu-ifunc-lib.c, gdb.base/gnu-ifunc.c,
    	gdb.base/gnu-ifunc.exp: New.
    
    ------------------------------------------------------------------------------
    
    gdb/
    2009-11-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	Transparent GNU-IFUNCs support.
    	* gdbtypes.c (init_type): Support TYPE_FLAG_GNU_IFUNC.
    	(gdbtypes_post_init): Initialize builtin_func_func_ptr.
    	(objfile_type): Initialize nodebug_text_gnu_ifunc_symbol.
    	* gdbtypes.h (enum type_flag_value <TYPE_FLAG_GNU_IFUNC>)
    	(TYPE_GNU_IFUNC, struct main_type <flag_gnu_ifunc>)
    	(struct builtin_type <builtin_func_func_ptr>)
    	(struct objfile_type <nodebug_text_gnu_ifunc_symbol>): New.
    	* infcall.c (find_function_addr <TYPE_GNU_IFUNC (ftype)>): New.
    	* minsyms.c (lookup_minimal_symbol_text, prim_record_minimal_symbol)
    	(find_solib_trampoline_target): Support also mst_text_gnu_ifunc.
    	(in_gnu_ifunc_stub): New.
    	* parse.c (write_exp_msymbol <mst_text_gnu_ifunc>): New.
    	* solib-svr4.c (svr4_in_dynsym_resolve_code): Call also
    	in_gnu_ifunc_stub.
    	* symmisc.c (dump_msymbols <mst_text_gnu_ifunc>): New.
    	* symtab.c (search_symbols): Support also mst_text_gnu_ifunc.
    	* symtab.h (enum minimal_symbol_type <mst_text_gnu_ifunc>)
    	(in_gnu_ifunc_stub): New.
    	* linespec.c: Include infcall.h.
    	(minsym_found <MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc>): New.
    
    gdb/testsuite/
    2009-11-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	Transparent GNU-IFUNCs support.
    	* gdb.base/gnu-ifunc-lib.c, gdb.base/gnu-ifunc.c,
    	gdb.base/gnu-ifunc.exp: New.

-----------------------------------------------------------------------

Summary of changes:
 gdb/frv-linux-tdep.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

First 500 lines of diff:
diff --git a/gdb/frv-linux-tdep.c b/gdb/frv-linux-tdep.c
index 3e5ce38..f386dfd 100644
--- a/gdb/frv-linux-tdep.c
+++ b/gdb/frv-linux-tdep.c
@@ -515,6 +515,9 @@ frv_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   if (frv_abi (gdbarch) == FRV_ABI_FDPIC)
     set_gdbarch_convert_from_func_ptr_addr (gdbarch,
 					  frv_linux_convert_from_func_ptr_addr);
+  else
+    set_gdbarch_convert_from_func_ptr_addr (gdbarch,
+					    linux_convert_from_func_ptr_addr);
 }
 
 static enum gdb_osabi


hooks/post-receive
--
Repository for Project Archer.


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

* [SCM]  archer-jankratochvil-ifunc: fixup
@ 2010-02-14 17:09 jkratoch
  0 siblings, 0 replies; 4+ messages in thread
From: jkratoch @ 2010-02-14 17:09 UTC (permalink / raw)
  To: archer-commits

The branch, archer-jankratochvil-ifunc has been updated
       via  000b2824aeac703bb39f41fca1dc37233dd69ca3 (commit)
      from  c3ec4d8d2ec0c1ce05f2537077a959b4b14b1f98 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 000b2824aeac703bb39f41fca1dc37233dd69ca3
Author: Jan Kratochvil <jkratoch@host1.dyn.jankratochvil.net>
Date:   Sun Feb 14 18:05:38 2010 +0100

    fixup

-----------------------------------------------------------------------

Summary of changes:
 gdb/linux-tdep.c                     |   37 +++++++++++++++++++++++-----------
 gdb/parse.c                          |   14 ++++++++++++-
 gdb/testsuite/gdb.base/gnu-ifunc.exp |    2 +-
 3 files changed, 39 insertions(+), 14 deletions(-)

First 500 lines of diff:
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 1ccdf11..9278291 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -157,13 +157,13 @@ linux_has_shared_address_space (void)
 
 /* Call gnu-ifunc (STT_GNU_IFUNC - a function returning addresss of a real
    function to call) to resolve breakpoint at its returned function.  FUNC_PTR
-   is the function pointer (possible function descriptor), PC is the real
-   function code.  Use linux_convert_from_func_ptr_addr if no function
-   descriptors need to be resolved on the platform. FUNC_PTR is equal to PC on
-   platforms without function descriptors.  Function returns FUNC_PTR if no
-   gnu-ifunc has been found, otherwise it returns address of the resolved
-   function address to call.  Returned address is always the possible address
-   of function descriptor.  */
+   is the function pointer (possibly function descriptor), PC is the function
+   entry.  Use linux_convert_from_func_ptr_addr if no function descriptors need
+   to be resolved on the platform.  FUNC_PTR is equal to PC on platforms
+   without function descriptors.  Function returns FUNC_PTR if no gnu-ifunc has
+   been found, otherwise it returns address of the gnu-ifunc-resolved function
+   to call.  Returned address is always the type of address possibly being
+   a function descriptor.  */
 
 CORE_ADDR
 linux_convert_from_func_and_ptr (struct gdbarch *gdbarch, CORE_ADDR func_ptr,
@@ -176,14 +176,27 @@ linux_convert_from_func_and_ptr (struct gdbarch *gdbarch, CORE_ADDR func_ptr,
   if (!target_has_execution)
     return func_ptr;
 
-  msymbol = lookup_minimal_symbol_by_pc (func_ptr);
+  if (func_ptr != pc)
+    {
+      /* Verify FUNC_PTR is a function descriptor.  */
+
+      msymbol = lookup_minimal_symbol_by_pc (func_ptr);
+      if (msymbol == NULL)
+	return func_ptr;
+      if (MSYMBOL_TYPE (msymbol) != mst_data)
+	return func_ptr;
+      if (SYMBOL_VALUE_ADDRESS (msymbol) != func_ptr)
+	return func_ptr;
+    }
+
+  /* Verify PC is a function entry point.  */
+
+  msymbol = lookup_minimal_symbol_by_pc (pc);
   if (msymbol == NULL)
     return func_ptr;
   if (MSYMBOL_TYPE (msymbol) != mst_text_gnu_ifunc)
     return func_ptr;
-
-  /* Not at the gnu-ifunc entry point?  */
-  if (SYMBOL_VALUE_ADDRESS (msymbol) != func_ptr)
+  if (SYMBOL_VALUE_ADDRESS (msymbol) != pc)
     return func_ptr;
 
   function = allocate_value (func_func_type);
@@ -201,7 +214,7 @@ linux_convert_from_func_and_ptr (struct gdbarch *gdbarch, CORE_ADDR func_ptr,
    linux_convert_from_func_and_ptr if the platform requires also a function
    descriptor resolution.  ADDR is address of the possibly-gnu-ifunc function.
    Function returns ADDR if no gnu-ifunc has been found, otherwise it returns
-   address of the resolved function address to call.  */
+   address of the resolved function to call.  */
 
 CORE_ADDR
 linux_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr,
diff --git a/gdb/parse.c b/gdb/parse.c
index 4d95ac1..cc90199 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -489,9 +489,21 @@ write_exp_msymbol (struct minimal_symbol *msymbol)
   pc = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, &current_target);
   if (pc != addr)
     {
+      struct minimal_symbol *ifunc_msym = lookup_minimal_symbol_by_pc (pc);
+
       /* In this case, assume we have a code symbol instead of
 	 a data symbol.  */
-      type = mst_text;
+
+      if (ifunc_msym != NULL && MSYMBOL_TYPE (ifunc_msym) == mst_text_gnu_ifunc
+	  && SYMBOL_VALUE_ADDRESS (ifunc_msym) == pc)
+	{
+	  /* A function descriptor has been resolved but PC is still in the
+	     gnu-ifunc resolver body (such as because inferior does not run to
+	     be able to call it).  */
+	  type = mst_text_gnu_ifunc;
+	}
+      else
+	type = mst_text;
       section = NULL;
       addr = pc;
     }
diff --git a/gdb/testsuite/gdb.base/gnu-ifunc.exp b/gdb/testsuite/gdb.base/gnu-ifunc.exp
index f2d93af..7a658a5 100644
--- a/gdb/testsuite/gdb.base/gnu-ifunc.exp
+++ b/gdb/testsuite/gdb.base/gnu-ifunc.exp
@@ -128,5 +128,5 @@ gdb_test "info sym $expect_out(1,string)" "gnu_ifunc in section .*" "info sym <g
 
 clean_restart $lib_nodebug_so_base
 
-gdb_test "p gnu_ifunc" " = {<text gnu-ifunc variable, no debug info>} 0x\[0-9a-f\]+ <gnu_ifunc>" "p gnu_ifunc not executing without debug"
+gdb_test "p gnu_ifunc" " = {<text gnu-ifunc variable, no debug info>} 0x\[0-9a-f\]+ <\.?gnu_ifunc>" "p gnu_ifunc not executing without debug"
 gdb_test "info sym gnu_ifunc" "gnu_ifunc in section .*" "info sym gnu_ifunc not executing without debug"


hooks/post-receive
--
Repository for Project Archer.


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

* [SCM]  archer-jankratochvil-ifunc: fixup
@ 2010-02-14 16:25 jkratoch
  0 siblings, 0 replies; 4+ messages in thread
From: jkratoch @ 2010-02-14 16:25 UTC (permalink / raw)
  To: archer-commits

The branch, archer-jankratochvil-ifunc has been updated
       via  d4f4122a56c1b55128972da009e157a329b0da7c (commit)
      from  91da8238770d28329797d6e7833ccaaaff28d803 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit d4f4122a56c1b55128972da009e157a329b0da7c
Author: Jan Kratochvil <jkratoch@host1.dyn.jankratochvil.net>
Date:   Sun Feb 14 17:25:40 2010 +0100

    fixup

-----------------------------------------------------------------------

Summary of changes:
 gdb/linux-tdep.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

First 500 lines of diff:
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 3625165..1ccdf11 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -174,17 +174,17 @@ linux_convert_from_func_and_ptr (struct gdbarch *gdbarch, CORE_ADDR func_ptr,
   struct value *function, *address;
 
   if (!target_has_execution)
-    return pc;
+    return func_ptr;
 
   msymbol = lookup_minimal_symbol_by_pc (func_ptr);
   if (msymbol == NULL)
-    return pc;
+    return func_ptr;
   if (MSYMBOL_TYPE (msymbol) != mst_text_gnu_ifunc)
-    return pc;
+    return func_ptr;
 
   /* Not at the gnu-ifunc entry point?  */
   if (SYMBOL_VALUE_ADDRESS (msymbol) != func_ptr)
-    return pc;
+    return func_ptr;
 
   function = allocate_value (func_func_type);
   set_value_address (function, pc);


hooks/post-receive
--
Repository for Project Archer.


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

* [SCM]  archer-jankratochvil-ifunc: fixup
@ 2010-02-14 15:37 jkratoch
  0 siblings, 0 replies; 4+ messages in thread
From: jkratoch @ 2010-02-14 15:37 UTC (permalink / raw)
  To: archer-commits

The branch, archer-jankratochvil-ifunc has been updated
       via  840d2c94dca8cf239e9e480c402c47b6a1bff704 (commit)
       via  528466fbc13632104bd1227ffbfaaa5e6dc043a0 (commit)
      from  2f6ba20293ecd4608a4cf726c149037c80875907 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 840d2c94dca8cf239e9e480c402c47b6a1bff704
Author: Jan Kratochvil <jkratoch@host1.dyn.jankratochvil.net>
Date:   Sun Feb 14 16:34:37 2010 +0100

    fixup

commit 528466fbc13632104bd1227ffbfaaa5e6dc043a0
Author: Jan Kratochvil <jkratoch@host1.dyn.jankratochvil.net>
Date:   Sun Feb 14 16:02:38 2010 +0100

    fixup

-----------------------------------------------------------------------

Summary of changes:
 gdb/frv-linux-tdep.c  |   10 ++++++----
 gdb/frv-tdep.c        |    3 +++
 gdb/gdbtypes.h        |    2 +-
 gdb/hppa-linux-tdep.c |   10 ++++++----
 gdb/hppa-tdep.c       |    4 +++-
 gdb/infcall.c         |   14 +++-----------
 gdb/linux-tdep.c      |   17 ++++++++++++++++-
 gdb/ppc-linux-tdep.c  |   47 ++++++++++++++++++++++++++---------------------
 8 files changed, 64 insertions(+), 43 deletions(-)

First 500 lines of diff:
diff --git a/gdb/frv-linux-tdep.c b/gdb/frv-linux-tdep.c
index 5b07063..3e5ce38 100644
--- a/gdb/frv-linux-tdep.c
+++ b/gdb/frv-linux-tdep.c
@@ -487,17 +487,19 @@ frv_linux_regset_from_core_section (struct gdbarch *gdbarch,
   return NULL;
 }
 
+/* Resolve both gnu-ifunc function addresses and function descriptors.  */
+
 static CORE_ADDR
 frv_linux_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
 				      CORE_ADDR addr,
 				      struct target_ops *targ)
 {
   CORE_ADDR pc = frv_convert_from_func_ptr_addr (gdbarch, addr, targ);
-  CORE_ADDR resolved;
+  CORE_ADDR resolved_addr;
 
-  resolved = linux_convert_from_func_and_ptr (gdbarch, addr, pc);
-  if (resolved != pc)
-    pc = frv_convert_from_func_ptr_addr (gdbarch, resolved, targ);
+  resolved_addr = linux_convert_from_func_and_ptr (gdbarch, addr, pc);
+  if (resolved_addr != addr)
+    pc = frv_convert_from_func_ptr_addr (gdbarch, resolved_addr, targ);
 
   return pc;
 }
diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c
index b8856a9..392108a 100644
--- a/gdb/frv-tdep.c
+++ b/gdb/frv-tdep.c
@@ -1169,6 +1169,9 @@ find_func_descr (struct gdbarch *gdbarch, CORE_ADDR entry_point)
   return descr;
 }
 
+/* Resolve function descriptors.  Return ADDR if no function descriptor was
+   found.  */
+
 CORE_ADDR
 frv_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr,
                                 struct target_ops *targ)
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index cd3eaef..a9116e8 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -272,7 +272,7 @@ enum type_instance_flag_value
 
 #define TYPE_NOTTEXT(t)		(TYPE_MAIN_TYPE (t)->flag_nottext)
 
-/* Currently used only for TYPE_CODE_FUNC where specifies the real function
+/* Used only for TYPE_CODE_FUNC where it specifies the real function
    address is returned by this function call.  TYPE_TARGET_TYPE determines the
    final returned function type to be presented to user.  */
 
diff --git a/gdb/hppa-linux-tdep.c b/gdb/hppa-linux-tdep.c
index e40105b..e452ab9 100644
--- a/gdb/hppa-linux-tdep.c
+++ b/gdb/hppa-linux-tdep.c
@@ -515,17 +515,19 @@ hppa_linux_regset_from_core_section (struct gdbarch *gdbarch,
   return NULL;
 }
 
+/* Resolve both gnu-ifunc function addresses and function descriptors.  */
+
 static CORE_ADDR
 hppa32_linux_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
 					 CORE_ADDR addr,
 					 struct target_ops *targ)
 {
   CORE_ADDR pc = hppa32_convert_from_func_ptr_addr (gdbarch, addr, targ);
-  CORE_ADDR resolved;
+  CORE_ADDR resolved_addr;
 
-  resolved = linux_convert_from_func_and_ptr (gdbarch, addr, pc);
-  if (resolved != pc)
-    pc = hppa32_convert_from_func_ptr_addr (gdbarch, resolved, targ);
+  resolved_addr = linux_convert_from_func_and_ptr (gdbarch, addr, pc);
+  if (resolved_addr != addr)
+    pc = hppa32_convert_from_func_ptr_addr (gdbarch, resolved_addr, targ);
 
   return pc;
 }
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 347fbe4..67e008c 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -1245,7 +1245,9 @@ hppa64_return_value (struct gdbarch *gdbarch, struct type *func_type,
 
   return RETURN_VALUE_REGISTER_CONVENTION;
 }
-\f
+
+/* Resolve function descriptors.  Return ADDR if no function descriptor was
+   found.  */
 
 CORE_ADDR
 hppa32_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr,
diff --git a/gdb/infcall.c b/gdb/infcall.c
index 6ac95cc..e642894 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -252,17 +252,9 @@ find_function_addr (struct value *function, struct type **retval_type)
       if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
 	  || TYPE_CODE (ftype) == TYPE_CODE_METHOD)
 	{
-	  CORE_ADDR funaddr2;
-
-	  funaddr2 = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr,
-							 &current_target);
-
-	  /* If TYPE_GNU_IFUNC is currently not resolvable keep its type.  */
-	  if (funaddr2 != funaddr || !TYPE_GNU_IFUNC (ftype))
-	    {
-	      funaddr = funaddr2;
-	      value_type = TYPE_TARGET_TYPE (ftype);
-	    }
+	  funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr,
+							&current_target);
+	  value_type = TYPE_TARGET_TYPE (ftype);
 	}
     }
   else if (code == TYPE_CODE_INT)
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 02b2342..3625165 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -155,7 +155,15 @@ linux_has_shared_address_space (void)
   return target_is_uclinux;
 }
 
-/* Call gnu-ifunc to resolve breakpoint at its returned function.  */
+/* Call gnu-ifunc (STT_GNU_IFUNC - a function returning addresss of a real
+   function to call) to resolve breakpoint at its returned function.  FUNC_PTR
+   is the function pointer (possible function descriptor), PC is the real
+   function code.  Use linux_convert_from_func_ptr_addr if no function
+   descriptors need to be resolved on the platform. FUNC_PTR is equal to PC on
+   platforms without function descriptors.  Function returns FUNC_PTR if no
+   gnu-ifunc has been found, otherwise it returns address of the resolved
+   function address to call.  Returned address is always the possible address
+   of function descriptor.  */
 
 CORE_ADDR
 linux_convert_from_func_and_ptr (struct gdbarch *gdbarch, CORE_ADDR func_ptr,
@@ -188,6 +196,13 @@ linux_convert_from_func_and_ptr (struct gdbarch *gdbarch, CORE_ADDR func_ptr,
   return value_as_address (address);
 }
 
+/* Call gnu-ifunc (STT_GNU_IFUNC - a function returning addresss of a real
+   function to call) to resolve breakpoint at its returned function.  Use
+   linux_convert_from_func_and_ptr if the platform requires also a function
+   descriptor resolution.  ADDR is address of the possibly-gnu-ifunc function.
+   Function returns ADDR if no gnu-ifunc has been found, otherwise it returns
+   address of the resolved function address to call.  */
+
 CORE_ADDR
 linux_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr,
 				  struct target_ops *targ)
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 94f993e..15b5f25 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -609,11 +609,7 @@ ppc64_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
   return target? target : pc;
 }
 
-
-/* Support for convert_from_func_ptr_addr (ARCH, ADDR, TARG) on PPC64
-   GNU/Linux.
-
-   Usually a function pointer's representation is simply the address
+/* Usually a function pointer's representation is simply the address
    of the function.  On GNU/Linux on the PowerPC however, a function
    pointer may be a pointer to a function descriptor.
 
@@ -637,9 +633,8 @@ ppc64_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
    random addresses such as occur when there is no symbol table.  */
 
 static CORE_ADDR
-ppc64_linux_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
-					CORE_ADDR addr,
-					struct target_ops *targ)
+convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr,
+			    struct target_ops *targ)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
   struct target_section *s = target_section_by_addr (targ, addr);
@@ -673,24 +668,34 @@ ppc64_linux_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
       res = bfd_get_section_contents (s->bfd, s->the_bfd_section,
 				      &buf, addr - s->addr, 8);
       if (res != 0)
-	{
-	  CORE_ADDR pc, resolved;
-	  
-	  pc = extract_unsigned_integer (buf, 8, byte_order)
-	       - bfd_section_vma (s->bfd, s->the_bfd_section) + s->addr;
-
-	  resolved = linux_convert_from_func_and_ptr (gdbarch, addr, pc);
-	  if (resolved != pc)
-	    pc = ppc64_linux_convert_from_func_ptr_addr (gdbarch, resolved,
-							 targ);
-
-	  return pc;
-	}
+	return extract_unsigned_integer (buf, 8, byte_order)
+		- bfd_section_vma (s->bfd, s->the_bfd_section) + s->addr;
    }
 
   return addr;
 }
 
+/* Support for convert_from_func_ptr_addr (ARCH, ADDR, TARG) on PPC64
+   GNU/Linux.
+
+   Call convert_from_func_ptr_addr for resolving PPC64 function descriptors but
+   support also gnu-ifunc functions on the GNU/Linux platform.  */
+
+static CORE_ADDR
+ppc64_linux_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
+					CORE_ADDR addr,
+					struct target_ops *targ)
+{
+  CORE_ADDR pc = convert_from_func_ptr_addr (gdbarch, addr, targ);
+  CORE_ADDR resolved_addr;
+
+  resolved_addr = linux_convert_from_func_and_ptr (gdbarch, addr, pc);
+  if (resolved_addr != addr)
+    pc = convert_from_func_ptr_addr (gdbarch, resolved_addr, targ);
+
+  return pc;
+}
+
 /* Wrappers to handle Linux-only registers.  */
 
 static void


hooks/post-receive
--
Repository for Project Archer.


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

end of thread, other threads:[~2010-02-14 19:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-14 19:16 [SCM] archer-jankratochvil-ifunc: fixup jkratoch
  -- strict thread matches above, loose matches on Subject: below --
2010-02-14 17:09 jkratoch
2010-02-14 16:25 jkratoch
2010-02-14 15:37 jkratoch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).