gas/
authorJan Beulich <jbeulich@novell.com>
Thu, 16 Dec 2004 13:23:22 +0000 (13:23 +0000)
committerJan Beulich <jbeulich@novell.com>
Thu, 16 Dec 2004 13:23:22 +0000 (13:23 +0000)
2004-12-15 Jan Beulich  <jbeulich@novell.com>

* config/obj-elf.c (obj_elf_change_section): Only set type and
attributes on new sections. Emit warning when type of re-declared
section doesn't match.

gas/testsuite/
2004-12-15 Jan Beulich  <jbeulich@novell.com>

* gas/elf/section5.[els]: New.

gas/ChangeLog
gas/config/obj-elf.c
gas/testsuite/ChangeLog
gas/testsuite/gas/elf/elf.exp
gas/testsuite/gas/elf/section5.e [new file with mode: 0644]
gas/testsuite/gas/elf/section5.l [new file with mode: 0644]
gas/testsuite/gas/elf/section5.s [new file with mode: 0644]

index fe30f9d92777b61dd59e1a9d477b821e11592389..3aed9699cc2c46a10c95940796a06bd0aa84881e 100644 (file)
@@ -1,3 +1,9 @@
+2004-12-15 Jan Beulich  <jbeulich@novell.com>
+
+       * config/obj-elf.c (obj_elf_change_section): Only set type and
+       attributes on new sections. Emit warning when type of re-declared
+       section doesn't match.
+
 2004-12-15 Jan Beulich  <jbeulich@novell.com>
 
        * dw2gencfi.c (dot.cfi.startproc): Clear cur_cfa_offset so
index b4c3a5a7f3af76eea5569a512faf4aec173cc4af..155eaffd2a8ec9fd4fbc0bfc3d832b42bba26d84 100644 (file)
@@ -622,11 +622,6 @@ obj_elf_change_section (const char *name,
        attr |= ssect->attr;
     }
 
-  if (type != SHT_NULL)
-    elf_section_type (sec) = type;
-  if (attr != 0)
-    elf_section_flags (sec) = attr;
-
   /* Convert ELF type and flags to BFD flags.  */
   flags = (SEC_RELOC
           | ((attr & SHF_WRITE) ? 0 : SEC_READONLY)
@@ -647,6 +642,9 @@ obj_elf_change_section (const char *name,
     {
       symbolS *secsym;
 
+      elf_section_type (sec) = type;
+      elf_section_flags (sec) = attr;
+
       /* Prevent SEC_HAS_CONTENTS from being inadvertently set.  */
       if (type == SHT_NOBITS)
        seg_info (sec)->bss = 1;
@@ -663,19 +661,26 @@ obj_elf_change_section (const char *name,
       else
        symbol_table_insert (section_symbol (sec));
     }
-  else if (attr != 0)
+  else
     {
-      /* 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 | SEC_MERGE | SEC_STRINGS
-             | SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD
-             | SEC_THREAD_LOCAL)))
-       as_warn (_("ignoring changed section attributes for %s"), name);
-      if ((flags & SEC_MERGE) && old_sec->entsize != (unsigned) entsize)
-       as_warn (_("ignoring changed section entity size for %s"), name);
+      if (type != SHT_NULL
+         && (unsigned) type != elf_section_type (old_sec))
+       as_warn (_("ignoring changed section type for %s"), name);
+
+      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 | SEC_MERGE | SEC_STRINGS
+                 | SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD
+                 | SEC_THREAD_LOCAL)))
+           as_warn (_("ignoring changed section attributes for %s"), name);
+         if ((flags & SEC_MERGE) && old_sec->entsize != (unsigned) entsize)
+           as_warn (_("ignoring changed section entity size for %s"), name);
+       }
     }
 
 #ifdef md_elf_section_change_hook
index eee9203ef3706ade9d7d643d6f46a50be5f462d3..56c056ec827569b341c6aab7921a1ffa61ad07c7 100644 (file)
@@ -1,3 +1,7 @@
+2004-12-15 Jan Beulich  <jbeulich@novell.com>
+
+       * gas/elf/section5.[els]: New.
+
 2004-12-13  Richard Sandiford  <rsandifo@redhat.com>
 
        * gas/mips/elf-rel25.d, gas/mips/elf-rel25a.d: Cope with different
index 376c204c0c03800cccfdd12af13fa771d98484b3..17acefdefae1a2139726acccd5da2e5881a90927 100644 (file)
@@ -2,7 +2,7 @@
 # elf tests
 #
 
-proc run_list_test { name suffix opts readelf_pipe } {
+proc run_list_test { name suffix opts readelf_opts readelf_pipe } {
     global READELF
     global srcdir subdir
     set testname "elf $name list"
@@ -14,8 +14,8 @@ proc run_list_test { name suffix opts readelf_pipe } {
        verbose "output is [file_contents "dump.out"]" 2
        return
     }
-    send_log "$READELF -s dump.o > dump.out\n"
-    catch "exec $READELF -s dump.o $readelf_pipe > dump.out\n" comp_output
+    send_log "$READELF $readelf_opts dump.o $readelf_pipe > dump.out\n"
+    catch "exec $READELF $readelf_opts dump.o $readelf_pipe > dump.out\n" comp_output
     if ![string match "" $comp_output] then {
        send_log "$comp_output\n"
        fail $testname
@@ -57,9 +57,10 @@ if { ([istarget "*-*-*elf*"]
     run_dump_test "group1b" 
     run_dump_test "section0" 
     run_dump_test "section1" 
-    run_list_test "section2" "$target_machine" "-al" ""
-    run_dump_test "section3"
+    run_list_test "section2" "$target_machine" "-al" "-s" ""
+    run_dump_test "section3" 
     run_dump_test "section4"
+    run_list_test "section5" "" "-al" "-SW" "| grep \"\\\\.test\\\[\\\[:digit:\\\]\\\]\""
     run_dump_test "symver" 
-    run_list_test "type" "" "" "| grep \"1 \\\[FONT\\\]\""
+    run_list_test "type" "" "" "-s" "| grep \"1 \\\[FONT\\\]\""
 }
diff --git a/gas/testsuite/gas/elf/section5.e b/gas/testsuite/gas/elf/section5.e
new file mode 100644 (file)
index 0000000..f1c4f7a
--- /dev/null
@@ -0,0 +1,8 @@
+.* \.test0[    ]+PROGBITS[     ]+([[:xdigit:]]+[       ]+){4}[         ]+[[:digit:]]+.*
+.* \.test1[    ]+PROGBITS[     ]+([[:xdigit:]]+[       ]+){4}[         ]+[[:digit:]]+.*
+.* \.rela?\.test1[     ]+RELA?[        ]+.*
+.* \.test2[    ]+PROGBITS[     ]+([[:xdigit:]]+[       ]+){4}[         ]+[[:digit:]]+.*
+.* \.rela?\.test2[     ]+RELA?[        ]+.*
+.* \.test3[    ]+PROGBITS[     ]+([[:xdigit:]]+[       ]+){4}WA[       ]+[[:digit:]]+.*
+.* \.rela?\.test3[     ]+RELA?[        ]+.*
+.* \.test4[    ]+NOBITS[       ]+([[:xdigit:]]+[       ]+){4}WA[       ]+[[:digit:]]+.*
diff --git a/gas/testsuite/gas/elf/section5.l b/gas/testsuite/gas/elf/section5.l
new file mode 100644 (file)
index 0000000..76e9e4f
--- /dev/null
@@ -0,0 +1,37 @@
+.*: Assembler messages:
+.*:7: Warning: .*
+.*:7: Warning: .*
+.*:10: Warning: .*
+.*:13: Warning: .*
+.*:16: Warning: .*
+.*:18: Warning: .*
+.*:20: Warning: .*
+.*:22: Warning: .*
+.*:24: Warning: .*
+.*GAS.*
+
+
+[      ]+[[:digit:]]+[         ]+.section[     ]+.test0[       ]*
+[      ]+[[:digit:]]+[         ]+.section[     ]+.test1,[      ]*"",[  ]*@progbits[    ]*
+[      ]+[[:digit:]]+[         ]+.section[     ]+.test2[       ]*
+[      ]+[[:digit:]]+[         ]+.section[     ]+.test3,[      ]*"aw"[         ]*
+[      ]+[[:digit:]]+[         ]+.section[     ]+.test4,[      ]*"aw",[        ]*@nobits[      ]*
+[      ]+[[:digit:]]+[         ]*
+[      ]+[[:digit:]]+[         ]+.section[     ]+.test1,[      ]*"aw",[        ]*@nobits[      ]*
+[      ]+[[:digit:]]+[         ]+.*
+[      ]+[[:digit:]]+[         ]*
+[      ]+[[:digit:]]+[         ]+.section[     ]+.test2,[      ]*"w"[  ]*
+[      ]+[[:digit:]]+[         ]+.*
+[      ]+[[:digit:]]+[         ]*
+[      ]+[[:digit:]]+[         ]+.section[     ]+.test3,[      ]*"aw",[        ]*@progbits[    ]*
+[      ]+[[:digit:]]+[         ]+.*
+[      ]+[[:digit:]]+[         ]*
+[      ]+[[:digit:]]+[         ]+.section[     ]+.test4,[      ]*"aw"[         ]*
+[      ]+[[:digit:]]+[         ]*
+[      ]+[[:digit:]]+[         ]+.section[     ]+.data,[       ]*"a"[  ]*
+[      ]+[[:digit:]]+[         ]*
+[      ]+[[:digit:]]+[         ]+.section[     ]+.bss,[        ]*"a"[  ]*
+[      ]+[[:digit:]]+[         ]*
+[      ]+[[:digit:]]+[         ]+.section[     ]+.data,[       ]*"aw",[        ]*@nobits[      ]*
+[      ]+[[:digit:]]+[         ]*
+[      ]+[[:digit:]]+[         ]+.section[     ]+.bss,[        ]*"aw",[        ]*@progbits[    ]*
diff --git a/gas/testsuite/gas/elf/section5.s b/gas/testsuite/gas/elf/section5.s
new file mode 100644 (file)
index 0000000..866af52
--- /dev/null
@@ -0,0 +1,24 @@
+.section       .test0
+.section       .test1, "", @progbits
+.section       .test2
+.section       .test3, "aw"
+.section       .test4, "aw", @nobits
+
+.section       .test1, "aw", @nobits
+test1: .long   test1
+
+.section       .test2, "w"
+test2: .long   test2
+
+.section       .test3, "aw", @progbits
+test3: .long   test3
+
+.section       .test4, "aw"
+
+.section       .data, "a"
+
+.section       .bss, "a"
+
+.section       .data, "aw", @nobits
+
+.section       .bss, "aw", @progbits