]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* gdbarch.sh (gdbarch_bfd_entry_point): New gdbarch method.
authorJim Blandy <jimb@codesourcery.com>
Fri, 13 Jun 2003 23:18:30 +0000 (23:18 +0000)
committerJim Blandy <jimb@codesourcery.com>
Fri, 13 Jun 2003 23:18:30 +0000 (23:18 +0000)
* arch-utils.c (generic_bfd_entry_point): New function.
* arch-utils.h (generic_bfd_entry_point): New declaration.
* gdbarch.c, gdbarch.h: Regenerated.
* solib-svr4.c (enable_break): Call it, instead of accessing
tmp_bfd->start_address directly.

gdb/ChangeLog
gdb/arch-utils.c
gdb/arch-utils.h
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/solib-svr4.c

index 666d50f1735773259368cf89815d44b48bf6c81f..8b197bd692ef158cc9fc2b4e0fd4edab521704bb 100644 (file)
@@ -1,5 +1,12 @@
 2003-06-13  Jim Blandy  <jimb@redhat.com>
 
+       * gdbarch.sh (gdbarch_bfd_entry_point): New gdbarch method.
+       * arch-utils.c (generic_bfd_entry_point): New function.
+       * arch-utils.h (generic_bfd_entry_point): New declaration.
+       * gdbarch.c, gdbarch.h: Regenerated.
+       * solib-svr4.c (enable_break): Call it, instead of accessing
+       tmp_bfd->start_address directly.
+
        * ppc-linux-tdep.c (ppc64_linux_convert_from_func_ptr_addr): New
        function.
        (ppc_linux_init_abi): Register it as the
index 9fa9ceade9d92d6680f1dfcd208e7891b60fadb5..94019e2dcdcc0c0a5a512a5b6af14de4e232bf8c 100644 (file)
@@ -368,6 +368,12 @@ cannot_register_not (int regnum)
   return 0;
 }
 
+CORE_ADDR
+generic_bfd_entry_point (struct gdbarch *gdbarch, bfd *abfd)
+{
+  return bfd_get_start_address (abfd);
+}
+
 /* Legacy version of target_virtual_frame_pointer().  Assumes that
    there is an DEPRECATED_FP_REGNUM and that it is the same, cooked or
    raw.  */
index 8fce25236feb994c7c4b8e50d87c15ff5a8843a3..15590f3bce5dbf93ca94b49ecf67647166d34bfb 100644 (file)
@@ -81,6 +81,10 @@ extern int core_addr_greaterthan (CORE_ADDR lhs, CORE_ADDR rhs);
 extern const struct floatformat *default_float_format (struct gdbarch *gdbarch);
 extern const struct floatformat *default_double_format (struct gdbarch *gdbarch);
 
+/* Return the start address of ABFD.  This is exactly like
+   bfd_get_start_address, except that it's a gdbarch function.  */
+extern CORE_ADDR generic_bfd_entry_point (struct gdbarch *gdbarch, bfd *abfd);
+
 /* The following DEPRECATED interfaces are for pre- multi-arch legacy
    targets. */
 
index 03d6b99733537f66e77a737b5047ed2fca74aa2c..47a355a844b269e51a1e932ccacac298edaadedf 100644 (file)
@@ -264,6 +264,7 @@ struct gdbarch
   gdbarch_software_single_step_ftype *software_single_step;
   gdbarch_print_insn_ftype *print_insn;
   gdbarch_skip_trampoline_code_ftype *skip_trampoline_code;
+  gdbarch_bfd_entry_point_ftype *bfd_entry_point;
   gdbarch_in_solib_call_trampoline_ftype *in_solib_call_trampoline;
   gdbarch_in_solib_return_trampoline_ftype *in_solib_return_trampoline;
   gdbarch_pc_in_sigtramp_ftype *pc_in_sigtramp;
@@ -432,6 +433,7 @@ struct gdbarch startup_gdbarch =
   0,  /* software_single_step */
   0,  /* print_insn */
   0,  /* skip_trampoline_code */
+  generic_bfd_entry_point,  /* bfd_entry_point */
   0,  /* in_solib_call_trampoline */
   0,  /* in_solib_return_trampoline */
   0,  /* pc_in_sigtramp */
@@ -557,6 +559,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
   current_gdbarch->smash_text_address = core_addr_identity;
   current_gdbarch->print_insn = legacy_print_insn;
   current_gdbarch->skip_trampoline_code = generic_skip_trampoline_code;
+  current_gdbarch->bfd_entry_point = generic_bfd_entry_point;
   current_gdbarch->in_solib_call_trampoline = generic_in_solib_call_trampoline;
   current_gdbarch->in_solib_return_trampoline = generic_in_solib_return_trampoline;
   current_gdbarch->pc_in_sigtramp = legacy_pc_in_sigtramp;
@@ -746,6 +749,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of software_single_step, has predicate */
   /* Skip verify of print_insn, invalid_p == 0 */
   /* Skip verify of skip_trampoline_code, invalid_p == 0 */
+  /* Skip verify of bfd_entry_point, invalid_p == 0 */
   /* Skip verify of in_solib_call_trampoline, invalid_p == 0 */
   /* Skip verify of in_solib_return_trampoline, invalid_p == 0 */
   /* Skip verify of pc_in_sigtramp, invalid_p == 0 */
@@ -788,6 +792,10 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
   fprintf_unfiltered (file,
                       "gdbarch_dump: GDB_MULTI_ARCH = %d\n",
                       GDB_MULTI_ARCH);
+  if (GDB_MULTI_ARCH)
+    fprintf_unfiltered (file,
+                        "gdbarch_dump: bfd_entry_point = 0x%08lx\n",
+                        (long) current_gdbarch->bfd_entry_point);
   if (GDB_MULTI_ARCH)
     fprintf_unfiltered (file,
                         "gdbarch_dump: gdbarch_frame_align_p() = %d\n",
@@ -5436,6 +5444,25 @@ set_gdbarch_skip_trampoline_code (struct gdbarch *gdbarch,
   gdbarch->skip_trampoline_code = skip_trampoline_code;
 }
 
+CORE_ADDR
+gdbarch_bfd_entry_point (struct gdbarch *gdbarch, bfd *abfd)
+{
+  gdb_assert (gdbarch != NULL);
+  if (gdbarch->bfd_entry_point == 0)
+    internal_error (__FILE__, __LINE__,
+                    "gdbarch: gdbarch_bfd_entry_point invalid");
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_bfd_entry_point called\n");
+  return gdbarch->bfd_entry_point (gdbarch, abfd);
+}
+
+void
+set_gdbarch_bfd_entry_point (struct gdbarch *gdbarch,
+                             gdbarch_bfd_entry_point_ftype bfd_entry_point)
+{
+  gdbarch->bfd_entry_point = bfd_entry_point;
+}
+
 int
 gdbarch_in_solib_call_trampoline (struct gdbarch *gdbarch, CORE_ADDR pc, char *name)
 {
index 6c0eb3e703af864c291ff57b66341d3a3f2ebaf1..3eb5b4b3bae317727aa55b9758c3589ca035c594 100644 (file)
@@ -2699,6 +2699,20 @@ extern void set_gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, gdbarch_s
 #define SKIP_TRAMPOLINE_CODE(pc) (gdbarch_skip_trampoline_code (current_gdbarch, pc))
 #endif
 
+/* The actual instruction address at which ABFD would begin execution.
+   If ABFD is position-independent code, this address is not relocated;
+   it's the address at which execution would begin if the file were
+   loaded at its sections' vmas.
+  
+   On most architectures, this is simply bfd_get_start_address.  But on
+   some (like 64-bit PPC), that points to a function descriptor, not an
+   instruction.  The descriptor contains the actual entry point, and
+   other pointers needed to call the function. */
+
+typedef CORE_ADDR (gdbarch_bfd_entry_point_ftype) (struct gdbarch *gdbarch, bfd *abfd);
+extern CORE_ADDR gdbarch_bfd_entry_point (struct gdbarch *gdbarch, bfd *abfd);
+extern void set_gdbarch_bfd_entry_point (struct gdbarch *gdbarch, gdbarch_bfd_entry_point_ftype *bfd_entry_point);
+
 /* For SVR4 shared libraries, each call goes through a small piece of
    trampoline code in the ".plt" section.  IN_SOLIB_CALL_TRAMPOLINE evaluates
    to nonzero if we are currently stopped in one of these. */
index 9911ec8bc8720dc230412b5eaaa50096d7d9e545..1bb66135f700bcf5d179f2c345e089da98c45c2c 100755 (executable)
@@ -666,6 +666,16 @@ F:2:SOFTWARE_SINGLE_STEP:void:software_single_step:enum target_signal sig, int i
 f:2:TARGET_PRINT_INSN:int:print_insn:bfd_vma vma, disassemble_info *info:vma, info:::legacy_print_insn::0
 f:2:SKIP_TRAMPOLINE_CODE:CORE_ADDR:skip_trampoline_code:CORE_ADDR pc:pc:::generic_skip_trampoline_code::0
 
+# The actual instruction address at which ABFD would begin execution.
+# If ABFD is position-independent code, this address is not relocated;
+# it's the address at which execution would begin if the file were
+# loaded at its sections' vmas.
+# 
+# On most architectures, this is simply bfd_get_start_address.  But on
+# some (like 64-bit PPC), that points to a function descriptor, not an
+# instruction.  The descriptor contains the actual entry point, and
+# other pointers needed to call the function.
+m:1::CORE_ADDR:bfd_entry_point:bfd *abfd:abfd:::generic_bfd_entry_point::0
 
 # For SVR4 shared libraries, each call goes through a small piece of
 # trampoline code in the ".plt" section.  IN_SOLIB_CALL_TRAMPOLINE evaluates
index d4335349790f88eb45cb0475f2dee1ccb06d6d87..6a866560cebe04fdd086c6dc307f47a11256ddbe 100644 (file)
@@ -1036,7 +1036,8 @@ enable_break (void)
         the current pc (which should point at the entry point for the
         dynamic linker) and subtracting the offset of the entry point.  */
       if (!load_addr_found)
-       load_addr = read_pc () - tmp_bfd->start_address;
+       load_addr = (read_pc ()
+                     - gdbarch_bfd_entry_point (current_gdbarch, tmp_bfd));
 
       /* Record the relocated start and end address of the dynamic linker
          text and plt section for svr4_in_dynsym_resolve_code.  */