Fix type of .persistent.bss section

Message ID 3124084.44csPzL39Z@fomalhaut
State New
Headers show
Series
  • Fix type of .persistent.bss section
Related show

Commit Message

Eric Botcazou April 23, 2021, 11:58 a.m.
Hi,

the change implementing the .persistent family of sections last year broke the 
existing support for the .persistent.bss section in the compiler:

int a __attribute__ ((section (".persistent.bss")));

t.s: Assembler messages:
t.s:4: Warning: setting incorrect section type for .persistent.bss

since the compiler encodes it as @nobits but the assembler expects @progbits.
The assembler is incorrect and should treat the section like the compiler.

Tested on x86-64/Linux, OK for mainline and 2.36 branch?


2021-04-23  Eric Botcazou  <ebotcazou@adacore.com>

bfd/
	* elf.c (special_sections_p): Add .persistent.bss.

gas/
	* testsuite/gas/elf/section25.d: Run it everywhere.
	* testsuite/gas/elf/section26.d: Likewise.
	* testsuite/gas/elf/section26.s: Add test for .persistent.bss.

-- 
Eric Botcazou

Comments

H.J. Lu via Binutils April 23, 2021, 3:31 p.m. | #1
Hi Eric,

> bfd/

> 	* elf.c (special_sections_p): Add .persistent.bss.

> 

> gas/

> 	* testsuite/gas/elf/section25.d: Run it everywhere.

> 	* testsuite/gas/elf/section26.d: Likewise.

> 	* testsuite/gas/elf/section26.s: Add test for .persistent.bss.


Approved - please apply - but with one caveat:

The tests fail for the H8300 architecture because the h8300 assembler 
requires sections to have attributes explicitly specified.  Therefore 
please could you add:

   # The h8300 port issues a warning message for
   # new sections created without attributes.
   #xfail: h8300-*

To section25.d and section26.d  (See section0.d for an already existing 
example of this).

Cheers
   Nick
Eric Botcazou April 23, 2021, 5:28 p.m. | #2
> The tests fail for the H8300 architecture because the h8300 assembler

> requires sections to have attributes explicitly specified.  Therefore

> please could you add:

> 

>    # The h8300 port issues a warning message for

>    # new sections created without attributes.

>    #xfail: h8300-*

> 

> To section25.d and section26.d  (See section0.d for an already existing

> example of this).


Thanks for catching this, modified as requested and applied.

-- 
Eric Botcazou

Patch

diff --git a/bfd/elf.c b/bfd/elf.c
index 11ae2f3a81b..4846b7bd47f 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2725,6 +2725,7 @@  static const struct bfd_elf_special_section special_sections_n[] =
 
 static const struct bfd_elf_special_section special_sections_p[] =
 {
+  { STRING_COMMA_LEN (".persistent.bss"), 0, SHT_NOBITS,	SHF_ALLOC + SHF_WRITE },
   { STRING_COMMA_LEN (".persistent"),	 -2, SHT_PROGBITS,	SHF_ALLOC + SHF_WRITE },
   { STRING_COMMA_LEN (".preinit_array"), -2, SHT_PREINIT_ARRAY, SHF_ALLOC + SHF_WRITE },
   { STRING_COMMA_LEN (".plt"),		  0, SHT_PROGBITS,	SHF_ALLOC + SHF_EXECINSTR },
diff --git a/gas/testsuite/gas/elf/section25.d b/gas/testsuite/gas/elf/section25.d
index 09353849e5b..5869b2c46eb 100644
--- a/gas/testsuite/gas/elf/section25.d
+++ b/gas/testsuite/gas/elf/section25.d
@@ -1,5 +1,4 @@ 
 #name: sections 25 (.noinit)
-#target: [supports_noinit_section]
 #source: section25.s
 #readelf: -S --wide
 
diff --git a/gas/testsuite/gas/elf/section26.d b/gas/testsuite/gas/elf/section26.d
index 15d85bdca9d..aeff28dc397 100644
--- a/gas/testsuite/gas/elf/section26.d
+++ b/gas/testsuite/gas/elf/section26.d
@@ -1,5 +1,4 @@ 
 #name: sections 26 (.persistent)
-#target: [supports_persistent_section]
 #source: section26.s
 #readelf: -S --wide
 
@@ -7,6 +6,8 @@ 
   \[..\] .persistent[ 	]+PROGBITS[ 	]+[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00  WA .*
 #...
   \[..\] .persistent.foo[ 	]+PROGBITS[ 	]+[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00  WA .*
+#...
+  \[..\] .persistent.bss[ 	]+NOBITS[ 	]+[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00  WA .*
 #...
   \[..\] .gnu.linkonce.p.bar[ 	]+PROGBITS[ 	]+[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00  WA .*
 #pass
diff --git a/gas/testsuite/gas/elf/section26.s b/gas/testsuite/gas/elf/section26.s
index 7f986454229..aefe15d4c2c 100644
--- a/gas/testsuite/gas/elf/section26.s
+++ b/gas/testsuite/gas/elf/section26.s
@@ -4,5 +4,8 @@ 
 .section .persistent.foo
 .word 0
 
+.section .persistent.bss
+.word 0
+
 .section .gnu.linkonce.p.bar
 .word 0