This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH [cygwin/mingw] Fix __attribute__((alias())) vs stdcall decoration
- From: Danny Smith <danny_r_smith_2001 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: Thu, 16 Oct 2003 14:40:46 +1000 (EST)
- Subject: PATCH [cygwin/mingw] Fix __attribute__((alias())) vs stdcall decoration
Hello
__attribute__((alias ("foo"))) does not work as expected with aliases
to stdcall or fastcall functions on win32 targets (which follow MS
convention and decorate the user names with @nn suffix).
The following test fails with an undefined reference to bar@4
/* alias.c */
#ifdef __cplusplus
extern "C"
#endif
void
__attribute__((stdcall))
foo(int i) { }
void
__attribute__((stdcall)) __attribute__((alias("foo@4")))
bar (int i);
int main()
{
bar(1);
return 0;
}
The assembly shows that the DECL_ASSEMBLY_NAME for bar is being used in
set statement rather than the user label bar@4
.globl _bar@4
.set _bar,_foo@4
This is a regression from 2.95. The regression is present on trunk, 3.3.2
and 3.2.3.
The following fixes. Effectively the use of this
ASM_OUTPUT_DEF_FROM_DECLS in varasm.c (assemble_alias) just replaces
IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL)) with
XSTR (XEXP (DECL_RTL (DECL), 0), 0) to get the decorated identifier.
ChangeLog
2003-10-17 Danny Smith <dannysmith@users.sourceforge.net>
* config/i386/cygming.h (ASM_OUTPUT_DEF_FROM_DECLS): Define.
Index: cygming.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/cygming.h,v
retrieving revision 1.8
diff -c -3 -p -r1.8 cygming.h
*** cygming.h 7 Oct 2003 09:36:34 -0000 1.8
--- cygming.h 16 Oct 2003 01:27:17 -0000
*************** extern int i386_pe_dllimport_name_p (con
*** 364,372 ****
--- 364,383 ----
#ifndef SET_ASM_OP
#define SET_ASM_OP "\t.set\t"
#endif
+ /* This implements the `alias' attribute, keeping any stdcall or
+ fastcall decoration. */
+ #undef ASM_OUTPUT_DEF_FROM_DECLS
+ #define ASM_OUTPUT_DEF_FROM_DECLS(STREAM, DECL, TARGET) \
+ do \
+ { \
+ const char *alias; \
+ rtx rtlname = XEXP (DECL_RTL (DECL), 0); \
+ if (GET_CODE (rtlname) == SYMBOL_REF) \
+ alias = XSTR (rtlname, 0); \
+ else \
+ abort (); \
+ ASM_OUTPUT_DEF (STREAM, alias, IDENTIFIER_POINTER (TARGET)); \
+ } while (0)
#undef TREE
http://personals.yahoo.com.au - Yahoo! Personals
New people, new possibilities. FREE for a limited time.