diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cccdf4611cf..e0f21f7a0e2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ Mon Jun 21 05:33:15 1999 Mumit Khan + * i386/winnt.c (exports_head): New static variable. + (i386_pe_record_exported_symbol): New function. + (i386_pe_asm_file_end): Use. + * i386/cygwin.h (ASM_OUTPUT_COMMON): Record the exported + symbols to be emitted at end of assembly. + (ASM_DECLARE_OBJECT_NAME): Likewise. + (ASM_DECLARE_FUNCTION_NAME): Likewise. + * i386/uwin.h (CPP_SPEC): Use -idirafter instead -iprefix and -iwithprefix. diff --git a/gcc/config/i386/cygwin.h b/gcc/config/i386/cygwin.h index 0b6a70fc42b..dbea466bc86 100644 --- a/gcc/config/i386/cygwin.h +++ b/gcc/config/i386/cygwin.h @@ -326,11 +326,7 @@ do { \ #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \ do { \ if (i386_pe_dllexport_name_p (NAME)) \ - { \ - drectve_section (); \ - fprintf ((STREAM), "\t.ascii \" -export:%s\"\n", \ - I386_PE_STRIP_ENCODING (NAME)); \ - } \ + i386_pe_record_exported_symbol (NAME); \ if (! i386_pe_dllimport_name_p (NAME)) \ { \ fprintf ((STREAM), "\t.comm\t"); \ @@ -345,13 +341,7 @@ do { \ #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) \ do { \ if (i386_pe_dllexport_name_p (NAME)) \ - { \ - enum in_section save_section = in_section; \ - drectve_section (); \ - fprintf ((STREAM), "\t.ascii \" -export:%s\"\n", \ - I386_PE_STRIP_ENCODING (NAME)); \ - switch_to_section (save_section, (DECL)); \ - } \ + i386_pe_record_exported_symbol (NAME); \ ASM_OUTPUT_LABEL ((STREAM), (NAME)); \ } while (0) @@ -447,12 +437,7 @@ do { \ do \ { \ if (i386_pe_dllexport_name_p (NAME)) \ - { \ - drectve_section (); \ - fprintf ((FILE), "\t.ascii \" -export:%s\"\n", \ - I386_PE_STRIP_ENCODING (NAME)); \ - function_section (DECL); \ - } \ + i386_pe_record_exported_symbol (NAME); \ if (write_symbols != SDB_DEBUG) \ i386_pe_declare_function_type (FILE, NAME, TREE_PUBLIC (DECL)); \ ASM_OUTPUT_LABEL (FILE, NAME); \ @@ -518,6 +503,7 @@ do { \ extern void i386_pe_record_external_function PROTO((char *)); extern void i386_pe_declare_function_type STDIO_PROTO((FILE *, char *, int)); +extern void i386_pe_record_exported_symbol PROTO((char *)); extern void i386_pe_asm_file_end STDIO_PROTO((FILE *)); /* For Win32 ABI compatibility */ diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c index f1a2d4b83be..24d8617f8df 100644 --- a/gcc/config/i386/winnt.c +++ b/gcc/config/i386/winnt.c @@ -545,8 +545,29 @@ i386_pe_record_external_function (name) extern_head = p; } +static struct extern_list *exports_head; + +/* Assemble an export symbol entry. We need to keep a list of + these, so that we can output the export list at the end of the + assembly. We used to output these export symbols in each function, + but that causes problems with GNU ld when the sections are + linkonce. */ + +void +i386_pe_record_exported_symbol (name) + char *name; +{ + struct extern_list *p; + + p = (struct extern_list *) permalloc (sizeof *p); + p->next = exports_head; + p->name = name; + exports_head = p; +} + /* This is called at the end of assembly. For each external function - which has not been defined, we output a declaration now. */ + which has not been defined, we output a declaration now. We also + output the .drectve section. */ void i386_pe_asm_file_end (file) @@ -567,4 +588,13 @@ i386_pe_asm_file_end (file) i386_pe_declare_function_type (file, p->name, TREE_PUBLIC (decl)); } } + + if (exports_head) + drectve_section (); + for (p = exports_head; p != NULL; p = p->next) + { + fprintf (file, "\t.ascii \" -export:%s\"\n", + I386_PE_STRIP_ENCODING (p->name)); + } } +