This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: Severe regression in corefile.exp with Solaris 2.7 sparc + hack
- To: Jim Kingdon <kingdon at redhat dot com>, "Peter.Schauer" <Peter dot Schauer at regent dot e-technik dot tu-muenchen dot de>
- Subject: Re: Severe regression in corefile.exp with Solaris 2.7 sparc + hack
- From: Kevin Buettner <kevinb at cygnus dot com>
- Date: Tue, 7 Mar 2000 15:53:56 -0700
- Cc: gdb-patches at sourceware dot cygnus dot com
- References: <200003072113.WAA26253@reisser.regent.e-technik.tu-muenchen.de> <b1z5mmnle.fsf@rtl.cygnus.com>
On Mar 7, 2:17pm, Jim Kingdon wrote:
> > Due to the BFD change, a CORE_ADDR is now an unsigned long long with 64 Bits.
> > When casting 32 bit pointers to a CORE_ADDR in solib.c, the sign bit of the
> > pointer gets extended
>
> Weird. GCC seems to do that too (albeit with a warning "cast from
> pointer to integer of different size").
>
> The best solution I could think of was to change "(CORE_ADDR)lm"
> (where lm is a void*) to "(CORE_ADDR)(size_t)lm". At least for me
> that seems to work (on a small test case). Hardly elegant, but better
> than manually anding with 0xffffffff I guess.
Of the two choices, I prefer manually anding with 0xffffffff. The
cast that you suggest will only yield the desired results when
sizeof(void *) == sizeof(size_t).
When sizeof(void *) < sizeof(size_t), you'll once again end up with an
undesired sign extension. And when sizeof(void *) > sizeof(size_t),
you'll end up losing some significant address bits.
Peter's solution (at least) identifies a class of targets for which
sign extension is a problem and correctly masks the address for those
targets.
I think there must be a better solution than the one that Peter
proposes. However, I don't know what it is either.
Kevin