x
authorJason Merrill <merrill@gnu.org>
Wed, 30 Apr 1997 18:13:30 +0000 (18:13 +0000)
committerJason Merrill <merrill@gnu.org>
Wed, 30 Apr 1997 18:13:30 +0000 (18:13 +0000)
From-SVN: r13994

21 files changed:
gcc/config/a29k/a29k.h
gcc/config/alpha/elf.h
gcc/config/arm/coff.h
gcc/config/h8300/h8300.h
gcc/config/i386/cygwin32.h
gcc/config/i386/go32.h
gcc/config/i386/sco5.h
gcc/config/i386/winnt.c
gcc/config/m68k/coff.h
gcc/config/mips/elf64.h
gcc/config/mips/iris6.h
gcc/config/mips/netbsd.h
gcc/config/pa/pa.h
gcc/config/psos.h
gcc/config/ptx4.h
gcc/config/rs6000/sysv4.h
gcc/config/sh/sh.h
gcc/config/sparc/sysv4.h
gcc/config/svr4.h
gcc/output.h
gcc/varasm.c

index 2b607e786e972face4a1cc6f36782cd9958187e4..59e9a13d628c5db6eca99795ab41faa192418818 100644 (file)
@@ -1450,7 +1450,7 @@ extern int a29k_debug_reg_map[];
 /* This how to write an assembler directive to FILE to switch to
    section NAME for DECL.  */
 
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
+#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
   fprintf (FILE, "\t.sect %s, bss\n\t.use %s\n", NAME, NAME)
 
 /* This is how to output the definition of a user-level label named NAME,
index 62d00adeb61193b6446176cb82feffb4411660e1..6eb94cd86b2376dd7a5cd619cdb5f60f70d2d65f 100644 (file)
@@ -276,10 +276,10 @@ dtors_section ()                                                  \
 
    We make the section read-only and executable for a function decl,
    read-only for a const data decl, and writable for a non-const data decl.  */
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
+#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
   fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
           (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
-          (DECL) && TREE_READONLY (DECL) ? "a" : "aw")
+          (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
 
 
 /* A C statement (sans semicolon) to output an element in the table of
index ebc8a8c6ca08ea0e41e6b61af7409d9ece79202c..18a07187e7e3baaf75f98ccaad86512dd9943149 100644 (file)
@@ -87,11 +87,11 @@ do {                                                                \
    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(STREAM, DECL, NAME) \
+#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
 do {                                                           \
   if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL)             \
     fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME));         \
-  else if ((DECL) && TREE_READONLY (DECL))                     \
+  else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC))      \
     fprintf (STREAM, "\t.section %s,\"\"\n", (NAME));          \
   else                                                         \
     fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME));         \
index 8e42f47f5a73dbbeda485b7342e0d30815409fc8..60a053245706206f6e48f2cf1be8493ffcf21536 100644 (file)
@@ -1182,7 +1182,7 @@ readonly_data()                                           \
    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) \
+#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
   fprintf (FILE, "\t.section %s\n", NAME)
 
 /* This is how to output the definition of a user-level label named NAME,
index ec2661cdcba14cc8ed935b5814e16a61365b64c8..88b367bc1cb40f64d592d91a1ea05ec0017a9a96 100644 (file)
@@ -172,27 +172,22 @@ while (0)
    symbols must be explicitly imported from shared libraries (DLLs).  */
 #define MULTIPLE_SYMBOL_SPACES
 
-/* 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 UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
+extern void i386_pe_unique_section ();
+#define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC)
 
-#define MAKE_DECL_ONE_ONLY(DECL)                       \
-  DECL_SECTION_NAME (DECL) = UNIQUE_SECTION (DECL)
+#define SUPPORTS_ONE_ONLY 1
 
 /* 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) \
+#define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC)     \
 do {                                                           \
   if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL)             \
     fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME));         \
-  else if ((DECL) && TREE_READONLY (DECL))                     \
+  else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC))      \
     fprintf (STREAM, "\t.section %s,\"\"\n", (NAME));          \
   else                                                         \
     fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME));         \
index 933f18409c62c653e3d96f8357ac672e32eb0fe3..c256f7d43554a512ca7452249792244a381001bf 100644 (file)
@@ -58,7 +58,7 @@ dtor_section ()                                                       \
   } while (0)
 
 /* Allow (eg) __attribute__((section "locked")) to work */
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME)\
+#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC)\
   do {                                         \
     fprintf (FILE, "\t.section %s\n", NAME);   \
   } while (0)
@@ -81,11 +81,6 @@ dtor_section ()                                                      \
        output_file_directive (FILE, main_input_filename);              \
   } while (0)
 
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME)\
-  do {                                         \
-    fprintf (FILE, "\t.section %s\n", NAME);   \
-  } while (0)
-
 /* This is how to output an assembler line
    that says to advance the location counter
    to a multiple of 2**LOG bytes.  */
index d156cab601e6956dd58721211a9426968badf53c..d5471ecdec3038c33e0f05db993ae6e3d887667f 100644 (file)
@@ -477,18 +477,18 @@ do {                                                                      \
 #define USER_LABEL_PREFIX ""
 
 #undef ASM_OUTPUT_SECTION_NAME
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
+#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
 do {                                                                   \
   char *snam = NAME ;                                                  \
   if (strcmp(NAME, ".gcc_except_table") == 0) snam = ".gccexc" ;       \
   if (TARGET_ELF)                                                      \
     fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME,            \
           (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" :         \
-          (DECL) && TREE_READONLY (DECL) ? "a" : "aw");                \
+          (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw"); \
   else                                                                 \
     fprintf (FILE, ".section\t%s,\"%s\"\n", snam,                      \
        (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "x" :             \
-       (DECL) && TREE_READONLY (DECL) ? "a" : "w");                    \
+       (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "w");     \
 } while (0)
 
 #undef ASM_OUTPUT_SKIP
index 9a32aaa5f894c1537234fb18a6a9b63d9925634e..72666921ed184ff7de3862ad2de187d56a0a77f0 100644 (file)
@@ -67,8 +67,9 @@ gen_stdcall_suffix (decl)
 /* Cover function for UNIQUE_SECTION.  */
 
 tree
-i386_pe_unique_section (decl)
+i386_pe_unique_section (decl, reloc)
      tree decl;
+     int reloc;
 {
   int len;
   char *name,*string,*prefix;
@@ -80,7 +81,7 @@ i386_pe_unique_section (decl)
      (everything from the $ on is stripped).  */
   if (TREE_CODE (decl) == FUNCTION_DECL)
     prefix = ".text$";
-  else if (TREE_READONLY (decl))
+  else if (DECL_READONLY_SECTION (decl, reloc))
     prefix = ".rdata$";
   else
     prefix = ".data$";
index 85b1061a84bb9aa492437d0caab908e1c521dc31..acd45e7bb2d12713122b87c923738ef20129756f 100644 (file)
@@ -103,10 +103,10 @@ Boston, MA 02111-1307, USA.  */
 /* Support generic sections */
 
 #undef ASM_OUTPUT_SECTION_NAME
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
+#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
   fprintf((FILE), ".section\t%s,\"%c\"\n", (NAME), \
          (DECL) && (TREE_CODE (DECL) == FUNCTION_DECL || \
-                    TREE_READONLY (DECL)) ? 'x' : 'd')
+                    DECL_READONLY_SECTION (DECL, RELOC)) ? 'x' : 'd')
 
 /* Support the ctors and dtors sections for g++.  */
 
index 358316c1c644ae91880017969f769615763c1d2d..3d1a91bba8f5b4cfc88aed2ea1bdad181b9b9566 100644 (file)
@@ -83,12 +83,12 @@ do {                                                        \
    NULL_TREE.  Some target formats do not support arbitrary sections.  Do not
    define this macro in such cases.  */
 
-#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME) \
+#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC) \
 do {                                                           \
   extern FILE *asm_out_text_file;                              \
   if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL)             \
     fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \
-  else if ((DECL) && TREE_READONLY (DECL))                     \
+  else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC))      \
     fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME));    \
   else                                                         \
     fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME));   \
index c9ec59dc62a141de9859c23da1e85fce6927a363..dd9914576a0b2c4fb54fe81f0438e28e202d2582 100644 (file)
@@ -338,12 +338,12 @@ dtors_section ()                                                  \
    NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
    NULL_TREE.  */
 
-#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME)                         \
+#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC)                  \
 do {                                                                   \
   extern FILE *asm_out_text_file;                                      \
   if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL)                     \
     fprintf (asm_out_text_file, "\t.section %s,1,6,4,4\n", (NAME));    \
-  else if ((DECL) && TREE_READONLY (DECL))                             \
+  else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC))              \
     fprintf (F, "\t.section %s,1,2,0,8\n", (NAME));                    \
   else                                                                 \
     fprintf (F, "\t.section %s,1,3,0,8\n", (NAME));                    \
index 1973cc352cfd2ebcba79bbf163b3d0647b2b93e2..9ed8dfd8dfc154507ca5286a2159a887778587bb 100644 (file)
@@ -211,12 +211,12 @@ do {                                                                       \
  NULL_TREE.  Some target formats do not support arbitrary sections.  Do not
  define this macro in such cases.
 */
-#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME)                               \
+#define ASM_OUTPUT_SECTION_NAME(F, DECL, NAME, RELOC)                        \
 do {                                                                         \
   extern FILE *asm_out_text_file;                                            \
   if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL)                           \
     fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \
-  else if ((DECL) && TREE_READONLY (DECL))                                   \
+  else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC))                    \
     fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME));                  \
   else                                                                       \
     fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME));                 \
index 30a070b297fd66f4519770761fbad02497a87b26..4751a8d2a4fd00a0c18bda20d9a07375a9d73348 100644 (file)
@@ -1976,7 +1976,7 @@ do { fputs ("\t.SPACE $PRIVATE$\n\
 
    We make the section read-only and executable for a function decl,
    read-only for a const data decl, and writable for a non-const data decl.  */
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
+#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
   if (DECL && TREE_CODE (DECL) == FUNCTION_DECL)               \
     {                                                          \
       fputs ("\t.SPACE $TEXT$\n", FILE);                       \
@@ -1984,7 +1984,7 @@ do { fputs ("\t.SPACE $PRIVATE$\n\
               "\t.SUBSPA %s%s%s,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY,SORT=24\n",\
               TARGET_GAS ? "" : "$", NAME, TARGET_GAS ? "" : "$"); \
     }                                                          \
-  else if (DECL && TREE_READONLY (DECL))                       \
+  else if (DECL && DECL_READONLY_SECTION (DECL, RELOC))                \
     {                                                          \
       fputs ("\t.SPACE $TEXT$\n", FILE);                       \
       fprintf (FILE,                                           \
index 0299a35d8ec071276ce2b3856dc135f5ba90912a..d4043002a1c142ec7fa55177478b88f9b53036eb 100644 (file)
@@ -87,10 +87,10 @@ while (0)
 
 /* Switch into a generic section. */
 
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
+#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
   fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
           (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
-          (DECL) && TREE_READONLY (DECL) ? "a" : "aw")
+          (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
 
 
 /* Define the pseudo-ops used to switch to the .ctors and .dtors
index 7bda47c923513f73d8f758f0a8a17b586b00d7b4..80b7b165d0cc052e41f962df5f89e59f0b43baf2 100644 (file)
@@ -541,10 +541,10 @@ dtors_section ()                                                  \
 
    We make the section read-only and executable for a function decl,
    read-only for a const data decl, and writable for a non-const data decl. */
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
+#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
   fprintf (FILE, ".section\t%s,\"%s\",@progbits\n", NAME, \
           (DECL) && TREE_CODE (DECL) == FUNCTION_DECL ? "ax" : \
-          (DECL) && TREE_READONLY (DECL) ? "a" : "aw")
+          (DECL) && DECL_READONLY_SECTION (DECL, RELOC) ? "a" : "aw")
 
 
 /* A C statement (sans semicolon) to output an element in the table of
index 867b32868a5176c61621d2330722fc0ce82a0462..635bb329d116dbea534a5c99b69763db6656ce91 100644 (file)
@@ -865,7 +865,7 @@ do {                                                                        \
  */
 
 #undef ASM_OUTPUT_SECTION_NAME
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME)                      \
+#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC)               \
 do {                                                                   \
   static struct section_info                                           \
     {                                                                  \
@@ -883,7 +883,7 @@ do {                                                                        \
                                                                        \
   if (DECL && TREE_CODE (DECL) == FUNCTION_DECL)                       \
     type = SECT_EXEC, mode = "ax";                                     \
-  else if (DECL && TREE_READONLY (DECL) && !TARGET_RELOCATABLE && !flag_pic) \
+  else if (DECL && DECL_READONLY_SECTION (DECL, RELOC) && !TARGET_RELOCATABLE && !flag_pic) \
     type = SECT_RO, mode = "a";                                                \
   else                                                                 \
     type = SECT_RW, mode = "aw";                                       \
index e88fa08be8931c725f55be73166c895d29e31435..022c9bcb4c42d2aabe7baf6434c14d07a3433f8f 100644 (file)
@@ -1373,7 +1373,7 @@ dtors_section()                                                   \
    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) \
+#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
    do { fprintf (FILE, ".section\t%s\n", NAME); } while (0)
 
 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
index 4dfde2af3d021a483b2941510b680f683a2050d6..96e49f9babe61f872e9912479c2e53ab60f0aa75 100644 (file)
@@ -186,12 +186,12 @@ do { ASM_OUTPUT_ALIGN ((FILE), Pmode == SImode ? 2 : 3);          \
    define this macro in such cases.  */
 
 #undef ASM_OUTPUT_SECTION_NAME /* Override svr4.h's definition.  */
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME) \
+#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
 do {                                                                   \
   if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL)                     \
     fprintf (FILE, ".section\t\"%s%s\",#alloc,#execinstr\n",           \
             flag_function_sections ? ".text%" : "", (NAME));           \
-  else if ((DECL) && TREE_READONLY (DECL))                             \
+  else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC))              \
     fprintf (FILE, ".section\t\"%s\",#alloc\n", (NAME));               \
   else                                                                 \
     fprintf (FILE, ".section\t\"%s\",#alloc,#write\n", (NAME));                \
index 19d566dbd720f78343e2df837f4e969c6ff63e7b..d70aa1175582fb3f8bb6e191ca68f9cab3cc29ae 100644 (file)
@@ -593,19 +593,17 @@ dtors_section ()                                                  \
     }                                                                  \
 }
 
-
-/*
- * Switch into a generic section.
- *
- * We make the section read-only and executable for a function decl,
- * read-only for a const data decl, and writable for a non-const data decl.
- *
- * If the section has already been defined, we must not
- * emit the attributes here. The SVR4 assembler does not
- * recognize section redefinitions.
- * If DECL is NULL, no attributes are emitted.
- */
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME)                      \
+/* Switch into a generic section.
+   We make the section read-only and executable for a function decl,
+   read-only for a const data decl, and writable for a non-const data decl.
+   If the section has already been defined, we must not
+   emit the attributes here. The SVR4 assembler does not
+   recognize section redefinitions.
+   If DECL is NULL, no attributes are emitted.  */
+
+#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC)               \
 do {                                                                   \
   static struct section_info                                           \
     {                                                                  \
@@ -623,7 +621,7 @@ do {                                                                        \
                                                                        \
   if (DECL && TREE_CODE (DECL) == FUNCTION_DECL)                       \
     type = SECT_EXEC, mode = "ax";                                     \
-  else if (DECL && TREE_READONLY (DECL))                               \
+  else if (DECL && DECL_READONLY_SECTION (DECL, RELOC))                        \
     type = SECT_RO, mode = "a";                                                \
   else                                                                 \
     type = SECT_RW, mode = "aw";                                       \
@@ -647,21 +645,20 @@ do {                                                                      \
     }                                                                  \
 } while (0)
 
-/* A C statement (sans semicolon) to mark DECL to be emitted as a
-   public symbol such that extra copies in multiple translation units will
-   be discarded by the linker.  */
-#define MAKE_DECL_ONE_ONLY(DECL)                               \
+#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
+#define UNIQUE_SECTION_P(DECL) (DECL_ONE_ONLY (DECL))
+#define UNIQUE_SECTION(DECL,RELOC)                             \
 do {                                                           \
   int len;                                                     \
   char *name, *string, *prefix;                                        \
                                                                \
-  DECL_WEAK (DECL) = 1;                                                \
-                                                               \
   name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));      \
                                                                \
-  if (TREE_CODE (DECL) == FUNCTION_DECL)                       \
+  if (! DECL_ONE_ONLY (DECL))                                  \
+    prefix = ".";                                              \
+  else if (TREE_CODE (DECL) == FUNCTION_DECL)                  \
     prefix = ".gnu.linkonce.t.";                               \
-  else if (TREE_READONLY (DECL))                               \
+  else if (DECL_READONLY_SECTION (DECL, RELOC))                        \
     prefix = ".gnu.linkonce.r.";                               \
   else                                                         \
     prefix = ".gnu.linkonce.d.";                               \
@@ -711,10 +708,7 @@ do {                                                               \
     }                                                                  \
   else if (TREE_CODE (DECL) == VAR_DECL)                               \
     {                                                                  \
-      if (!TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)            \
-         || !DECL_INITIAL (DECL)                                       \
-         || (DECL_INITIAL (DECL) != error_mark_node                    \
-             && !TREE_CONSTANT (DECL_INITIAL (DECL))))                 \
+      if (! DECL_READONLY_SECTION (DECL, RELOC))                       \
        data_section ();                                                \
       else                                                             \
        const_section ();                                               \
index 8722b64759027bc6dab9436e9d82bf1989b15104..749043b38fad16e2bc8e5cb3a31a89388262e798 100644 (file)
@@ -134,8 +134,9 @@ extern int in_text_section          PROTO((void));
 #ifdef TREE_CODE
 /* Tell assembler to change to section NAME for DECL.
    If DECL is NULL, just switch to section NAME.
-   If NAME is NULL, get the name from DECL.  */
-extern void named_section              PROTO((tree, char *));
+   If NAME is NULL, get the name from DECL.
+   If RELOC is 1, the initializer for DECL contains relocs.  */
+extern void named_section              PROTO((tree, char *, int));
 
 /* Tell assembler to switch to the section for function DECL.  */
 extern void function_section           PROTO((tree));
@@ -429,3 +430,14 @@ extern int sdb_begin_function_line;
 #ifdef BUFSIZ
 extern FILE *asm_out_file;
 #endif
+
+/* Decide whether DECL needs to be in a writable section.  RELOC is the same
+   as for SELECT_SECTION.  */
+
+#define DECL_READONLY_SECTION(DECL,RELOC)              \
+  (TREE_READONLY (DECL)                                        \
+   && ! TREE_THIS_VOLATILE (DECL)                      \
+   && DECL_INITIAL (DECL)                              \
+   && (DECL_INITIAL (DECL) == error_mark_node          \
+       || TREE_CONSTANT (DECL_INITIAL (DECL)))         \
+   && ! (RELOC && (flag_pic || DECL_ONE_ONLY (DECL))))
index c422fbc3a08f7062f71d49ca2953a243053ae812..3d4e87afa0bf71c74e1f650400c1ce83cbcd1a0d 100644 (file)
@@ -250,12 +250,14 @@ in_data_section ()
 
 /* Tell assembler to change to section NAME for DECL.
    If DECL is NULL, just switch to section NAME.
-   If NAME is NULL, get the name from DECL.  */
+   If NAME is NULL, get the name from DECL.
+   If RELOC is 1, the initializer for DECL contains relocs.  */
 
 void
-named_section (decl, name)
+named_section (decl, name, reloc)
      tree decl;
      char *name;
+     int reloc;
 {
   if (decl != NULL_TREE
       && TREE_CODE_CLASS (TREE_CODE (decl)) != 'd')
@@ -270,7 +272,7 @@ named_section (decl, name)
       in_section = in_named;
     
 #ifdef ASM_OUTPUT_SECTION_NAME
-      ASM_OUTPUT_SECTION_NAME (asm_out_file, decl, name);
+      ASM_OUTPUT_SECTION_NAME (asm_out_file, decl, name, reloc);
 #else
       /* Section attributes are not supported if this macro isn't provided -
         some host formats don't support them at all.  The front-end should
@@ -280,6 +282,29 @@ named_section (decl, name)
     }
 }
 
+#ifdef ASM_OUTPUT_SECTION_NAME
+#ifndef UNIQUE_SECTION
+#define UNIQUE_SECTION(DECL,RELOC)                             \
+do {                                                           \
+  int len;                                                     \
+  char *name, *string;                                         \
+                                                               \
+  name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (DECL));      \
+  /* Strip off any encoding in name.  */                       \
+  STRIP_NAME_ENCODING (name, name);                            \
+                                                               \
+  len = strlen (name) + 1;                                     \
+  string = alloca (len + 1);                                   \
+  sprintf (string, ".%s", name);                               \
+                                                               \
+  DECL_SECTION_NAME (DECL) = build_string (len, string);       \
+} while (0)
+#endif
+#ifndef UNIQUE_SECTION_P
+#define UNIQUE_SECTION_P(DECL) 0
+#endif
+#endif
+
 #ifdef BSS_SECTION_ASM_OP
 
 /* Tell the assembler to switch to the bss section.  */
@@ -376,7 +401,7 @@ function_section (decl)
 {
   if (decl != NULL_TREE
       && DECL_SECTION_NAME (decl) != NULL_TREE)
-    named_section (decl, (char *) 0);
+    named_section (decl, (char *) 0, 0);
   else
     text_section ();
 }
@@ -391,7 +416,7 @@ variable_section (decl, reloc)
      int reloc;
 {
   if (IN_NAMED_SECTION (decl))
-    named_section (decl, NULL);
+    named_section (decl, NULL, reloc);
   else
     {
       /* C++ can have const variables that get initialized from constructors,
@@ -410,12 +435,7 @@ variable_section (decl, reloc)
 #ifdef SELECT_SECTION
       SELECT_SECTION (decl, reloc);
 #else
-      if (TREE_READONLY (decl)
-         && ! TREE_THIS_VOLATILE (decl)
-         && DECL_INITIAL (decl)
-         && (DECL_INITIAL (decl) == error_mark_node
-             || TREE_CONSTANT (DECL_INITIAL (decl)))
-         && ! (flag_pic && reloc))
+      if (DECL_READONLY_SECTION (decl, reloc))
        readonly_data_section ();
       else
        data_section ();
@@ -430,7 +450,7 @@ void
 exception_section ()
 {
 #ifdef ASM_OUTPUT_SECTION_NAME
-  named_section (NULL_TREE, ".gcc_except_table");
+  named_section (NULL_TREE, ".gcc_except_table", 0);
 #else
   if (flag_pic)
     data_section ();
@@ -938,18 +958,10 @@ assemble_start_function (decl, fnname)
 #ifdef ASM_OUTPUT_SECTION_NAME
   /* If the function is to be put in its own section and it's not in a section
      already, indicate so.  */
-  if (flag_function_sections
-      && DECL_SECTION_NAME (decl) == NULL_TREE)
-    {
-#ifdef UNIQUE_SECTION
-      DECL_SECTION_NAME(decl) = UNIQUE_SECTION (decl);
-#else
-      char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-      /* Strip off any encoding in name.  */
-      STRIP_NAME_ENCODING (name, name);
-      DECL_SECTION_NAME (decl) = build_string (strlen (name), name);
-#endif
-    }
+  if ((flag_function_sections
+       && DECL_SECTION_NAME (decl) == NULL_TREE)
+      || UNIQUE_SECTION_P (decl))
+    UNIQUE_SECTION (decl, 0);
 #endif
 
   function_section (decl);
@@ -1438,6 +1450,11 @@ assemble_variable (decl, top_level, at_end, dont_output_data)
   else if (DECL_INITIAL (decl))
     reloc = output_addressed_constants (DECL_INITIAL (decl));
 
+#ifdef ASM_OUTPUT_SECTION_NAME
+  if (UNIQUE_SECTION_P (decl))
+    UNIQUE_SECTION (decl, reloc);
+#endif
+
   /* Switch to the appropriate section.  */
   variable_section (decl, reloc);
 
@@ -3050,7 +3067,7 @@ output_constant_def_contents (exp, reloc, labelno)
   int align;
 
   if (IN_NAMED_SECTION (exp))
-    named_section (exp, NULL);
+    named_section (exp, NULL, reloc);
   else
     {
       /* First switch to text section, except for writable strings.  */