Commit 6ca23bff by Danny Smith Committed by Danny Smith

winnt.c (DLL_IMPORT_PREFIX): New define.

	* config/i386/winnt.c (DLL_IMPORT_PREFIX): New define.
	Use throughout instead of DLL_IMPORT_EXPORT_PREFIX and "e."
	(DLL_EXPORT_PREFIX): New define. Use throughout instead of
	DLL_IMPORT_EXPORT_PREFIX and "i."
	(i386_pe_dllexport_name_p): Here.
	(i386_pe_dllimport_name_p): Here.
        (i386_pe_mark_dllexport): Here. Remove DLL_IMPORT_PREFIX,
	not 9 chars when getting identifier name.
	(i386_pe_mark_dllimport): Here.
	(i386_pe_encode_section_info): Here. Remove DLL_IMPORT_PREFIX,
	not 9 chars when getting identifier name. Correct comment.
	(i386_pe_strip_name_encoding): Here. Add comments for different
	cases.
	(gen_fastcall_suffix): Break down xmalloc() argument to
	components.
	(gen_stdcall_suffix): Likewise.
	Update copyright year.

From-SVN: r64227
parent 9b73c90a
2003-03-12 Danny Smith <dannysmith@users.sourceforge.net>
* config/i386/winnt.c (DLL_IMPORT_PREFIX): New define.
Use throughout instead of DLL_IMPORT_EXPORT_PREFIX and "e."
(DLL_EXPORT_PREFIX): New define. Use throughout instead of
DLL_IMPORT_EXPORT_PREFIX and "i."
(i386_pe_dllexport_name_p): Here.
(i386_pe_dllimport_name_p): Here.
(i386_pe_mark_dllexport): Here. Remove DLL_IMPORT_PREFIX,
not 9 chars when getting identifier name.
(i386_pe_mark_dllimport): Here.
(i386_pe_encode_section_info): Here. Remove DLL_IMPORT_PREFIX,
not 9 chars when getting identifier name. Correct comment.
(i386_pe_strip_name_encoding): Here. Add comments for different
cases.
(gen_fastcall_suffix): Break down xmalloc() argument to
components.
(gen_stdcall_suffix): Likewise.
Update copyright year.
2003-03-12 Eric Botcazou <ebotcazou@libertysurf.fr> 2003-03-12 Eric Botcazou <ebotcazou@libertysurf.fr>
PR optimization/9888 PR optimization/9888
......
/* Subroutines for insn-output.c for Windows NT. /* Subroutines for insn-output.c for Windows NT.
Contributed by Douglas Rupp (drupp@cs.washington.edu) Contributed by Douglas Rupp (drupp@cs.washington.edu)
Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002 Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of GNU CC. This file is part of GNU CC.
...@@ -54,6 +54,15 @@ int i386_pe_dllimport_p PARAMS ((tree)); ...@@ -54,6 +54,15 @@ int i386_pe_dllimport_p PARAMS ((tree));
void i386_pe_mark_dllexport PARAMS ((tree)); void i386_pe_mark_dllexport PARAMS ((tree));
void i386_pe_mark_dllimport PARAMS ((tree)); void i386_pe_mark_dllimport PARAMS ((tree));
/* This is we how mark internal identifiers with dllimport or dllexport
attributes. */
#ifndef DLL_IMPORT_PREFIX
#define DLL_IMPORT_PREFIX "#i."
#endif
#ifndef DLL_EXPORT_PREFIX
#define DLL_EXPORT_PREFIX "#e."
#endif
/* Handle a "dllimport" or "dllexport" attribute; /* Handle a "dllimport" or "dllexport" attribute;
arguments as in struct attribute_spec.handler. */ arguments as in struct attribute_spec.handler. */
tree tree
...@@ -202,8 +211,8 @@ int ...@@ -202,8 +211,8 @@ int
i386_pe_dllexport_name_p (symbol) i386_pe_dllexport_name_p (symbol)
const char *symbol; const char *symbol;
{ {
return symbol[0] == DLL_IMPORT_EXPORT_PREFIX return (strncmp (DLL_EXPORT_PREFIX, symbol,
&& symbol[1] == 'e' && symbol[2] == '.'; strlen (DLL_EXPORT_PREFIX)) == 0);
} }
/* Return nonzero if SYMBOL is marked as being dllimport'd. */ /* Return nonzero if SYMBOL is marked as being dllimport'd. */
...@@ -212,8 +221,8 @@ int ...@@ -212,8 +221,8 @@ int
i386_pe_dllimport_name_p (symbol) i386_pe_dllimport_name_p (symbol)
const char *symbol; const char *symbol;
{ {
return symbol[0] == DLL_IMPORT_EXPORT_PREFIX return (strncmp (DLL_IMPORT_PREFIX, symbol,
&& symbol[1] == 'i' && symbol[2] == '.'; strlen (DLL_IMPORT_PREFIX)) == 0);
} }
/* Mark a DECL as being dllexport'd. /* Mark a DECL as being dllexport'd.
...@@ -237,12 +246,13 @@ i386_pe_mark_dllexport (decl) ...@@ -237,12 +246,13 @@ i386_pe_mark_dllexport (decl)
else else
abort (); abort ();
if (i386_pe_dllimport_name_p (oldname)) if (i386_pe_dllimport_name_p (oldname))
oldname += 9; /* Remove DLL_IMPORT_PREFIX. */
oldname += strlen (DLL_IMPORT_PREFIX);
else if (i386_pe_dllexport_name_p (oldname)) else if (i386_pe_dllexport_name_p (oldname))
return; /* already done */ return; /* already done */
newname = alloca (strlen (oldname) + 4); newname = alloca (strlen (DLL_EXPORT_PREFIX) + strlen (oldname) + 1);
sprintf (newname, "%ce.%s", DLL_IMPORT_EXPORT_PREFIX, oldname); sprintf (newname, "%s%s", DLL_EXPORT_PREFIX, oldname);
/* We pass newname through get_identifier to ensure it has a unique /* We pass newname through get_identifier to ensure it has a unique
address. RTL processing can sometimes peek inside the symbol ref address. RTL processing can sometimes peek inside the symbol ref
...@@ -316,8 +326,8 @@ i386_pe_mark_dllimport (decl) ...@@ -316,8 +326,8 @@ i386_pe_mark_dllimport (decl)
return; return;
} }
newname = alloca (strlen (oldname) + 4); newname = alloca (strlen (DLL_IMPORT_PREFIX) + strlen (oldname) + 1);
sprintf (newname, "%ci.%s", DLL_IMPORT_EXPORT_PREFIX, oldname); sprintf (newname, "%s%s", DLL_IMPORT_PREFIX, oldname);
/* We pass newname through get_identifier to ensure it has a unique /* We pass newname through get_identifier to ensure it has a unique
address. RTL processing can sometimes peek inside the symbol ref address. RTL processing can sometimes peek inside the symbol ref
...@@ -366,7 +376,8 @@ gen_fastcall_suffix (decl) ...@@ -366,7 +376,8 @@ gen_fastcall_suffix (decl)
} }
} }
newsym = xmalloc (strlen (asmname) + 11); /* 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); sprintf (newsym, "%c%s@%d", FASTCALL_PREFIX, asmname, total/BITS_PER_UNIT);
return IDENTIFIER_POINTER (get_identifier (newsym)); return IDENTIFIER_POINTER (get_identifier (newsym));
} }
...@@ -404,7 +415,8 @@ gen_stdcall_suffix (decl) ...@@ -404,7 +415,8 @@ gen_stdcall_suffix (decl)
} }
} }
newsym = xmalloc (strlen (asmname) + 10); /* 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); sprintf (newsym, "%s@%d", asmname, total/BITS_PER_UNIT);
return IDENTIFIER_POINTER (get_identifier (newsym)); return IDENTIFIER_POINTER (get_identifier (newsym));
} }
...@@ -447,8 +459,8 @@ i386_pe_encode_section_info (decl, first) ...@@ -447,8 +459,8 @@ i386_pe_encode_section_info (decl, first)
i386_pe_mark_dllimport (decl); i386_pe_mark_dllimport (decl);
/* It might be that DECL has already been marked as dllimport, but a /* It might be that DECL has already been marked as dllimport, but a
subsequent definition nullified that. The attribute is gone but subsequent definition nullified that. The attribute is gone but
DECL_RTL still has (DLL_IMPORT_EXPORT_PREFIX)i._imp__foo. We need DECL_RTL still has (DLL_IMPORT_PREFIX) prefixed. We need to remove
to remove that. Ditto for the DECL_NON_ADDR_CONST_P flag. */ that. Ditto for the DECL_NON_ADDR_CONST_P flag. */
else if ((TREE_CODE (decl) == FUNCTION_DECL else if ((TREE_CODE (decl) == FUNCTION_DECL
|| TREE_CODE (decl) == VAR_DECL) || TREE_CODE (decl) == VAR_DECL)
&& DECL_RTL (decl) != NULL_RTX && DECL_RTL (decl) != NULL_RTX
...@@ -458,7 +470,8 @@ i386_pe_encode_section_info (decl, first) ...@@ -458,7 +470,8 @@ i386_pe_encode_section_info (decl, first)
&& i386_pe_dllimport_name_p (XSTR (XEXP (XEXP (DECL_RTL (decl), 0), 0), 0))) && 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); const char *oldname = XSTR (XEXP (XEXP (DECL_RTL (decl), 0), 0), 0);
tree idp = get_identifier (oldname + 9); /* Remove DLL_IMPORT_PREFIX. */
tree idp = get_identifier (oldname + strlen (DLL_IMPORT_PREFIX));
rtx newrtl = gen_rtx (SYMBOL_REF, Pmode, IDENTIFIER_POINTER (idp)); rtx newrtl = gen_rtx (SYMBOL_REF, Pmode, IDENTIFIER_POINTER (idp));
XEXP (DECL_RTL (decl), 0) = newrtl; XEXP (DECL_RTL (decl), 0) = newrtl;
...@@ -477,8 +490,12 @@ const char * ...@@ -477,8 +490,12 @@ const char *
i386_pe_strip_name_encoding (str) i386_pe_strip_name_encoding (str)
const char *str; const char *str;
{ {
if (*str == DLL_IMPORT_EXPORT_PREFIX) if (strncmp (str, DLL_IMPORT_PREFIX, strlen (DLL_IMPORT_PREFIX))
str += 3; == 0)
str += strlen (DLL_IMPORT_PREFIX);
else if (strncmp (str, DLL_EXPORT_PREFIX, strlen (DLL_EXPORT_PREFIX))
== 0)
str += strlen (DLL_EXPORT_PREFIX);
if (*str == '*') if (*str == '*')
str += 1; str += 1;
return str; return str;
...@@ -508,30 +525,34 @@ void i386_pe_output_labelref (stream, name) ...@@ -508,30 +525,34 @@ void i386_pe_output_labelref (stream, name)
FILE *stream; FILE *stream;
const char *name; const char *name;
{ {
char prefix[4]; if (strncmp (name, DLL_IMPORT_PREFIX, strlen (DLL_IMPORT_PREFIX))
== 0)
sprintf (prefix, "%ci.", DLL_IMPORT_EXPORT_PREFIX); /* A dll import */
if (strncmp (name, prefix, strlen (prefix)) == 0)
{ {
if (name[3] == FASTCALL_PREFIX) if (name[strlen (DLL_IMPORT_PREFIX)] == FASTCALL_PREFIX)
/* A dllimport fastcall symbol. */
{ {
fprintf (stream, "__imp_%s", fprintf (stream, "__imp_%s",
i386_pe_strip_name_encoding (name)); i386_pe_strip_name_encoding (name));
} }
else else
/* A dllimport non-fastcall symbol. */
{ {
fprintf (stream, "__imp__%s", fprintf (stream, "__imp__%s",
i386_pe_strip_name_encoding (name)); i386_pe_strip_name_encoding (name));
} }
} }
else if ((name[0] == FASTCALL_PREFIX) else if ((name[0] == FASTCALL_PREFIX)
|| ((name[0] == DLL_IMPORT_EXPORT_PREFIX) || (strncmp (name, DLL_EXPORT_PREFIX, strlen (DLL_EXPORT_PREFIX)
&& (name[3] == FASTCALL_PREFIX))) == 0
&& name[strlen (DLL_EXPORT_PREFIX)] == FASTCALL_PREFIX)))
/* A fastcall symbol. */
{ {
fprintf (stream, "%s", fprintf (stream, "%s",
i386_pe_strip_name_encoding (name)); i386_pe_strip_name_encoding (name));
} }
else else
/* Everything else. */
{ {
fprintf (stream, "%s%s", USER_LABEL_PREFIX, fprintf (stream, "%s%s", USER_LABEL_PREFIX,
i386_pe_strip_name_encoding (name)); i386_pe_strip_name_encoding (name));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment