This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch[mingw/cygwin]: Fix dllimport "unmarking" thinko in winnt.c
- From: Christopher Faylor <cgf at redhat dot com>
- To: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, chorns at users dot sourceforge dot net, ekohl at rz-online dot de
- Date: Sat, 8 Mar 2003 20:01:04 -0500
- Subject: Re: Patch[mingw/cygwin]: Fix dllimport "unmarking" thinko in winnt.c
- References: <20030305221618.85110.qmail@web21414.mail.yahoo.com>
On Thu, Mar 06, 2003 at 09:16:18AM +1100, Danny Smith wrote:
>Hello,
>
>The modifications to provide __fastcall support
>
>http://gcc.gnu.org/ml/gcc-cvs/2002-12/msg00633.html
>
>introduced mistakes in config/i386/winnt.c.
>
>The dllimport __imp_ prefix is now added in i386_pe_output_labelref
>rather than earlier in in i386_pe_mark_dllimport. Thus, when remarking
>as dllexport or unmarking dllimport, we need only to strip off
>DLL_IMPORT_EXPORT_PREFIX "i." (3 chars) rather than
>DLL_IMPORT_EXPORT_PREFIX "i.__imp_" (9 chars). The following patch
>fixes.
>
>This latent bug has probably never been noticed before because, AFAICT,
>the code to "unmark" dllimport attributes happens too late (or is not
>executed at all), leading to such PR's as PR7103.
Rather than using oldname += 3, wouldn't it make sense to define a constant
so that it was little more obvious what the "3" referred to?
cgf
>
>ChangeLog
>
>2003-03-05 Danny Smith <dannysmith at users dot sourceforge dot net>
>
> * config/i386/winnt.c (i386_pe_mark_dllexport): Advance past
> leading 3 chars, not 9 when getting identifier name.
> (i386_pe_encode_section_info) Likewise.
>
>
>
>Index: gcc/gcc/config/i386/winnt.c
>===================================================================
>RCS file: /cvs/gcc/gcc/gcc/config/i386/winnt.c,v
>retrieving revision 1.40
>diff -c -3 -p -r1.40 winnt.c
>*** gcc/gcc/config/i386/winnt.c 26 Dec 2002 18:45:04 -0000 1.40
>--- gcc/gcc/config/i386/winnt.c 4 Mar 2003 23:07:51 -0000
>*************** i386_pe_mark_dllexport (decl)
>*** 237,243 ****
> else
> abort ();
> if (i386_pe_dllimport_name_p (oldname))
>! oldname += 9;
> else if (i386_pe_dllexport_name_p (oldname))
> return; /* already done */
>
>--- 237,243 ----
> else
> abort ();
> if (i386_pe_dllimport_name_p (oldname))
>! oldname += 3;
> else if (i386_pe_dllexport_name_p (oldname))
> return; /* already done */
>
>*************** i386_pe_encode_section_info (decl, first
>*** 458,464 ****
> && i386_pe_dllimport_name_p (XSTR (XEXP (XEXP (DECL_RTL (decl), 0), 0),
>0)))
> {
> const char *oldname = XSTR (XEXP (XEXP (DECL_RTL (decl), 0), 0), 0);
>! tree idp = get_identifier (oldname + 9);
> rtx newrtl = gen_rtx (SYMBOL_REF, Pmode, IDENTIFIER_POINTER (idp));
>
> XEXP (DECL_RTL (decl), 0) = newrtl;
>--- 458,464 ----
> && i386_pe_dllimport_name_p (XSTR (XEXP (XEXP (DECL_RTL (decl), 0), 0),
>0)))
> {
> const char *oldname = XSTR (XEXP (XEXP (DECL_RTL (decl), 0), 0), 0);
>! tree idp = get_identifier (oldname + 3);
> rtx newrtl = gen_rtx (SYMBOL_REF, Pmode, IDENTIFIER_POINTER (idp));
>
> XEXP (DECL_RTL (decl), 0) = newrtl;
>
>
>http://mobile.yahoo.com.au - Yahoo! Mobile
>- Exchange IMs with Messenger friends on your Telstra or Vodafone mobile phone.