Check for changed section attributes.
authorAlan Modra <amodra@gmail.com>
Thu, 20 Apr 2000 01:43:32 +0000 (01:43 +0000)
committerAlan Modra <amodra@gmail.com>
Thu, 20 Apr 2000 01:43:32 +0000 (01:43 +0000)
gas/ChangeLog
gas/config/obj-elf.c

index 3b49ba7c2d0e747a5d3c2f056a65492be170362c..32c5f4730bafa7bc43190e72ddfc2e46286ea53b 100644 (file)
@@ -1,5 +1,8 @@
 2000-04-19  Alan Modra  <alan@linuxcare.com.au>
 
+       * config/obj-elf.c (obj_elf_change_section): Check for changed
+       section attributes.
+
        * Makefile.am: (CPU_MULTI_VALID): Remove.
        (MULTI_CPU_TYPES): Define.
        (MULTI_CPU_OBJ_VALID): Define.
@@ -11,7 +14,7 @@
 
 2000-04-19  Michael Sokolov  <msokolov@ivan.Harhan.ORG>
 
-       * Makefile.am (FLEX, LEX): Get them from configure.
+       * Makefile.am (YACC, LEX): Get them from configure.
 
 2000-04-18  H.J. Lu  (hjl@gnu.org)
 
index 21fd0fa22411c5d5676eaec1db264a992f0feb1c..ae82f72003b164450134b051d7402533e31ca873 100644 (file)
@@ -617,8 +617,10 @@ obj_elf_change_section (name, type, attr, push)
      char *name;
      int type, attr, push;
 {
-  int new_sec;
+  asection *old_sec;
   segT sec;
+  flagword flags;
+  int i;
 
 #ifdef md_flush_pending_output
   md_flush_pending_output ();
@@ -639,49 +641,57 @@ obj_elf_change_section (name, type, attr, push)
   previous_section = now_seg;
   previous_subsection = now_subseg;
 
-  new_sec = bfd_get_section_by_name (stdoutput, name) == NULL;
+  old_sec = bfd_get_section_by_name (stdoutput, name);
   sec = subseg_new (name, 0);
 
-  if (new_sec)
-    {
-      flagword flags;
-      symbolS *secsym;
-      int i;
-
-      /* See if this is one of the special sections.  */
-      for (i = 0; special_sections[i].name != NULL; i++)
-        if (strcmp (name, special_sections[i].name) == 0)
-          {
-           if (type == SHT_NULL)
-             type = special_sections[i].type;
-           else if (type != special_sections[i].type)
-             as_warn (_("Setting incorrect section type for %s"), name);
-
-           if ((attr &~ special_sections[i].attributes) != 0)
+  /* See if this is one of the special sections.  */
+  for (i = 0; special_sections[i].name != NULL; i++)
+    if (strcmp (name, special_sections[i].name) == 0)
+      {
+       if (type == SHT_NULL)
+         type = special_sections[i].type;
+       else if (type != special_sections[i].type)
+         {
+           if (old_sec == NULL)
              {
-               /* As a GNU extension, we permit a .note section to be
-                  allocatable.  If the linker sees an allocateable .note
-                  section, it will create a PT_NOTE segment in the output
-                  file.  */
-               if (strcmp (name, ".note") != 0
-                   || attr != SHF_ALLOC)
-                 as_warn (_("Setting incorrect section attributes for %s"),
-                          name);
+               as_warn (_("Setting incorrect section type for %s"), name);
+             }
+           else
+             {
+               as_warn (_("Ignoring incorrect section type for %s"), name);
+               type = special_sections[i].type;
              }
-           attr |= special_sections[i].attributes;
-           break;
          }
-
-      /* Convert ELF type and flags to BFD flags.  */
-      flags = (SEC_RELOC
-              | ((attr & SHF_WRITE) ? 0 : SEC_READONLY)
-              | ((attr & SHF_ALLOC) ? SEC_ALLOC : 0)
-              | (((attr & SHF_ALLOC) && type != SHT_NOBITS) ? SEC_LOAD : 0)
-              | ((attr & SHF_EXECINSTR) ? SEC_CODE : 0));
+       if ((attr &~ special_sections[i].attributes) != 0
+           && old_sec == NULL)
+         {
+           /* As a GNU extension, we permit a .note section to be
+              allocatable.  If the linker sees an allocateable .note
+              section, it will create a PT_NOTE segment in the output
+              file.  */
+           if (strcmp (name, ".note") != 0
+               || attr != SHF_ALLOC)
+             as_warn (_("Setting incorrect section attributes for %s"),
+                      name);
+         }
+       attr |= special_sections[i].attributes;
+       break;
+      }
+
+  /* Convert ELF type and flags to BFD flags.  */
+  flags = (SEC_RELOC
+          | ((attr & SHF_WRITE) ? 0 : SEC_READONLY)
+          | ((attr & SHF_ALLOC) ? SEC_ALLOC : 0)
+          | (((attr & SHF_ALLOC) && type != SHT_NOBITS) ? SEC_LOAD : 0)
+          | ((attr & SHF_EXECINSTR) ? SEC_CODE : 0));
 #ifdef md_elf_section_flags
-      flags = md_elf_section_flags (flags, attr, type);
+  flags = md_elf_section_flags (flags, attr, type);
 #endif
 
+  if (old_sec == NULL)
+    {
+      symbolS *secsym;
+
       /* Prevent SEC_HAS_CONTENTS from being inadvertently set.  */
       if (type == SHT_NOBITS)
         seg_info (sec)->bss = 1;
@@ -695,9 +705,19 @@ obj_elf_change_section (name, type, attr, push)
       else
         symbol_table_insert (section_symbol (sec));
     }
+  else if (attr != 0)
+    {
+      /* If section attributes are specified the second time we see a
+        particular section, then check that they are the same as we
+        saw the first time.  */
+      if ((old_sec->flags ^ flags)
+         & (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE
+            | SEC_EXCLUDE | SEC_SORT_ENTRIES))
+       as_warn (_("Ignoring changed section attributes for %s"), name);
+    }
 
 #ifdef md_elf_section_change_hook
-      md_elf_section_change_hook ();
+  md_elf_section_change_hook ();
 #endif
 }
 
This page took 0.031778 seconds and 4 git commands to generate.