From b64deb96ba30ac61563887cd76dc11b8904ccbc5 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 25 Apr 1997 02:15:39 +0000 Subject: [PATCH] x From-SVN: r13980 --- gcc/config/i386/cygwin32.h | 41 ++++++++++++++++++++++++++++++-------- gcc/config/i386/winnt.c | 26 ++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 8 deletions(-) diff --git a/gcc/config/i386/cygwin32.h b/gcc/config/i386/cygwin32.h index b8cbc36af8a..fe404e0d0ef 100644 --- a/gcc/config/i386/cygwin32.h +++ b/gcc/config/i386/cygwin32.h @@ -158,14 +158,6 @@ while (0) #define TARGET_DEFAULT \ (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE) -/* A C statement to output something to the assembler file to switch to section - NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or - NULL_TREE. Some target formats do not support arbitrary sections. Do not - define this macro in such cases. */ - -#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \ - fprintf (FILE, "\t.section %s\n", NAME) - /* This is how to output an assembler line that says to advance the location counter to a multiple of 2**LOG bytes. */ @@ -173,3 +165,36 @@ while (0) #undef ASM_OUTPUT_ALIGN #define ASM_OUTPUT_ALIGN(FILE,LOG) \ if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG)) + +/* For objects going into their own sections, a C expression of name of the + section, expressed as a STRING_CST node, to put DECL into. The + STRING_CST node must be allocated in the saveable obstack. Function + build_string can be used to do this. Define this macro if the name of a + symbol cannot be used as its section name. */ +extern union tree_node *i386_pe_unique_section (); +#define UNIQUE_SECTION(DECL) i386_pe_unique_section (DECL) + +#define MAKE_DECL_ONE_ONLY(DECL) \ + DECL_SECTION_NAME (DECL) = UNIQUE_SECTION (DECL) + +/* A C statement to output something to the assembler file to switch to section + NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or + NULL_TREE. Some target formats do not support arbitrary sections. Do not + define this macro in such cases. */ +#undef ASM_OUTPUT_SECTION_NAME +#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME) \ +do { \ + if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \ + fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \ + else if ((DECL) && TREE_READONLY (DECL)) \ + fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \ + else \ + fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \ + /* Functions may have been compiled at various levels of \ + optimization so we can't use `same_size' here. Instead, \ + have the linker pick one. */ \ + if ((DECL) && DECL_ONE_ONLY (DECL)) \ + fprintf (STREAM, "\t.linkonce %s\n", \ + TREE_CODE (DECL) == FUNCTION_DECL \ + ? "discard" : "same_size"); \ +} while (0) diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c index 9920b8d4f8d..9a32aaa5f89 100644 --- a/gcc/config/i386/winnt.c +++ b/gcc/config/i386/winnt.c @@ -64,3 +64,29 @@ gen_stdcall_suffix (decl) return IDENTIFIER_POINTER (get_identifier (newsym)); } +/* Cover function for UNIQUE_SECTION. */ + +tree +i386_pe_unique_section (decl) + tree decl; +{ + int len; + char *name,*string,*prefix; + + name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); + + /* The object is put in, for example, section .text$foo. + The linker will then ultimately place them in .text + (everything from the $ on is stripped). */ + if (TREE_CODE (decl) == FUNCTION_DECL) + prefix = ".text$"; + else if (TREE_READONLY (decl)) + prefix = ".rdata$"; + else + prefix = ".data$"; + len = strlen (name) + strlen (prefix); + string = alloca (len + 1); + sprintf (string, "%s%s", prefix, name); + + return build_string (len, string); +} -- 2.30.2