output.h (SECTION_NOTYPE): Define.
authorAlan Modra <amodra@bigpond.net.au>
Tue, 22 Oct 2002 07:59:41 +0000 (07:59 +0000)
committerAlan Modra <amodra@gcc.gnu.org>
Tue, 22 Oct 2002 07:59:41 +0000 (17:29 +0930)
* output.h (SECTION_NOTYPE): Define.
* varasm.c (default_section_type_flags_1): Set SECTION_NOTYPE for
init array sections.
(default_elf_asm_named_section): Mind SECTION_NOTYPE.
* config/arm/arm.c (arm_elf_asm_named_section): Likewise.  Also
merge TLS support.

From-SVN: r58404

gcc/ChangeLog
gcc/config/arm/arm.c
gcc/output.h
gcc/varasm.c

index de0f8b5..c1656be 100644 (file)
@@ -1,3 +1,12 @@
+2002-10-22  Alan Modra  <amodra@bigpond.net.au>
+
+       * output.h (SECTION_NOTYPE): Define.
+       * varasm.c (default_section_type_flags_1): Set SECTION_NOTYPE for
+       init array sections.
+       (default_elf_asm_named_section): Mind SECTION_NOTYPE.
+       * config/arm/arm.c (arm_elf_asm_named_section): Likewise.  Also
+       merge TLS support.
+
 2002-10-21  Richard Henderson  <rth@redhat.com>
 
        * real.c (sticky_rshift_significand): Return inexact, don't
index 70e0291..d6c1a02 100644 (file)
@@ -11068,8 +11068,13 @@ arm_elf_asm_named_section (name, flags)
      const char *name;
      unsigned int flags;
 {
-  char flagchars[8], *f = flagchars;
-  const char *type;
+  char flagchars[10], *f = flagchars;
+
+  if (! named_section_first_declaration (name))
+    {
+      fprintf (asm_out_file, "\t.section\t%s\n", name);
+      return;
+    }
 
   if (!(flags & SECTION_DEBUG))
     *f++ = 'a';
@@ -11083,19 +11088,28 @@ arm_elf_asm_named_section (name, flags)
     *f++ = 'M';
   if (flags & SECTION_STRINGS)
     *f++ = 'S';
+  if (flags & SECTION_TLS)
+    *f++ = 'T';
   *f = '\0';
 
-  if (flags & SECTION_BSS)
-    type = "nobits";
-  else
-    type = "progbits";
+  fprintf (asm_out_file, "\t.section\t%s,\"%s\"", name, flagchars);
 
-  if (flags & SECTION_ENTSIZE)
-    fprintf (asm_out_file, "\t.section\t%s,\"%s\",%%%s,%d\n",
-            name, flagchars, type, flags & SECTION_ENTSIZE);
-  else
-    fprintf (asm_out_file, "\t.section\t%s,\"%s\",%%%s\n",
-            name, flagchars, type);
+  if (!(flags & SECTION_NOTYPE))
+    {
+      const char *type;
+
+      if (flags & SECTION_BSS)
+       type = "nobits";
+      else
+       type = "progbits";
+
+      fprintf (asm_out_file, ",%%%s", type);
+
+      if (flags & SECTION_ENTSIZE)
+       fprintf (asm_out_file, ",%d", flags & SECTION_ENTSIZE);
+    }
+
+  putc ('\n', asm_out_file);
 }
 #endif
 
index cd5cd09..4070f95 100644 (file)
@@ -485,7 +485,8 @@ extern void no_asm_to_stream PARAMS ((FILE *));
                                           embedded zeros */
 #define SECTION_OVERRIDE 0x20000       /* allow override of default flags */
 #define SECTION_TLS     0x40000        /* contains thread-local storage */
-#define SECTION_MACH_DEP 0x80000       /* subsequent bits reserved for target */
+#define SECTION_NOTYPE  0x80000        /* don't output @progbits */
+#define SECTION_MACH_DEP 0x100000      /* subsequent bits reserved for target */
 
 extern unsigned int get_named_section_flags PARAMS ((const char *));
 extern bool set_named_section_flags    PARAMS ((const char *, unsigned int));
index 2894f89..e2d5f3a 100644 (file)
@@ -4828,6 +4828,17 @@ default_section_type_flags_1 (decl, name, reloc, shlib)
       || strncmp (name, ".gnu.linkonce.tb.", 17) == 0)
     flags |= SECTION_TLS;
 
+  /* These three sections have special ELF types.  They are neither
+     SHT_PROGBITS nor SHT_NOBITS, so when changing sections we don't
+     want to print a section type (@progbits or @nobits).  If someone
+     is silly enough to emit code or TLS variables to one of these
+     sections, then don't handle them specially.  */
+  if (!(flags & (SECTION_CODE | SECTION_BSS | SECTION_TLS))
+      && (strcmp (name, ".init_array") == 0
+         || strcmp (name, ".fini_array") == 0
+         || strcmp (name, ".preinit_array") == 0))
+    flags |= SECTION_NOTYPE;
+
   return flags;
 }
 
@@ -4850,7 +4861,6 @@ default_elf_asm_named_section (name, flags)
      unsigned int flags;
 {
   char flagchars[10], *f = flagchars;
-  const char *type;
 
   if (! named_section_first_declaration (name))
     {
@@ -4874,17 +4884,24 @@ default_elf_asm_named_section (name, flags)
     *f++ = 'T';
   *f = '\0';
 
-  if (flags & SECTION_BSS)
-    type = "nobits";
-  else
-    type = "progbits";
+  fprintf (asm_out_file, "\t.section\t%s,\"%s\"", name, flagchars);
 
-  if (flags & SECTION_ENTSIZE)
-    fprintf (asm_out_file, "\t.section\t%s,\"%s\",@%s,%d\n",
-            name, flagchars, type, flags & SECTION_ENTSIZE);
-  else
-    fprintf (asm_out_file, "\t.section\t%s,\"%s\",@%s\n",
-            name, flagchars, type);
+  if (!(flags & SECTION_NOTYPE))
+    {
+      const char *type;
+
+      if (flags & SECTION_BSS)
+       type = "nobits";
+      else
+       type = "progbits";
+
+      fprintf (asm_out_file, ",@%s", type);
+
+      if (flags & SECTION_ENTSIZE)
+       fprintf (asm_out_file, ",%d", flags & SECTION_ENTSIZE);
+    }
+
+  putc ('\n', asm_out_file);
 }
 
 void