This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
asmname should be verbatim if starting with an asterisk
- From: Pascal Obry <obry at act-europe dot fr>
- To: gcc-patches at gnu dot org
- Date: Wed, 2 Jun 2004 21:53:36 +0200
- Subject: asmname should be verbatim if starting with an asterisk
Note that this has been recorded into GCC Bugzilla under #15765, Andrew asked
me to send this patch to this mailing-list.
On Windows an stdcall calling convention routine will have an @nn suffix and
an '_' prefix added.
If an stdcall symbol starts with an asterisk the underscore prefix is not added
but the @nn suffix is still added in winnt.c (see gen_fastcall_suffix() and
gen_fastcall_suffix() routines).
Even if this following patch looks long the only real change I have made is
to add in both routines:
/* A symbol starting with an asterisk means that no prefix or suffix must
be added to this symbol, just return asmname as-is */
if (asmname[0] == '*')
return asmname;
I've taken the opportunity to factorize the code in gen_fastcall_suffix() and
gen_stdcall_suffix() as both procedures were having mostly 90% of code
duplication.
<<
*** winnt.c.orig Sat May 29 15:15:39 2004
--- winnt.c Sat May 29 15:31:22 2004
***************
*** 403,419 ****
DECL_NON_ADDR_CONST_P (decl) = 1;
}
! /* Return string which is the former assembler name modified with a
! prefix consisting of FASTCALL_PREFIX and a suffix consisting of an
! atsign (@) followed by the number of bytes of arguments. */
static const char *
! gen_fastcall_suffix (tree decl)
{
int total = 0;
const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
char *newsym;
if (TYPE_ARG_TYPES (TREE_TYPE (decl)))
if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (decl))))
== void_type_node)
--- 403,424 ----
DECL_NON_ADDR_CONST_P (decl) = 1;
}
! /* Return string (using format string) which is the former assembler name
! modified with a suffix consisting of an atsign (@) followed by the number
! of bytes of arguments */
static const char *
! gen_suffix (const char *format, tree decl)
{
int total = 0;
const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
char *newsym;
+ /* A symbol starting with an asterisk means that no prefix or suffix must
+ be added to this symbol, just return asmname as-is */
+ if (asmname[0] == '*')
+ return asmname;
+
if (TYPE_ARG_TYPES (TREE_TYPE (decl)))
if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (decl))))
== void_type_node)
***************
*** 438,486 ****
/* Assume max of 8 base 10 digits in the suffix. */
newsym = xmalloc (1 + strlen (asmname) + 1 + 8 + 1);
! sprintf (newsym, "%c%s@%d", FASTCALL_PREFIX, asmname, total/BITS_PER_UNIT);
return IDENTIFIER_POINTER (get_identifier (newsym));
}
/* Return string which is the former assembler name modified with a
! suffix consisting of an atsign (@) followed by the number of bytes of
! arguments */
static const char *
! gen_stdcall_suffix (tree decl)
{
! int total = 0;
! /* ??? This probably should use XSTR (XEXP (DECL_RTL (decl), 0), 0) instead
! of DECL_ASSEMBLER_NAME. */
! const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
! char *newsym;
! if (TYPE_ARG_TYPES (TREE_TYPE (decl)))
! if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (decl))))
! == void_type_node)
! {
! tree formal_type = TYPE_ARG_TYPES (TREE_TYPE (decl));
! /* Quit if we hit an incomplete type. Error is reported
! by convert_arguments in c-typeck.c or cp/typeck.c. */
! while (TREE_VALUE (formal_type) != void_type_node
! && COMPLETE_TYPE_P (TREE_VALUE (formal_type)))
! {
! int parm_size
! = TREE_INT_CST_LOW (TYPE_SIZE (TREE_VALUE (formal_type)));
! /* Must round up to include padding. This is done the same
! way as in store_one_arg. */
! parm_size = ((parm_size + PARM_BOUNDARY - 1)
! / PARM_BOUNDARY * PARM_BOUNDARY);
! total += parm_size;
! formal_type = TREE_CHAIN (formal_type);
! }
! }
! /* Assume max of 8 base 10 digits in the suffix. */
! newsym = xmalloc (strlen (asmname) + 1 + 8 + 1);
! sprintf (newsym, "%s@%d", asmname, total/BITS_PER_UNIT);
! return IDENTIFIER_POINTER (get_identifier (newsym));
}
void
--- 443,473 ----
/* Assume max of 8 base 10 digits in the suffix. */
newsym = xmalloc (1 + strlen (asmname) + 1 + 8 + 1);
! sprintf (newsym, format, asmname, total/BITS_PER_UNIT);
return IDENTIFIER_POINTER (get_identifier (newsym));
}
/* Return string which is the former assembler name modified with a
! prefix consisting of FASTCALL_PREFIX and a suffix consisting of an
! atsign (@) followed by the number of bytes of arguments. */
static const char *
! gen_fastcall_suffix (tree decl)
{
! char *format = " %s@%d";
! format[0] = FASTCALL_PREFIX;
! return gen_suffix (format, decl);
! }
! /* Return string which is the former assembler name modified with a
! suffix consisting of an atsign (@) followed by the number of bytes of
! arguments */
! static const char *
! gen_stdcall_suffix (tree decl)
! {
! return gen_suffix ("%s@%d", decl);
}
void
>>
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595