aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <merrill@gnu.org>1997-04-25 02:15:39 +0000
committerJason Merrill <merrill@gnu.org>1997-04-25 02:15:39 +0000
commitb64deb96ba30ac61563887cd76dc11b8904ccbc5 (patch)
treedc13ef82b7552c95c617fd5dc6efc4f0d6857559
parent52a18c1031e2540f517ac918ba5bd0b186cc1987 (diff)
downloadgcc-b64deb96ba30ac61563887cd76dc11b8904ccbc5.zip
gcc-b64deb96ba30ac61563887cd76dc11b8904ccbc5.tar.gz
gcc-b64deb96ba30ac61563887cd76dc11b8904ccbc5.tar.bz2
x
From-SVN: r13980
-rw-r--r--gcc/config/i386/cygwin32.h41
-rw-r--r--gcc/config/i386/winnt.c26
2 files changed, 59 insertions, 8 deletions
diff --git a/gcc/config/i386/cygwin32.h b/gcc/config/i386/cygwin32.h
index b8cbc36..fe404e0 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 9920b8d..9a32aaa 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);
+}