This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] use gdbarch_addr_bits_remove for entry point address
- From: Yao Qi <yao at codesourcery dot com>
- To: <gdb-patches at sourceware dot org>
- Date: Tue, 20 Nov 2012 17:36:24 +0800
- Subject: [PATCH] use gdbarch_addr_bits_remove for entry point address
Hi,
This patch attempts to clear the lsb of the entry address, which might
be set by compiler for thumb code.
This patch does something similar to this one,
RFC: Handle ISA bits for the entry point
http://sourceware.org/ml/gdb-patches/2009-07/msg00682.html
Regression tested on arm-none-linux-gnueabi. Is it OK?
gdb:
2012-11-20 Daniel Jacobowitz <dan@codesourcery.com>
Kazu Hirata <kazu@codesourcery.com>
Yao Qi <yao@codesourcery.com>
* objfiles.c (init_entry_point_info): Use gdbarch_addr_bits_remove.
* solib-svr4.c (exec_entry_point): Likewise.
* symfile.c (generic_load): Call gdbarch_addr_bits_remove on
the entry address.
---
gdb/objfiles.c | 5 +++++
gdb/solib-svr4.c | 5 ++++-
gdb/symfile.c | 1 +
3 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index a1db8c6..3374c68 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -353,6 +353,11 @@ init_entry_point_info (struct objfile *objfile)
/* Examination of non-executable.o files. Short-circuit this stuff. */
objfile->ei.entry_point_p = 0;
}
+
+ if (objfile->ei.entry_point_p)
+ objfile->ei.entry_point
+ = gdbarch_addr_bits_remove (objfile->gdbarch,
+ objfile->ei.entry_point);
}
/* If there is a valid and known entry point, function fills *ENTRY_P with it
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 37cc654..02e45a3 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1388,6 +1388,8 @@ svr4_in_dynsym_resolve_code (CORE_ADDR pc)
static CORE_ADDR
exec_entry_point (struct bfd *abfd, struct target_ops *targ)
{
+ CORE_ADDR addr;
+
/* KevinB wrote ... for most targets, the address returned by
bfd_get_start_address() is the entry point for the start
function. But, for some targets, bfd_get_start_address() returns
@@ -1396,9 +1398,10 @@ exec_entry_point (struct bfd *abfd, struct target_ops *targ)
gdbarch_convert_from_func_ptr_addr(). The method
gdbarch_convert_from_func_ptr_addr() is the merely the identify
function for targets which don't use function descriptors. */
- return gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
+ addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
bfd_get_start_address (abfd),
targ);
+ return gdbarch_addr_bits_remove (target_gdbarch (), addr);
}
/* Helper function for gdb_bfd_lookup_symbol. */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 55af541..70f631f 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2132,6 +2132,7 @@ generic_load (char *args, int from_tty)
gettimeofday (&end_time, NULL);
entry = bfd_get_start_address (loadfile_bfd);
+ entry = gdbarch_addr_bits_remove (target_gdbarch (), entry);
ui_out_text (uiout, "Start address ");
ui_out_field_fmt (uiout, "address", "%s", paddress (target_gdbarch (), entry));
ui_out_text (uiout, ", load size ");
--
1.7.7.6