[binutils-gdb] ld: testsuite: Fix test cases in ld-unique/unique.exp

Jan Beulich via Binutils-cvs <[email protected]>
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9d3e20d8c4b1e9126853f1a41c18170dac4ffec1

commit 9d3e20d8c4b1e9126853f1a41c18170dac4ffec1
Author: Jan Dubiec <[email protected]>
Date:   Fri Aug 21 14:48:17 2026 +0200

    ld: testsuite: Fix test cases in ld-unique/unique.exp
    
    These tests fail on H8, as shown in the log below, for two reasons:
      1. Unexpected assembler diagnostics (see also https://sourceware.org/pipermail/binutils/2026-August/150723.html).
      2. An undefined reference to main: unique.s defines main, whereas the C
      startup code expects _main.
    
    This patch fixes both issues.
    
    [...]
    Running /mnt/Works/binutils/ld/testsuite/ld-unique/unique.exp ...
    FAIL: Could not create a non-unique object
    FAIL: Could not link a unique executable
    [...]
    
    Detailed log:
    [...]
    h8300-elf-cc  -B/mnt/Works/xcomp/build-binutils-h8300-linux/ld/tmpdir/ld/ -I/mnt/Works/binutils/ld/testsuite/ld-unique -g -O2 -fno-sanitize=all    -c  -c /mnt/Works/binutils/ld/testsuite/ld-unique/unique.s -o tmpdir/unique.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-unique -g -O2 -fno-sanitize=all    -c  -c /mnt/Works/binutils/ld/testsuite/ld-unique/unique.s -o tmpdir/unique.o 2>&1}  /dev/null ld.tmp (timeout = 300)
    spawn [open ...]
    h8300-elf-cc  -B/mnt/Works/xcomp/build-binutils-h8300-linux/ld/tmpdir/ld/ -I/mnt/Works/binutils/ld/testsuite/ld-unique -g -O2 -fno-sanitize=all    -c  -c /mnt/Works/binutils/ld/testsuite/ld-unique/unique_empty.s -o tmpdir/unique_empty.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-unique -g -O2 -fno-sanitize=all    -c  -c /mnt/Works/binutils/ld/testsuite/ld-unique/unique_empty.s -o tmpdir/unique_empty.o 2>&1}  /dev/null ld.tmp (timeout = 300)
    spawn [open ...]
    /mnt/Works/binutils/ld/testsuite/ld-unique/unique_empty.s: Assembler messages:
    /mnt/Works/binutils/ld/testsuite/ld-unique/unique_empty.s:6: Warning: new section '.note.GNU-stack' defined without attributes - this might cause problems
    /mnt/Works/binutils/ld/testsuite/ld-unique/unique_empty.s:6: Warning: new section '.note.GNU-stack' defined without attributes - this might cause problems
    
    FAIL: Could not create a non-unique object
    h8300-elf-cc  -B/mnt/Works/xcomp/build-binutils-h8300-linux/ld/tmpdir/ld/  -no-pie  -L/usr/local/h8300-elf/lib      -L/mnt/Works/xcomp/build-binutils-h8300-linux/ld -o tmpdir/unique_prog tmpdir/unique.o
    Executing on host: sh -c {h8300-elf-cc  -B/mnt/Works/xcomp/build-binutils-h8300-linux/ld/tmpdir/ld/  -no-pie  -L/usr/local/h8300-elf/lib      -L/mnt/Works/xcomp/build-binutils-h8300-linux/ld -o tmpdir/unique_prog tmpdir/unique.o 2>&1}  /dev/null ld.tmp (timeout = 300)
    spawn [open ...]
    /mnt/Works/xcomp/sysroot-linux/h8300-elf/bin/ld: warning: /mnt/Works/xcomp/sysroot-linux/bin/../lib/gcc/h8300-elf/17.0.0/crtn.o: missing .note.GNU-stack section implies executable stack
    /mnt/Works/xcomp/sysroot-linux/h8300-elf/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
    /mnt/Works/xcomp/sysroot-linux/h8300-elf/bin/ld: /mnt/Works/xcomp/sysroot-linux/bin/../lib/gcc/h8300-elf/17.0.0/../../../../h8300-elf/lib/crt0.o: in function `start':
    (.text+0x29): undefined reference to `main'
    collect2: error: ld returned 1 exit status
    /mnt/Works/xcomp/sysroot-linux/h8300-elf/bin/ld: warning: /mnt/Works/xcomp/sysroot-linux/bin/../lib/gcc/h8300-elf/17.0.0/crtn.o: missing .note.GNU-stack section implies executable stack
    /mnt/Works/xcomp/sysroot-linux/h8300-elf/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
    /mnt/Works/xcomp/sysroot-linux/h8300-elf/bin/ld: /mnt/Works/xcomp/sysroot-linux/bin/../lib/gcc/h8300-elf/17.0.0/../../../../h8300-elf/lib/crt0.o: in function `start':
    (.text+0x29): undefined reference to `main'
    collect2: error: ld returned 1 exit status
    
    FAIL: Could not link a unique executable
    [...]
    
    Signed-off-by: Jan Dubiec <[email protected]>

Diff:
---
 ld/testsuite/ld-unique/unique.s        | 5 +++--
 ld/testsuite/ld-unique/unique_empty.s  | 2 +-
 ld/testsuite/ld-unique/unique_shared.s | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/ld/testsuite/ld-unique/unique.s b/ld/testsuite/ld-unique/unique.s
index 2ad41c25201..cfaf94f0aeb 100644
--- a/ld/testsuite/ld-unique/unique.s
+++ b/ld/testsuite/ld-unique/unique.s
@@ -3,9 +3,10 @@ a_val:	.long 0
 	.size a_val, .-a_val
 
         .type main,"function"
-        .global main
+        .global main, _main
 main:
+_main:
         .long 0
 
-	.section	.note.GNU-stack,""
+	.section	.note.GNU-stack, ""
 
diff --git a/ld/testsuite/ld-unique/unique_empty.s b/ld/testsuite/ld-unique/unique_empty.s
index 71d5b862498..c7b2778defa 100644
--- a/ld/testsuite/ld-unique/unique_empty.s
+++ b/ld/testsuite/ld-unique/unique_empty.s
@@ -3,4 +3,4 @@
 main:
 	.dc.a b_val
 
-	.section	.note.GNU-stack
+	.section	.note.GNU-stack, ""
diff --git a/ld/testsuite/ld-unique/unique_shared.s b/ld/testsuite/ld-unique/unique_shared.s
index 359b13eb809..0a7f7d34368 100644
--- a/ld/testsuite/ld-unique/unique_shared.s
+++ b/ld/testsuite/ld-unique/unique_shared.s
@@ -1,4 +1,4 @@
 	.type b_val, %gnu_unique_object
 b_val:	.long 0
 	.size b_val, .-b_val
-	.section	.note.GNU-stack
+	.section	.note.GNU-stack, ""
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.