[PATCH] use gdbarch_addr_bits_remove for entry point address

Pedro Alves alves.ped@gmail.com
Fri Nov 23 19:58:00 GMT 2012


On 11/20/2012 09:36 AM, Yao Qi wrote:

> 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 this is needed here, then it would look to me that  gdbarch_convert_from_func_ptr_addr
would be needed too.  See the function right below  init_entry_point_info:

/* If there is a valid and known entry point, function fills *ENTRY_P with it
   and returns non-zero; otherwise it returns zero.  */

int
entry_point_address_query (CORE_ADDR *entry_p)
{
  struct gdbarch *gdbarch;
  CORE_ADDR entry_point;

  if (symfile_objfile == NULL || !symfile_objfile->ei.entry_point_p)
    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);

  *entry_p = entry_point;
  return 1;
}

So you if put the gdbarch_addr_bits_remove call in init_entry_point_info,
ISTM the same call in entry_point_address_query is no longer necessary.  And
that it'd be better to move gdbarch_convert_from_func_ptr_addr too, I'd think (and I
don't know if there's an order they should be called in; moving both preserves the order).
Maybe there are yet other callers that could have gdbarch_addr_bits_remove calls
removed as redundant too, I haven't checked.

-- 
Pedro Alves



More information about the Gdb-patches mailing list