[15/22] ELF: test certain .bss usages

Message ID ed6e76e3-5c19-478f-9a9f-1c52542aa79a@suse.com
State New
Headers
Series ELF: correct handling of simplified section directives |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Testing passed

Commit Message

Jan Beulich Dec. 15, 2023, 12:16 p.m. UTC
  Various targets have / had overrides for .bss. Make sure that in such
cases
- .previous still works correctly (requiring such targets to invoke
  obj_elf_section_change_hook() from their overriding handlers),
- sub-section specifiers are accepted as far as feasible (mandated by
  the doc).
  

Patch

--- /dev/null
+++ b/gas/testsuite/gas/elf/bss-prev.d
@@ -0,0 +1,13 @@ 
+#name: .bss / .previous interaction
+#as: --no-pad-sections
+#readelf: -S --wide
+
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ +\[Nr\] Name +Type +Addr(ess|) +Off +Size .*
+#...
+ *\[ [1-9]\] *\.text +PROGBITS +0*0 +0[0-9a-f]* 0+ .*
+ *\[ [1-9]\] *\.data +PROGBITS +0*0 +0[0-9a-f]* 0*1 .*
+ *\[ [1-9]\] *\.bss +NOBITS +0*0 +0[0-9a-f]* 0*1 .*
+#pass
--- /dev/null
+++ b/gas/testsuite/gas/elf/bss-prev.s
@@ -0,0 +1,6 @@ 
+	.text
+	.data
+	.bss
+	.byte 0
+	.previous
+	.byte 1
--- /dev/null
+++ b/gas/testsuite/gas/elf/bss-subsect.d
@@ -0,0 +1,11 @@ 
+#name: .bss <subsection>
+#as: --no-pad-sections
+#readelf: -S --wide
+
+There are [0-9]+ section headers, starting at offset 0x[0-9a-f]+:
+
+Section Headers:
+ +\[Nr\] Name +Type +Addr(ess|) +Off +Size .*
+#...
+ *\[ [1-9]\] *\.bss +NOBITS +0*0 +0[0-9a-f]* 0*a .*
+#pass
--- /dev/null
+++ b/gas/testsuite/gas/elf/bss-subsect.s
@@ -0,0 +1,10 @@ 
+	.bss
+	.byte 0
+
+	.bss 2
+	.balign 2
+	.skip 2
+
+	.bss 1
+	.balign 4
+	.skip 4
--- a/gas/testsuite/gas/elf/elf.exp
+++ b/gas/testsuite/gas/elf/elf.exp
@@ -336,6 +336,13 @@  if { [is_elf_format] } then {
 
     run_dump_test "pr25917"
     run_dump_test "bss"
+    # Some targets treat .bss similar to .lcomm.
+    if { ![istarget "csky-*-*"]
+	 && ![istarget "mcore-*-*"]
+	 && ![istarget "spu-*-*"] } then {
+	run_dump_test "bss-prev" $dump_opts
+	run_dump_test "bss-subsect" $dump_opts
+    }
     run_dump_test "bad-bss"
     run_dump_test "bad-section-flag"
     run_dump_test "bad-size"