This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH cygwin/mingw32]: Fix strip_name_encoding for fastcall symbols


The following code fails on mingw32 (trunk, 3.4.0 and 3.3.3) because of
a bug in config/i386/winnt.c (i386_pe_strip_name_encoding_full).

When compiled with g++ -O0, the fastcall function is nether inlined nor

__inline__ int __attribute__((fastcall)) ffunc(void) { return 1; }
int main() { return ffunc(); }

The problem is that i386_pe_strip_name_encoding_full strips all chars
beginning with the first '@;. Since fastcall symbols are prefixed with
'@', it returns an empty string. The bug is exposed in the above test
case when 'linkonce' semantics are used by C++ and
notice_global_symbol() in varasm.c sets weak_global_object_name to an
empty string.  The code compiles without error in C or when the inline
attribute is removed in C++.

This is not a regression since it has been broken since fastcall support
was introduced in 3.3.

The following patch fixes.  Tested on mingw32 (c, c++, objc).

Is this OK for trunk and for 3.4.1 when branched.


2004-03-12  Danny Smith  <>

	* config/i386/winnt.c (i386_pe_strip_name_encoding_full): Strip
	leading '@' on fastcall symbols before stripping suffix.

Index: winnt.c
RCS file: /cvs/gcc/gcc/gcc/config/i386/winnt.c,v
retrieving revision 1.62
diff -c -3 -p -r1.62 winnt.c
*** winnt.c	31 Jan 2004 08:02:55 -0000	1.62
--- winnt.c	12 Mar 2004 01:26:28 -0000
*************** i386_pe_strip_name_encoding (const char 
*** 558,564 ****
    return str;
! /* Also strip the stdcall suffix.  */
  const char *
  i386_pe_strip_name_encoding_full (const char *str)
--- 558,564 ----
    return str;
! /* Also strip the fastcall prefix and stdcall suffix.  */
  const char *
  i386_pe_strip_name_encoding_full (const char *str)
*************** i386_pe_strip_name_encoding_full (const 
*** 566,571 ****
--- 566,576 ----
    const char *p;
    const char *name = i386_pe_strip_name_encoding (str);
+   /* Strip leading '@' on fastcall symbols.  */
+   if (*name == '@')
+     name++;
+   /* Strip trailing "@n".  */
    p = strchr (name, '@');
    if (p)
      return ggc_alloc_string (name, p - name);

Find local movie times and trailers on Yahoo! Movies.

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