This is the mail archive of the gdb-patches@sources.redhat.com 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]

Re: gdb 5.0: solib.c (LM_ADDR) should be signed, not unsigned


"Maciej W. Rozycki" wrote:
> 
> Hi,
> 
>  It appeared not only LM_ADDR has problems with signedness.  Here is an
> updated patch that fixes read_register() as well.
> 

> diff -u --recursive --new-file gdb-5.0.macro/gdb/solib.c gdb-5.0/gdb/solib.c
> --- gdb-5.0.macro/gdb/solib.c   Wed Apr  5 20:40:22 2000
> +++ gdb-5.0/gdb/solib.c Sun Jul 23 23:16:32 2000
> @@ -117,10 +117,12 @@
> 
>  #define SOLIB_EXTRACT_ADDRESS(member) \
>    extract_address (&member, sizeof (member))
> +#define SOLIB_EXTRACT_SIGNED_ADDRESS(member) \
> +  extract_signed_address (&member, sizeof (member))
> 
>  #ifndef SVR4_SHARED_LIBS
> 
> -#define LM_ADDR(so) (SOLIB_EXTRACT_ADDRESS ((so) -> lm.lm_addr))
> +#define LM_ADDR(so) (SOLIB_EXTRACT_SIGNED_ADDRESS ((so) -> lm.lm_addr))
>  #define LM_NEXT(so) (SOLIB_EXTRACT_ADDRESS ((so) -> lm.lm_next))
>  #define LM_NAME(so) (SOLIB_EXTRACT_ADDRESS ((so) -> lm.lm_name))
>  /* Test for first link map entry; first entry is a shared library. */
> @@ -133,7 +135,7 @@
> 
>  #else /* SVR4_SHARED_LIBS */
> 
> -#define LM_ADDR(so) (SOLIB_EXTRACT_ADDRESS ((so) -> lm.l_addr))
> +#define LM_ADDR(so) (SOLIB_EXTRACT_SIGNED_ADDRESS ((so) -> lm.l_addr))
>  #define LM_NEXT(so) (SOLIB_EXTRACT_ADDRESS ((so) -> lm.l_next))
>  #define LM_NAME(so) (SOLIB_EXTRACT_ADDRESS ((so) -> lm.l_name))
>  /* Test for first link map entry; first entry is the exec-file. */

I don't think this is right.  I think it would sign extend that address
for all targets - wrong in 99% of cases.  

Can you provide more information on the problem you're seeing (+
host/target etc).

	Andrew

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