This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH cygwin/mingw32]: Fix strip_name_encoding for fastcall symbols
- From: Danny Smith <danny_smith_0000 at yahoo dot co dot nz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Christopher Faylor <cgf at redhat dot com>
- Date: Fri, 12 Mar 2004 23:08:02 +1300 (NZDT)
- Subject: [PATCH cygwin/mingw32]: Fix strip_name_encoding for fastcall symbols
Hello
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
emitted.
// strip_name_encode_bug.cc
__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.
ChangeLog
2004-03-12 Danny Smith <dannysmith@users.sourceforge.net>
* 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.
http://au.movies.yahoo.com