This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [rfa] Hack around coffread cast ...
- To: Andrew Cagney <ac131313 at cygnus dot com>
- Subject: Re: [rfa] Hack around coffread cast ...
- From: Michael Snyder <msnyder at cygnus dot com>
- Date: Thu, 01 Feb 2001 13:54:22 -0800
- CC: GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- Organization: Red Hat
- References: <3A79AF8C.9EB1EB88@cygnus.com>
Andrew Cagney wrote:
>
> Hello,
>
> (This one I don't like :-)
>
> This uses a more robust cast to convert an integer into a pointer.
> Better solutions definitly welcome.
You mean other than using a union? Looks ok to me...
> The problem is that you can't
> assume that sizeof(int) == sizeof(long) == sizeof(pointer).
>
> Andrew
>
> ----------------------------------------------------------------------------------------------------
> Thu Feb 1 00:29:42 2001 Andrew Cagney <cagney@redhat.com>
>
> * coffread.c: Include "gdb_assert.h".
> (coff_symtab_read): Cast the integer s_sclass to a
> long before casting it to a pointer.
>
> Index: coffread.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/coffread.c,v
> retrieving revision 1.14
> diff -p -r1.14 coffread.c
> *** coffread.c 2000/12/15 01:01:46 1.14
> --- coffread.c 2001/02/01 18:48:26
> ***************
> *** 42,47 ****
> --- 42,48 ----
> #include "stabsread.h"
> #include "complaints.h"
> #include "target.h"
> + #include "gdb_assert.h"
>
> extern void _initialize_coffread (void);
>
> *************** coff_symtab_read (long symtab_offset, un
> *** 965,973 ****
> {
> struct minimal_symbol *msym;
>
> msym = prim_record_minimal_symbol_and_info
> ! (cs->c_name, tmpaddr, ms_type, (char *) cs->c_sclass, sec,
> ! NULL, objfile);
> #ifdef COFF_MAKE_MSYMBOL_SPECIAL
> if (msym)
> COFF_MAKE_MSYMBOL_SPECIAL (cs->c_sclass, msym);
> --- 966,980 ----
> {
> struct minimal_symbol *msym;
>
> + /* FIXME: cagney/2001-02-01: The nasty (int) -> (long)
> + -> (void*) cast is to ensure that that the value of
> + cs->c_sclass can be correctly stored in a void
> + pointer in MSYMBOL_INFO. Better solutions
> + welcome. */
> + gdb_assert (sizeof (void *) >= sizeof (cs->c_sclass));
> msym = prim_record_minimal_symbol_and_info
> ! (cs->c_name, tmpaddr, ms_type, (void *) (long) cs->c_sclass,
> ! sec, NULL, objfile);
> #ifdef COFF_MAKE_MSYMBOL_SPECIAL
> if (msym)
> COFF_MAKE_MSYMBOL_SPECIAL (cs->c_sclass, msym);