[PATCH] ld: testsuite: Declare the section in ld/testsuite/ld-gc/dummy.s correctly.

Jan Dubiec jdx@o2.pl
Sun Aug 9 23:38:14 GMT 2026


These three test cases fail on H8:

Running /mnt/Works/binutils/ld/testsuite/ld-gc/gc.exp ...
[...]
FAIL: --gc-sections with --defsym
FAIL: --gc-sections with KEEP
FAIL: --gc-sections with __start_SECTIONNAME
[...]

All of them fail due to unexpected assembler warnings, e.g.:

[...]
Executing on host: ./ld-new -shared   (timeout = 300)
spawn -ignore SIGHUP ./ld-new -shared
/mnt/Works/xcomp/build-binutils-h8300-linux/ld/ld-new: -shared not supported
h8300-elf-cc  -B/mnt/Works/xcomp/build-binutils-h8300-linux/ld/tmpdir/ld/ -I/mnt/Works/binutils/ld/testsuite/ld-gc -g -O2 -fno-sanitize=all    -ffunction-sections -fdata-sections -fno-sanitize=all -fno-lto  -c /mnt/Works/binutils/ld/testsuite/ld-gc/pr13683.c -o tmpdir/pr13683.o
Executing on host: sh -c {h8300-elf-cc  -B/mnt/Works/xcomp/build-binutils-h8300-linux/ld/tmpdir/ld/ -I/mnt/Works/binutils/ld/testsuite/ld-gc -g -O2 -fno-sanitize=all    -ffunction-sections -fdata-sections -fno-sanitize=all -fno-lto  -c /mnt/Works/binutils/ld/testsuite/ld-gc/pr13683.c -o tmpdir/pr13683.o 2>&1}  /dev/null ld.tmp (timeout = 300)
spawn [open ...]
/mnt/Works/xcomp/build-binutils-h8300-linux/ld/../gas/as-new  --defsym UNDERSCORE=1    -o tmpdir/dummy.o /mnt/Works/binutils/ld/testsuite/ld-gc/dummy.s
Executing on host: sh -c {/mnt/Works/xcomp/build-binutils-h8300-linux/ld/../gas/as-new  --defsym UNDERSCORE=1    -o tmpdir/dummy.o /mnt/Works/binutils/ld/testsuite/ld-gc/dummy.s 2>&1}  /dev/null dump.tmp (timeout = 300)
spawn [open ...]
/mnt/Works/binutils/ld/testsuite/ld-gc/dummy.s: Assembler messages:
/mnt/Works/binutils/ld/testsuite/ld-gc/dummy.s:2: Warning: new section '.note.GNU-stack' defined without attributes - this might cause problems
./ld-new   -L/mnt/Works/binutils/ld/testsuite/ld-gc  --gc-sections -e main --defsym foo=foo2 tmpdir/pr13683.o -o tmpdir/dump tmpdir/dummy.o 
Executing on host: sh -c {./ld-new   -L/mnt/Works/binutils/ld/testsuite/ld-gc  --gc-sections -e main --defsym foo=foo2 tmpdir/pr13683.o -o tmpdir/dump tmpdir/dummy.o  2>&1}  /dev/null dump.tmp (timeout = 300)
spawn [open ...]
/mnt/Works/xcomp/build-binutils-h8300-linux/ld/ld-new: warning: tmpdir/pr13683.o: missing .note.GNU-stack section implies executable stack
/mnt/Works/xcomp/build-binutils-h8300-linux/ld/ld-new: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
succeeded with: </mnt/Works/binutils/ld/testsuite/ld-gc/dummy.s: Assembler messages:
/mnt/Works/binutils/ld/testsuite/ld-gc/dummy.s:2: Warning: new section '.note.GNU-stack' defined without attributes - this might cause problems>, no expected output
FAIL: --gc-sections with --defsym
[...]

This patch fixes the issue by declaring the section with an empty attribute
list. BTW, the linker still issues the warning about the executable stack,
but the tests pass.

Signed-off-by: Jan Dubiec <jdx@o2.pl>
---
 ld/testsuite/ld-gc/dummy.s | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ld/testsuite/ld-gc/dummy.s b/ld/testsuite/ld-gc/dummy.s
index 66d3b2a8856..11aba3ca5e1 100644
--- a/ld/testsuite/ld-gc/dummy.s
+++ b/ld/testsuite/ld-gc/dummy.s
@@ -1,2 +1,2 @@
 # Dummy
-	.section	".note.GNU-stack"
+	.section	".note.GNU-stack", ""
-- 
2.55.0


More information about the Binutils mailing list