public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Re: [PATCH] gas should honor original section type (was Re: ELF section identification and gld)
@ 2004-12-15 10:15 Jan Beulich
  2004-12-16 12:12 ` Nick Clifton
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2004-12-15 10:15 UTC (permalink / raw)
  To: nickc; +Cc: binutils, ian

[-- Attachment #1: Type: text/plain, Size: 8647 bytes --]

>Unfortunately this patch appears to introduce quite a few new testsuite

>failures in other toolchains.  In particular I found lots of failures
of 
>the new section5 test because it only checks for REL in the output and

>does not include RELA.  (This affected toolchains such as: 
>alpha-linux-gnu and sh-elf).
>
>Other toolchains had even more difficulties.  The patch introduced 51

>new unexpected failures for GAS tests and 47 new unexpected failures
for 
>LD tests for the mmix-mmixware toolchain.  The mips64-linux toolchain

>had 13 and 15 new unexpected failures respectively, and the 
>sparc64-linux-gnu toolchain has 21 and 9 new failures.
>
>Please could you investigate and resolve these issues and then
resubmit 
>your patch ?

This patch attempts to address this. Built and tested on
i686-pc-linux-gnu
and as cross version for mmix-mmixware (and verified that the same
failure
cause applies to the other mentioned architectures). The previous
version
was simply overdoing its job.

One thing I'd like to note before any complaints come up: A side effect
of
the change is that on a sequence like

.section .xyz, "a"
.section .xyz, "a", @progbits

a warning will now be issued on the second directive, even though
implicitly
the missing section type in the first will (at a late stage during
assembly)
be set to SHT_PROGBITS, too. I consider this warning valid, though,
for
consistency reasons (one shouldn't use both implicit and explicit
setting of
the type).

Jan

gas/
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>

	* section5.[els]: New.

---
/home/jbeulich/src/binutils/mainline/2004-12-03.13.35/gas/config/obj-elf.c	2004-11-18
15:05:33.000000000 +0100
+++ 2004-12-03.13.35/gas/config/obj-elf.c	2004-12-14
16:07:27.000000000 +0100
@@ -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
---
/home/jbeulich/src/binutils/mainline/2004-12-03.13.35/gas/testsuite/gas/elf/elf.exp	2004-10-06
09:35:51.000000000 +0200
+++ 2004-12-03.13.35/gas/testsuite/gas/elf/elf.exp	2004-12-14
16:07:27.000000000 +0100
@@ -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 re
 	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\\\]\"" 
 }
---
/home/jbeulich/src/binutils/mainline/2004-12-03.13.35/gas/testsuite/gas/elf/section5.e	1970-01-01
01:00:00.000000000 +0100
+++ 2004-12-03.13.35/gas/testsuite/gas/elf/section5.e	2004-12-06
11:57:54.000000000 +0100
@@ -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:]]+.*
---
/home/jbeulich/src/binutils/mainline/2004-12-03.13.35/gas/testsuite/gas/elf/section5.l	1970-01-01
01:00:00.000000000 +0100
+++ 2004-12-03.13.35/gas/testsuite/gas/elf/section5.l	2004-08-27
18:09:29.000000000 +0200
@@ -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[ 	]*
---
/home/jbeulich/src/binutils/mainline/2004-12-03.13.35/gas/testsuite/gas/elf/section5.s	1970-01-01
01:00:00.000000000 +0100
+++ 2004-12-03.13.35/gas/testsuite/gas/elf/section5.s	2004-08-27
18:06:16.000000000 +0200
@@ -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


[-- Attachment #2: binutils-mainline-elf-section.patch --]
[-- Type: application/octet-stream, Size: 7901 bytes --]

This patch attempts to address this. Built and tested on i686-pc-linux-gnu
and as cross version for mmix-mmixware (and verified that the same failure
cause applies to the other mentioned architectures). The previous version
was simply overdoing its job.

One thing I'd like to note before any complaints come up: A side effect of
the change is that on a sequence like

.section .xyz, "a"
.section .xyz, "a", @progbits

a warning will now be issued on the second directive, even though implicitly
the missing section type in the first will (at a late stage during assembly)
be set to SHT_PROGBITS, too. I consider this warning valid, though, for
consistency reasons (one shouldn't use both implicit and explicit setting of
the type).

Jan

gas/
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>

	* section5.[els]: New.

--- /home/jbeulich/src/binutils/mainline/2004-12-03.13.35/gas/config/obj-elf.c	2004-11-18 15:05:33.000000000 +0100
+++ 2004-12-03.13.35/gas/config/obj-elf.c	2004-12-14 16:07:27.000000000 +0100
@@ -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
--- /home/jbeulich/src/binutils/mainline/2004-12-03.13.35/gas/testsuite/gas/elf/elf.exp	2004-10-06 09:35:51.000000000 +0200
+++ 2004-12-03.13.35/gas/testsuite/gas/elf/elf.exp	2004-12-14 16:07:27.000000000 +0100
@@ -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 re
 	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\\\]\""
 }
--- /home/jbeulich/src/binutils/mainline/2004-12-03.13.35/gas/testsuite/gas/elf/section5.e	1970-01-01 01:00:00.000000000 +0100
+++ 2004-12-03.13.35/gas/testsuite/gas/elf/section5.e	2004-12-06 11:57:54.000000000 +0100
@@ -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:]]+.*
--- /home/jbeulich/src/binutils/mainline/2004-12-03.13.35/gas/testsuite/gas/elf/section5.l	1970-01-01 01:00:00.000000000 +0100
+++ 2004-12-03.13.35/gas/testsuite/gas/elf/section5.l	2004-08-27 18:09:29.000000000 +0200
@@ -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[ 	]*
--- /home/jbeulich/src/binutils/mainline/2004-12-03.13.35/gas/testsuite/gas/elf/section5.s	1970-01-01 01:00:00.000000000 +0100
+++ 2004-12-03.13.35/gas/testsuite/gas/elf/section5.s	2004-08-27 18:06:16.000000000 +0200
@@ -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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] gas should honor original section type (was Re: ELF section identification and gld)
  2004-12-15 10:15 [PATCH] gas should honor original section type (was Re: ELF section identification and gld) Jan Beulich
@ 2004-12-16 12:12 ` Nick Clifton
  0 siblings, 0 replies; 8+ messages in thread
From: Nick Clifton @ 2004-12-16 12:12 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils, ian

Hi Jan,

> gas/
> 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>
> 
> 	* section5.[els]: New.

Approved - please apply.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] gas should honor original section type (was Re:ELF section identification and gld)
  2004-09-10 13:57   ` Alan Modra
@ 2004-09-27 16:33     ` Nick Clifton
  0 siblings, 0 replies; 8+ messages in thread
From: Nick Clifton @ 2004-09-27 16:33 UTC (permalink / raw)
  To: binutils; +Cc: 'Jan Beulich'

Hi Guys,

>>>From: binutils-owner On Behalf Of Jan Beulich
>>>(in the architecture independent parts), is there any mechanism to
>>>build/test all (default) architectures without having to 
>>>manually build them individually?

As has already been said the only real mechanism to test the 
architecture independent parts of the tools is the brute force approach 
- build and check as many different targets as you can and look for 
regressions.


> Alan Modra wrote:
> I use the following script
> 
> for z in a29k-coff alpha-linuxecoff alpha-linux arc-elf arm-aout arm-coff arm-linux avr-elf cris-elf d10v-elf d30v-elf dlx-elf fr30-elf frv-elf hppa-linux hppa64-linux h8300-rtems h8300-elf h8500-rtems i370-linux i586-coff i586-aout i586-linux i686-pe i860-stardent-elf i960-intel-nindy i960-coff i960-elf ia64-linux ip2k-elf m32r-elf m68hc11-elf m68hc12-elf m68k-aout m68k-netbsd m68k-coff m68k-linux m88k-coff mcore-elf mcore-pe mips-ecoff mips-linux mmix mn10200-elf mn10300-elf openrisc-elf or32-coff or32-elf pj-elf powerpc-linux powerpc64-linux rs6000-aix4.3.3 rs6000-aix5.1 s390x-linux s390-linux sh-linux sh-pe sh-rtems sh64-elf ns32k-netbsd sparc-aout sparc-coff sparc-linux sparc64-linux tic30-unknown-aout tic30-unknown-coff tic4x-coff tic54x-coff tic80-coff v850-elf vax-netbsdelf vax-netbsd vax-vms w65-unknown-coff x86_64-linux xstormy16-elf z8k-coff

Interesting script.  I use makefiles myself but to a similar effect. 
There were several targets in your list which I was not testing, so I 
have added them to my framework.  I also noticed that your list does not 
include these targets which you might want to add: crx-elf, iq2000-elf, 
msp430-elf and xtensa-elf.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] gas should honor original section type (was Re:ELF section identification and gld)
  2004-09-10  9:49 ` [PATCH] gas should honor original section type (was " Dave Korn
@ 2004-09-10 13:57   ` Alan Modra
  2004-09-27 16:33     ` Nick Clifton
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Modra @ 2004-09-10 13:57 UTC (permalink / raw)
  To: Dave Korn; +Cc: 'Jan Beulich', binutils

On Fri, Sep 10, 2004 at 10:47:11AM +0100, Dave Korn wrote:
> > From: binutils-owner On Behalf Of Jan Beulich
> > (in the architecture independent parts), is there any mechanism to
> > build/test all (default) architectures without having to 
> > manually build
> > them individually?
> 
>   I believe the correct answer to that question is to add
> "--enable-targets=all" to your configure line.  You still need to specify
> --target=XXX to select which one is the default.

No, all that does is compile all (well, most) of the bfd backends.  Gas
isn't multi-architecture, so you won't be testing much of gas.  I use
the following script

for z in a29k-coff alpha-linuxecoff alpha-linux arc-elf arm-aout arm-coff arm-linux avr-elf cris-elf d10v-elf d30v-elf dlx-elf fr30-elf frv-elf hppa-linux hppa64-linux h8300-rtems h8300-elf h8500-rtems i370-linux i586-coff i586-aout i586-linux i686-pe i860-stardent-elf i960-intel-nindy i960-coff i960-elf ia64-linux ip2k-elf m32r-elf m68hc11-elf m68hc12-elf m68k-aout m68k-netbsd m68k-coff m68k-linux m88k-coff mcore-elf mcore-pe mips-ecoff mips-linux mmix mn10200-elf mn10300-elf openrisc-elf or32-coff or32-elf pj-elf powerpc-linux powerpc64-linux rs6000-aix4.3.3 rs6000-aix5.1 s390x-linux s390-linux sh-linux sh-pe sh-rtems sh64-elf ns32k-netbsd sparc-aout sparc-coff sparc-linux sparc64-linux tic30-unknown-aout tic30-unknown-coff tic4x-coff tic54x-coff tic80-coff v850-elf vax-netbsdelf vax-netbsd vax-vms w65-unknown-coff x86_64-linux xstormy16-elf z8k-coff
do
  echo -n "$z "
  test -d $z || mkdir $z
  cd $z;
  echo "CFLAGS=\"-g -O\" /src/binutils-current/configure --prefix=/usr/local --disable-nls --build=i586-linux --host=i586-linux --target=$z" > ../zzz
  chmod 755 ../zzz
  xx=9
  for x in 8 7 6 5 4 3 2 1 0
  do
    test -f make.log$x && mv -f make.log$x make.log$xx
    test -f check.log$x && mv -f check.log$x check.log$xx
    xx=$x
  done
  if test x$1 = xfull || ! test -f zzz || ! cmp -s zzz ../zzz; then
    mv make.log? check.log? ..
    rm -rf *
    mv -f ../zzz ../make.log? ../check.log? .
    ./zzz >& make.log0
  else
    rm ../zzz
    ./zzz >& make.log0
#    make clean > /dev/null 2>&1
  fi
  if make >> make.log0 2>&1; then
    if make -k check > check.log0 2>&1; then
      echo -n OK
    else
      echo -n check
    fi
  else
    echo -n make
  fi
  echo
  cd ..
done


-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH] gas should honor original section type (was Re:ELF section identification and gld)
  2004-09-10  6:44 Jan Beulich
@ 2004-09-10  9:49 ` Dave Korn
  2004-09-10 13:57   ` Alan Modra
  0 siblings, 1 reply; 8+ messages in thread
From: Dave Korn @ 2004-09-10  9:49 UTC (permalink / raw)
  To: 'Jan Beulich', nickc; +Cc: binutils, ian

> -----Original Message-----
> From: binutils-owner On Behalf Of Jan Beulich
> Sent: 10 September 2004 07:45

> I'll look into these. A general question, though: For changes 
> like this
> (in the architecture independent parts), is there any mechanism to
> build/test all (default) architectures without having to 
> manually build
> them individually?

  I believe the correct answer to that question is to add
"--enable-targets=all" to your configure line.  You still need to specify
--target=XXX to select which one is the default.


    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] gas should honor original section type (was Re: ELF section identification and gld)
@ 2004-09-10  6:44 Jan Beulich
  2004-09-10  9:49 ` [PATCH] gas should honor original section type (was " Dave Korn
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2004-09-10  6:44 UTC (permalink / raw)
  To: nickc; +Cc: binutils, ian

>Unfortunately this patch appears to introduce quite a few new testsuite

>failures in other toolchains.  In particular I found lots of failures
of 
>the new section5 test because it only checks for REL in the output and

>does not include RELA.  (This affected toolchains such as: 
>alpha-linux-gnu and sh-elf).

An obvious oversight.

>Other toolchains had even more difficulties.  The patch introduced 51

>new unexpected failures for GAS tests and 47 new unexpected failures
for 
>LD tests for the mmix-mmixware toolchain.  The mips64-linux toolchain

>had 13 and 15 new unexpected failures respectively, and the 
>sparc64-linux-gnu toolchain has 21 and 9 new failures.
>
>Please could you investigate and resolve these issues and then
resubmit 
>your patch ?

I'll look into these. A general question, though: For changes like this
(in the architecture independent parts), is there any mechanism to
build/test all (default) architectures without having to manually build
them individually?

Thanks, Jan

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] gas should honor original section type (was Re: ELF section identification and gld)
  2004-08-30  6:40 [PATCH] gas should honor original section type (was Re: ELF " Jan Beulich
@ 2004-09-09 11:10 ` Nick Clifton
  0 siblings, 0 replies; 8+ messages in thread
From: Nick Clifton @ 2004-09-09 11:10 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils, ian

Hi Jan,

> This patch attempts to address this. Built and tested on
> i686-pc-linux-gnu.

> bfd/
> 2004-08-27 Jan Beulich <jbeulich@novell.com>
> 
> 	* elf.c (_bfd_elf_new_section_hook): Only set various section
> 	characteristics on new sections.
> 
> gas/config/
> 2004-08-27 Jan Beulich <jbeulich@novell.com>
> 
> 	* confif/obj-elf.c (obj_elf_change_section): Only set type and
> 	attributes on new sections. Emit warning when type on
> re-declared
> 	section doesn't match.
> 
> gas/testsuite/
> 2004-08-27 Jan Beulich <jbeulich@novell.com>
> 
> 	* section5.*: New.

Unfortunately this patch appears to introduce quite a few new testsuite 
failures in other toolchains.  In particular I found lots of failures of 
the new section5 test because it only checks for REL in the output and 
does not include RELA.  (This affected toolchains such as: 
alpha-linux-gnu and sh-elf).

Other toolchains had even more difficulties.  The patch introduced 51 
new unexpected failures for GAS tests and 47 new unexpected failures for 
LD tests for the mmix-mmixware toolchain.  The mips64-linux toolchain 
had 13 and 15 new unexpected failures respectively, and the 
sparc64-linux-gnu toolchain has 21 and 9 new failures.

Please could you investigate and resolve these issues and then resubmit 
your patch ?

Cheers
   Nick


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] gas should honor original section type (was Re: ELF section identification and gld)
@ 2004-08-30  6:40 Jan Beulich
  2004-09-09 11:10 ` Nick Clifton
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Beulich @ 2004-08-30  6:40 UTC (permalink / raw)
  To: binutils; +Cc: ian

[-- Attachment #1: Type: text/plain, Size: 8641 bytes --]

>Clearly gas should not silently replace the section type.  That sounds
>like a bug.

This patch attempts to address this. Built and tested on
i686-pc-linux-gnu.

Jan

bfd/
2004-08-27 Jan Beulich <jbeulich@novell.com>

	* elf.c (_bfd_elf_new_section_hook): Only set various section
	characteristics on new sections.

gas/config/
2004-08-27 Jan Beulich <jbeulich@novell.com>

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

gas/testsuite/
2004-08-27 Jan Beulich <jbeulich@novell.com>

	* section5.*: New.

---
/home/jbeulich/src/binutils/mainline/2004-08-27.13.46/bfd/elf.c	2004-08-19
11:03:15.000000000 +0200
+++ 2004-08-27.13.46-elf-segments/bfd/elf.c	2004-08-27
18:17:12.337508784 +0200
@@ -2224,18 +2224,18 @@ _bfd_elf_new_section_hook (bfd *abfd, as
       if (sdata == NULL)
 	return FALSE;
       sec->used_by_bfd = sdata;
-    }
 
-  elf_section_type (sec) = SHT_NULL;
-  ssect = _bfd_elf_get_sec_type_attr (abfd, sec->name);
-  if (ssect != NULL)
-    {
-      elf_section_type (sec) = ssect->type;
-      elf_section_flags (sec) = ssect->attr;
-    }
+      elf_section_type (sec) = SHT_NULL;
+      ssect = _bfd_elf_get_sec_type_attr (abfd, sec->name);
+      if (ssect != NULL)
+	{
+	  elf_section_type (sec) = ssect->type;
+	  elf_section_flags (sec) = ssect->attr;
+	}
 
-  /* Indicate whether or not this section should use RELA relocations.
 */
-  sec->use_rela_p = get_elf_backend_data (abfd)->default_use_rela_p;
+      /* Indicate whether or not this section should use RELA
relocations.  */
+      sec->use_rela_p = get_elf_backend_data
(abfd)->default_use_rela_p;
+    }
 
   return TRUE;
 }
---
/home/jbeulich/src/binutils/mainline/2004-08-27.13.46/gas/config/obj-elf.c	2004-06-16
15:22:54.000000000 +0200
+++ 2004-08-27.13.46-elf-segments/gas/config/obj-elf.c	2004-08-27
18:26:53.325185232 +0200
@@ -616,11 +616,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)
@@ -641,6 +636,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;
@@ -657,19 +655,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
---
/home/jbeulich/src/binutils/mainline/2004-08-27.13.46/gas/testsuite/gas/elf/elf.exp	2004-08-02
10:52:10.000000000 +0200
+++
2004-08-27.13.46-elf-segments/gas/testsuite/gas/elf/elf.exp	2004-08-27
18:20:31.896171256 +0200
@@ -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 re
 	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
@@ -56,9 +56,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" "-S" "| grep
\"\\\\.test\\\[\\\[:digit:\\\]\\\]\""
     run_dump_test "symver" 
-    run_list_test "type" "" "" "| grep \"1 \\\[FONT\\\]\"" 
+    run_list_test "type" "" "" "-s" "| grep \"1 \\\[FONT\\\]\"" 
 }
---
/home/jbeulich/src/binutils/mainline/2004-08-27.13.46/gas/testsuite/gas/elf/section5.e	1970-01-01
01:00:00.000000000 +0100
+++
2004-08-27.13.46-elf-segments/gas/testsuite/gas/elf/section5.e	2004-08-27
17:25:29.000000000 +0200
@@ -0,0 +1,8 @@
+.* \.test0[ 	]+PROGBITS[ 	]+([[:xdigit:]]+[ 	]+){4}[
	]+[[:digit:]]+.*
+.* \.test1[ 	]+PROGBITS[ 	]+([[:xdigit:]]+[ 	]+){4}[
	]+[[:digit:]]+.*
+.* \.rel\.test1[ 	]+REL[ 	]+.*
+.* \.test2[ 	]+PROGBITS[ 	]+([[:xdigit:]]+[ 	]+){4}[
	]+[[:digit:]]+.*
+.* \.rel\.test2[ 	]+REL[ 	]+.*
+.* \.test3[ 	]+PROGBITS[ 	]+([[:xdigit:]]+[ 	]+){4}WA[
	]+[[:digit:]]+.*
+.* \.rel\.test3[ 	]+REL[ 	]+.*
+.* \.test4[ 	]+NOBITS[ 	]+([[:xdigit:]]+[ 	]+){4}WA[
	]+[[:digit:]]+.*
---
/home/jbeulich/src/binutils/mainline/2004-08-27.13.46/gas/testsuite/gas/elf/section5.l	1970-01-01
01:00:00.000000000 +0100
+++
2004-08-27.13.46-elf-segments/gas/testsuite/gas/elf/section5.l	2004-08-27
18:09:29.000000000 +0200
@@ -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[ 	]*
---
/home/jbeulich/src/binutils/mainline/2004-08-27.13.46/gas/testsuite/gas/elf/section5.s	1970-01-01
01:00:00.000000000 +0100
+++
2004-08-27.13.46-elf-segments/gas/testsuite/gas/elf/section5.s	2004-08-27
18:06:16.000000000 +0200
@@ -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


[-- Attachment #2: binutils-mainline-elf-section.patch --]
[-- Type: application/octet-stream, Size: 8638 bytes --]

>Clearly gas should not silently replace the section type.  That sounds
>like a bug.

This patch attempts to address this. Built and tested on i686-pc-linux-gnu.

Jan

bfd/
2004-08-27 Jan Beulich <jbeulich@novell.com>

	* elf.c (_bfd_elf_new_section_hook): Only set various section
	characteristics on new sections.

gas/config/
2004-08-27 Jan Beulich <jbeulich@novell.com>

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

gas/testsuite/
2004-08-27 Jan Beulich <jbeulich@novell.com>

	* section5.*: New.

--- /home/jbeulich/src/binutils/mainline/2004-08-27.13.46/bfd/elf.c	2004-08-19 11:03:15.000000000 +0200
+++ 2004-08-27.13.46-elf-segments/bfd/elf.c	2004-08-27 18:17:12.337508784 +0200
@@ -2224,18 +2224,18 @@ _bfd_elf_new_section_hook (bfd *abfd, as
       if (sdata == NULL)
 	return FALSE;
       sec->used_by_bfd = sdata;
-    }
 
-  elf_section_type (sec) = SHT_NULL;
-  ssect = _bfd_elf_get_sec_type_attr (abfd, sec->name);
-  if (ssect != NULL)
-    {
-      elf_section_type (sec) = ssect->type;
-      elf_section_flags (sec) = ssect->attr;
-    }
+      elf_section_type (sec) = SHT_NULL;
+      ssect = _bfd_elf_get_sec_type_attr (abfd, sec->name);
+      if (ssect != NULL)
+	{
+	  elf_section_type (sec) = ssect->type;
+	  elf_section_flags (sec) = ssect->attr;
+	}
 
-  /* Indicate whether or not this section should use RELA relocations.  */
-  sec->use_rela_p = get_elf_backend_data (abfd)->default_use_rela_p;
+      /* Indicate whether or not this section should use RELA relocations.  */
+      sec->use_rela_p = get_elf_backend_data (abfd)->default_use_rela_p;
+    }
 
   return TRUE;
 }
--- /home/jbeulich/src/binutils/mainline/2004-08-27.13.46/gas/config/obj-elf.c	2004-06-16 15:22:54.000000000 +0200
+++ 2004-08-27.13.46-elf-segments/gas/config/obj-elf.c	2004-08-27 18:26:53.325185232 +0200
@@ -616,11 +616,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)
@@ -641,6 +636,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;
@@ -657,19 +655,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
--- /home/jbeulich/src/binutils/mainline/2004-08-27.13.46/gas/testsuite/gas/elf/elf.exp	2004-08-02 10:52:10.000000000 +0200
+++ 2004-08-27.13.46-elf-segments/gas/testsuite/gas/elf/elf.exp	2004-08-27 18:20:31.896171256 +0200
@@ -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 re
 	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
@@ -56,9 +56,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" "-S" "| grep \"\\\\.test\\\[\\\[:digit:\\\]\\\]\""
     run_dump_test "symver" 
-    run_list_test "type" "" "" "| grep \"1 \\\[FONT\\\]\""
+    run_list_test "type" "" "" "-s" "| grep \"1 \\\[FONT\\\]\""
 }
--- /home/jbeulich/src/binutils/mainline/2004-08-27.13.46/gas/testsuite/gas/elf/section5.e	1970-01-01 01:00:00.000000000 +0100
+++ 2004-08-27.13.46-elf-segments/gas/testsuite/gas/elf/section5.e	2004-08-27 17:25:29.000000000 +0200
@@ -0,0 +1,8 @@
+.* \.test0[ 	]+PROGBITS[ 	]+([[:xdigit:]]+[ 	]+){4}[ 	]+[[:digit:]]+.*
+.* \.test1[ 	]+PROGBITS[ 	]+([[:xdigit:]]+[ 	]+){4}[ 	]+[[:digit:]]+.*
+.* \.rel\.test1[ 	]+REL[ 	]+.*
+.* \.test2[ 	]+PROGBITS[ 	]+([[:xdigit:]]+[ 	]+){4}[ 	]+[[:digit:]]+.*
+.* \.rel\.test2[ 	]+REL[ 	]+.*
+.* \.test3[ 	]+PROGBITS[ 	]+([[:xdigit:]]+[ 	]+){4}WA[ 	]+[[:digit:]]+.*
+.* \.rel\.test3[ 	]+REL[ 	]+.*
+.* \.test4[ 	]+NOBITS[ 	]+([[:xdigit:]]+[ 	]+){4}WA[ 	]+[[:digit:]]+.*
--- /home/jbeulich/src/binutils/mainline/2004-08-27.13.46/gas/testsuite/gas/elf/section5.l	1970-01-01 01:00:00.000000000 +0100
+++ 2004-08-27.13.46-elf-segments/gas/testsuite/gas/elf/section5.l	2004-08-27 18:09:29.000000000 +0200
@@ -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[ 	]*
--- /home/jbeulich/src/binutils/mainline/2004-08-27.13.46/gas/testsuite/gas/elf/section5.s	1970-01-01 01:00:00.000000000 +0100
+++ 2004-08-27.13.46-elf-segments/gas/testsuite/gas/elf/section5.s	2004-08-27 18:06:16.000000000 +0200
@@ -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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-12-16 12:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-15 10:15 [PATCH] gas should honor original section type (was Re: ELF section identification and gld) Jan Beulich
2004-12-16 12:12 ` Nick Clifton
  -- strict thread matches above, loose matches on Subject: below --
2004-09-10  6:44 Jan Beulich
2004-09-10  9:49 ` [PATCH] gas should honor original section type (was " Dave Korn
2004-09-10 13:57   ` Alan Modra
2004-09-27 16:33     ` Nick Clifton
2004-08-30  6:40 [PATCH] gas should honor original section type (was Re: ELF " Jan Beulich
2004-09-09 11:10 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).