gas: error for section type, attr, or entsize change
authorAlan Modra <amodra@gmail.com>
Thu, 6 Feb 2020 14:12:45 +0000 (00:42 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 10 Feb 2020 04:58:23 +0000 (15:28 +1030)
* config/obj-elf.c (obj_elf_change_section): Error for section
type, attr or entsize changes in assembly.
* testsuite/gas/elf/elf.exp: Pass -Z to gas for section5 test.
* testsuite/gas/elf/section5.l: Update.

gas/ChangeLog
gas/config/obj-elf.c
gas/testsuite/gas/elf/elf.exp
gas/testsuite/gas/elf/section5.l

index 4c60d86a66ead9275bc5b82efd88770a5ade93bf..a07d9b7f35e064a0dfc4fbb3a87ce632a6291e4e 100644 (file)
@@ -1,3 +1,10 @@
+2020-02-10  Alan Modra  <amodra@gmail.com>
+
+       * config/obj-elf.c (obj_elf_change_section): Error for section
+       type, attr or entsize changes in assembly.
+       * testsuite/gas/elf/elf.exp: Pass -Z to gas for section5 test.
+       * testsuite/gas/elf/section5.l: Update.
+
 2020-02-10  Alan Modra  <amodra@gmail.com>
 
        * output-file.c (output_file_close): Do a normal close when
index d7a07fec6bfe8606d0dc2fe1cbd6d4b37f85703a..a7225983f6a2c3c2f2ea0ff7368c69c582678db5 100644 (file)
@@ -767,7 +767,17 @@ obj_elf_change_section (const char *name,
     {
       if (type != SHT_NULL
          && (unsigned) type != elf_section_type (old_sec))
-       as_warn (_("ignoring changed section type for %s"), name);
+       {
+         if (ssect != NULL)
+           /* This is a special section with known type.  User
+              assembly might get the section type wrong; Even high
+              profile projects like glibc have done so in the past.
+              So don't error in this case.  */
+           as_warn (_("ignoring changed section type for %s"), name);
+         else
+           /* Do error when assembly isn't self-consistent.  */
+           as_bad (_("changed section type for %s"), name);
+       }
 
       if (attr != 0)
        {
@@ -779,14 +789,19 @@ obj_elf_change_section (const char *name,
                  | SEC_EXCLUDE | SEC_SORT_ENTRIES | SEC_MERGE | SEC_STRINGS
                  | SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD
                  | SEC_THREAD_LOCAL)))
-           as_warn (_("ignoring changed section attributes for %s"), name);
+           {
+             if (ssect != NULL)
+               as_warn (_("ignoring changed section attributes for %s"), name);
+             else
+               as_bad (_("changed section attributes for %s"), name);
+           }
          else
            /* FIXME: Maybe we should consider removing a previously set
               processor or application specific attribute as suspicious ?  */
            elf_section_flags (sec) = attr;
 
          if ((flags & SEC_MERGE) && old_sec->entsize != (unsigned) entsize)
-           as_warn (_("ignoring changed section entity size for %s"), name);
+           as_bad (_("changed section entity size for %s"), name);
        }
     }
 
index 0f9b2672c4cda1d4ce01f8b7888aa835867dfb9b..b0522af3bb1482df9b29cf51a6df6ddae79d5374 100644 (file)
@@ -202,7 +202,7 @@ if { [is_elf_format] } then {
        # new sections created without atrributes.
        # The RX port does not complain about changing the attributes of the
        # .data and .bss sections since it does not use those names.
-       run_elf_list_test "section5" "" "-al" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
+       run_elf_list_test "section5" "" "-al -Z" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
     }
     run_dump_test "struct"
     if { ![istarget "alpha*-*-*"] } then {
index 31b87e603511446e2a0f9b8a1c24f3ea4809e827..00a14560684e683d06b125797019c35bab5028a2 100644 (file)
@@ -1,12 +1,13 @@
 .*: Assembler messages:
-.*:7: Warning: .*
-.*:7: Warning: .*
-.*:10: Warning: .*
-.*:16: Warning: .*
+.*:7: Error: .*
+.*:7: Error: .*
+.*:10: Error: .*
+.*:16: Error: .*
 .*:18: Warning: .*
 .*:20: Warning: .*
 .*:22: Warning: .*
 .*:24: Warning: .*
+4 errors, 4 warnings, generating bad object file
 .*GAS.*
 
 
This page took 0.028101 seconds and 4 git commands to generate.