This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: Handle ISA bits for the entry point


ARM GNU/Linux binaries traditionally were either entirely ARM mode, or
mixed ARM and Thumb with some critical bits of ARM code - like _start.
With the introduction of Thumb-2, it's now possible to build the C
library in Thumb mode.  The binary's entry point can now be a Thumb
function.

This is represented in the expected way: e_entry in the ELF header
has the low bit set.  That means to get a code address we must
call gdbarch_addr_bits_remove.

Instead of scattering this around, I audited all the calls to
entry_point_address.  Several of them already called
gdbarch_convert_from_func_ptr_addr; the ones that did not look like
omissions, and I didn't find any which would be adversely affected by
either that or gdbarch_addr_bits_remove.  So this patch does
both in entry_point_address, and removes the now dead calls at
caller sites.

Tested on ARM GNU/Linux, where it (together with the next patch)
fixes several function calling failures.  I'll check this in.

-- 
Daniel Jacobowitz
CodeSourcery

2009-07-28  Daniel Jacobowitz  <dan@codesourcery.com>

	gdb/
	* arch-utils.c (displaced_step_at_entry_point): Do not call
	gdbarch_convert_from_func_ptr_addr.
	* cris-tdep.c: Remove outdated comment.
	* infcall.c (call_function_by_hand): Do not call
	gdbarch_convert_from_func_ptr_addr after entry_point_address.
	* objfiles.c (entry_point_address): Call both
	gdbarch_convert_from_func_ptr_addr and
	gdbarch_addr_bits_remove.

---
 gdb/arch-utils.c |    4 ----
 gdb/cris-tdep.c  |    1 -
 gdb/infcall.c    |   19 ++++++++-----------
 gdb/objfiles.c   |   21 ++++++++++++++++++++-
 4 files changed, 28 insertions(+), 17 deletions(-)

Index: gdb-mainline/gdb/arch-utils.c
===================================================================
--- gdb-mainline.orig/gdb/arch-utils.c	2009-07-02 10:29:17.000000000 -0700
+++ gdb-mainline/gdb/arch-utils.c	2009-07-22 14:46:56.000000000 -0700
@@ -76,10 +76,6 @@ displaced_step_at_entry_point (struct gd
 
   addr = entry_point_address ();
 
-  /* Make certain that the address points at real code, and not a
-     function descriptor.  */
-  addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, &current_target);
-
   /* Inferior calls also use the entry point as a breakpoint location.
      We don't want displaced stepping to interfere with those
      breakpoints, so leave space.  */
Index: gdb-mainline/gdb/cris-tdep.c
===================================================================
--- gdb-mainline.orig/gdb/cris-tdep.c	2009-07-02 10:25:53.000000000 -0700
+++ gdb-mainline/gdb/cris-tdep.c	2009-07-22 14:46:36.000000000 -0700
@@ -39,7 +39,6 @@
 #include "regcache.h"
 #include "gdb_assert.h"
 
-/* To get entry_point_address.  */
 #include "objfiles.h"
 
 #include "solib.h"              /* Support for shared libraries.  */
Index: gdb-mainline/gdb/infcall.c
===================================================================
--- gdb-mainline.orig/gdb/infcall.c	2009-07-22 14:40:11.000000000 -0700
+++ gdb-mainline/gdb/infcall.c	2009-07-22 14:46:20.000000000 -0700
@@ -592,11 +592,6 @@ call_function_by_hand (struct value *fun
 
 	real_pc = funaddr;
 	dummy_addr = entry_point_address ();
-	/* Make certain that the address points at real code, and not a
-	   function descriptor.  */
-	dummy_addr = gdbarch_convert_from_func_ptr_addr (gdbarch,
-							 dummy_addr,
-							 &current_target);
 	/* A call dummy always consists of just a single breakpoint, so
 	   its address is the same as the address of the dummy.  */
 	bp_addr = dummy_addr;
@@ -614,14 +609,16 @@ call_function_by_hand (struct value *fun
 	sym = lookup_minimal_symbol ("__CALL_DUMMY_ADDRESS", NULL, NULL);
 	real_pc = funaddr;
 	if (sym)
-	  dummy_addr = SYMBOL_VALUE_ADDRESS (sym);
+	  {
+	    dummy_addr = SYMBOL_VALUE_ADDRESS (sym);
+	    /* Make certain that the address points at real code, and not
+	       a function descriptor.  */
+	    dummy_addr = gdbarch_convert_from_func_ptr_addr (gdbarch,
+							     dummy_addr,
+							     &current_target);
+	  }
 	else
 	  dummy_addr = entry_point_address ();
-	/* Make certain that the address points at real code, and not
-	   a function descriptor.  */
-	dummy_addr = gdbarch_convert_from_func_ptr_addr (gdbarch,
-							 dummy_addr,
-							 &current_target);
 	/* A call dummy always consists of just a single breakpoint,
 	   so it's address is the same as the address of the dummy.  */
 	bp_addr = dummy_addr;
Index: gdb-mainline/gdb/objfiles.c
===================================================================
--- gdb-mainline.orig/gdb/objfiles.c	2009-07-14 07:55:06.000000000 -0700
+++ gdb-mainline/gdb/objfiles.c	2009-07-22 14:45:45.000000000 -0700
@@ -271,7 +271,26 @@ init_entry_point_info (struct objfile *o
 CORE_ADDR
 entry_point_address (void)
 {
-  return symfile_objfile ? symfile_objfile->ei.entry_point : 0;
+  struct gdbarch *gdbarch;
+  CORE_ADDR entry_point;
+
+  if (symfile_objfile == NULL)
+    return 0;
+
+  gdbarch = get_objfile_arch (symfile_objfile);
+
+  entry_point = symfile_objfile->ei.entry_point;
+
+  /* Make certain that the address points at real code, and not a
+     function descriptor.  */
+  entry_point = gdbarch_convert_from_func_ptr_addr (gdbarch, entry_point,
+						    &current_target);
+
+  /* Remove any ISA markers, so that this matches entries in the
+     symbol table.  */
+  entry_point = gdbarch_addr_bits_remove (gdbarch, entry_point);
+
+  return entry_point;
 }
 
 /* Create the terminating entry of OBJFILE's minimal symbol table.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]