[v2] h8300-elf: ld: Use USER_LABEL_PREFIX when generating linker scripts

Message ID 20260821235634.1564244-1-jdx@o2.pl
State New
Headers
Series [v2] h8300-elf: ld: Use USER_LABEL_PREFIX when generating linker scripts |

Checks

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

Commit Message

Jan Dubiec Aug. 21, 2026, 11:55 p.m. UTC
  This version does not explicitly set the entry symbol; the default one
is used instead. The corresponding newlib patch will follow shortly.

Signed-off-by: Jan Dubiec <jdx@o2.pl>
---
  ld/emulparams/h8300elf.sh         | 1 +
 ld/testsuite/ld-h8300/gcsection.d | 2 +-
 ld/testsuite/ld-h8300/gcsection.s | 6 +++---
 ld/testsuite/ld-h8300/relax-2.d   | 2 +-
 ld/testsuite/ld-h8300/relax-2.s   | 4 ++--
 ld/testsuite/ld-h8300/relax-3.d   | 2 +-
 ld/testsuite/ld-h8300/relax-3.s   | 4 ++--
 ld/testsuite/ld-h8300/relax-4.d   | 2 +-
 ld/testsuite/ld-h8300/relax-4.s   | 4 ++--
 ld/testsuite/ld-h8300/relax-5.d   | 2 +-
 ld/testsuite/ld-h8300/relax-5.s   | 4 ++--
 ld/testsuite/ld-h8300/relax-6.d   | 2 +-
 ld/testsuite/ld-h8300/relax-6.s   | 4 ++--
 ld/testsuite/ld-h8300/relax-7.d   | 2 +-
 ld/testsuite/ld-h8300/relax-7a.s  | 4 ++--
 ld/testsuite/ld-h8300/relax.d     | 2 +-
 ld/testsuite/ld-h8300/relax.s     | 4 ++--
 sim/testsuite/h8300/testutils.inc | 4 ++--
 18 files changed, 28 insertions(+), 27 deletions(-)
  

Comments

Jan Dubiec Aug. 22, 2026, 12:18 a.m. UTC | #1
On 22.08.2026 01:55, Jan Dubiec wrote:
> This version does not explicitly set the entry symbol; the default one
> is used instead. The corresponding newlib patch will follow shortly.
Link to the corresponding newlib patch: 
https://inbox.sourceware.org/newlib/20260822001114.1564261-1-jdx@o2.pl/T/#u

/J.D.
  
Alan Modra Aug. 22, 2026, 9:31 a.m. UTC | #2
On Sat, Aug 22, 2026 at 01:55:30AM +0200, Jan Dubiec wrote:
> This version does not explicitly set the entry symbol; the default one
> is used instead. The corresponding newlib patch will follow shortly.
> 
> Signed-off-by: Jan Dubiec <jdx@o2.pl>
> ---
>   ld/emulparams/h8300elf.sh         | 1 +
>  ld/testsuite/ld-h8300/gcsection.d | 2 +-
>  ld/testsuite/ld-h8300/gcsection.s | 6 +++---
>  ld/testsuite/ld-h8300/relax-2.d   | 2 +-
>  ld/testsuite/ld-h8300/relax-2.s   | 4 ++--
>  ld/testsuite/ld-h8300/relax-3.d   | 2 +-
>  ld/testsuite/ld-h8300/relax-3.s   | 4 ++--
>  ld/testsuite/ld-h8300/relax-4.d   | 2 +-
>  ld/testsuite/ld-h8300/relax-4.s   | 4 ++--
>  ld/testsuite/ld-h8300/relax-5.d   | 2 +-
>  ld/testsuite/ld-h8300/relax-5.s   | 4 ++--
>  ld/testsuite/ld-h8300/relax-6.d   | 2 +-
>  ld/testsuite/ld-h8300/relax-6.s   | 4 ++--
>  ld/testsuite/ld-h8300/relax-7.d   | 2 +-
>  ld/testsuite/ld-h8300/relax-7a.s  | 4 ++--
>  ld/testsuite/ld-h8300/relax.d     | 2 +-
>  ld/testsuite/ld-h8300/relax.s     | 4 ++--
>  sim/testsuite/h8300/testutils.inc | 4 ++--
>  18 files changed, 28 insertions(+), 27 deletions(-)

The testsuite changes cause regressions on h8300-linux-gnu where
USER_LABEL_PREFIX is empty.

h8300-linux-gnu  +FAIL: H8300 Relaxation Test
h8300-linux-gnu  +FAIL: H8300 Relaxation Test 2
h8300-linux-gnu  +FAIL: H8300 Relaxation Test 3
h8300-linux-gnu  +FAIL: H8300 Relaxation Test 4
h8300-linux-gnu  +FAIL: H8300 Relaxation Test 5
h8300-linux-gnu  +FAIL: H8300 Relaxation Test 6
h8300-linux-gnu  +FAIL: H8300 Relaxation Test 7
h8300-linux-gnu  +FAIL: H8300 GCC section test case

warning: cannot find entry symbol _start; ...
  
Jan Dubiec Aug. 22, 2026, 10:25 a.m. UTC | #3
On 22.08.2026 11:31, Alan Modra wrote:
[...]

> The testsuite changes cause regressions on h8300-linux-gnu where
> USER_LABEL_PREFIX is empty.
> 
> h8300-linux-gnu  +FAIL: H8300 Relaxation Test
> h8300-linux-gnu  +FAIL: H8300 Relaxation Test 2
> h8300-linux-gnu  +FAIL: H8300 Relaxation Test 3
> h8300-linux-gnu  +FAIL: H8300 Relaxation Test 4
> h8300-linux-gnu  +FAIL: H8300 Relaxation Test 5
> h8300-linux-gnu  +FAIL: H8300 Relaxation Test 6
> h8300-linux-gnu  +FAIL: H8300 Relaxation Test 7
> h8300-linux-gnu  +FAIL: H8300 GCC section test case
> 
> warning: cannot find entry symbol _start; ...
> 
Argh, I forgot about Linux again...

Do you have any idea how to fix it? The following code will work on bare 
metal and should also work on Linux, but it looks rather ugly:

	.global _start, __start
_start:
__start:


/J.D.
  
Alan Modra Aug. 22, 2026, 11:01 a.m. UTC | #4
On Sat, Aug 22, 2026 at 12:25:33PM +0200, Jan Dubiec wrote:
> On 22.08.2026 11:31, Alan Modra wrote:
> [...]
> 
> > The testsuite changes cause regressions on h8300-linux-gnu where
> > USER_LABEL_PREFIX is empty.
> > 
> > h8300-linux-gnu  +FAIL: H8300 Relaxation Test
> > h8300-linux-gnu  +FAIL: H8300 Relaxation Test 2
> > h8300-linux-gnu  +FAIL: H8300 Relaxation Test 3
> > h8300-linux-gnu  +FAIL: H8300 Relaxation Test 4
> > h8300-linux-gnu  +FAIL: H8300 Relaxation Test 5
> > h8300-linux-gnu  +FAIL: H8300 Relaxation Test 6
> > h8300-linux-gnu  +FAIL: H8300 Relaxation Test 7
> > h8300-linux-gnu  +FAIL: H8300 GCC section test case
> > 
> > warning: cannot find entry symbol _start; ...
> > 
> Argh, I forgot about Linux again...
> 
> Do you have any idea how to fix it? The following code will work on bare
> metal and should also work on Linux, but it looks rather ugly:
> 
> 	.global _start, __start
> _start:
> __start:

Yes, that's what we use in other testcases.
  
Jan Dubiec Aug. 22, 2026, 11:09 a.m. UTC | #5
On 22.08.2026 13:01, Alan Modra wrote:
[...]

> Yes, that's what we use in other testcases.
> 
OK, then. I'll post v3 later today.

/J.D.
  

Patch

diff --git a/ld/emulparams/h8300elf.sh b/ld/emulparams/h8300elf.sh
index 45b3458d1ce..dd007fcd0ff 100644
--- a/ld/emulparams/h8300elf.sh
+++ b/ld/emulparams/h8300elf.sh
@@ -9,6 +9,7 @@  MAXPAGESIZE=2
 TARGET_PAGE_SIZE=128
 ARCH=h8300
 TEMPLATE_NAME=elf
+USER_LABEL_PREFIX=_
 EMBEDDED=yes
 STACK_ADDR=0xfefc
 TINY_READONLY_SECTION=".tinyrodata :
diff --git a/ld/testsuite/ld-h8300/gcsection.d b/ld/testsuite/ld-h8300/gcsection.d
index acf39be8d7f..af52552fb3a 100644
--- a/ld/testsuite/ld-h8300/gcsection.d
+++ b/ld/testsuite/ld-h8300/gcsection.d
@@ -17,7 +17,7 @@  Disassembly of section .text:
  114:	mov.l	@er7\+,er6
  118:	rts	
 
-0000011a <_start>:
+0000011a <__start>:
  11a:	mov.l	er6,@-er7
  11e:	mov.l	er7,er6
  120:	mov.w	#0x4b,r0
diff --git a/ld/testsuite/ld-h8300/gcsection.s b/ld/testsuite/ld-h8300/gcsection.s
index 2149ee99cb4..29eccfeb02f 100644
--- a/ld/testsuite/ld-h8300/gcsection.s
+++ b/ld/testsuite/ld-h8300/gcsection.s
@@ -29,8 +29,8 @@  _functionWeDontUse:
 	.size	_functionWeDontUse, .-_functionWeDontUse
 	.section	.text.start,"ax",@progbits
 	.align 1
-	.global _start
-_start:
+	.global __start
+__start:
 	mov.l	er6,@-er7
 	mov.l	er7,er6
 	mov.w	#75,r0
@@ -39,5 +39,5 @@  _start:
 	mov.w	r2,r0
 	mov.l	@er7+,er6
 	rts
-	.size	_start, .-_start
+	.size	__start, .-__start
 	.end
diff --git a/ld/testsuite/ld-h8300/relax-2.d b/ld/testsuite/ld-h8300/relax-2.d
index 7e7964b5c81..fb40a9569fe 100644
--- a/ld/testsuite/ld-h8300/relax-2.d
+++ b/ld/testsuite/ld-h8300/relax-2.d
@@ -6,7 +6,7 @@ 
 
 Disassembly of section .text:
 
-00000100 <_start>:
+00000100 <__start>:
  100:	mov.b	@0x64:8,r0l
  102:	mov.b	r0l,@0x64:8
  104:	mov.b	@0x4320:16,r0l
diff --git a/ld/testsuite/ld-h8300/relax-2.s b/ld/testsuite/ld-h8300/relax-2.s
index 8e096b83863..5d02ce3b801 100644
--- a/ld/testsuite/ld-h8300/relax-2.s
+++ b/ld/testsuite/ld-h8300/relax-2.s
@@ -1,6 +1,6 @@ 
 	.h8300h
-	.globl	_start
-_start:
+	.globl	__start
+__start:
 	mov.b	@foo:16,r0l
 	mov.b	r0l,@foo:16
 	mov.b	@bar:32,r0l
diff --git a/ld/testsuite/ld-h8300/relax-3.d b/ld/testsuite/ld-h8300/relax-3.d
index f5a9390b785..35c88ee55c2 100644
--- a/ld/testsuite/ld-h8300/relax-3.d
+++ b/ld/testsuite/ld-h8300/relax-3.d
@@ -6,7 +6,7 @@ 
 
 Disassembly of section .text:
 
-00000100 <_start>:
+00000100 <__start>:
 #
 # Relaxation of aa:16
 #
diff --git a/ld/testsuite/ld-h8300/relax-3.s b/ld/testsuite/ld-h8300/relax-3.s
index f4a2346ab9c..84d0934e1b7 100644
--- a/ld/testsuite/ld-h8300/relax-3.s
+++ b/ld/testsuite/ld-h8300/relax-3.s
@@ -1,6 +1,6 @@ 
 	.h8300s
-	.globl	_start
-_start:
+	.globl	__start
+__start:
 	# s3-s6 aren't valid 16-bit addresses.
 	mov.b	@s1:16,r0l
 	mov.b	@s2:16,r0l
diff --git a/ld/testsuite/ld-h8300/relax-4.d b/ld/testsuite/ld-h8300/relax-4.d
index ee80bc39644..a6e040f1130 100644
--- a/ld/testsuite/ld-h8300/relax-4.d
+++ b/ld/testsuite/ld-h8300/relax-4.d
@@ -6,7 +6,7 @@ 
 
 Disassembly of section .text:
 
-00000100 <_start>:
+00000100 <__start>:
  100:	mov.b	#0x3,r0l
  102:	mov.b	#0x5,r2l
  104:	bset	r0l,@0xff:8
diff --git a/ld/testsuite/ld-h8300/relax-4.s b/ld/testsuite/ld-h8300/relax-4.s
index 7d6296da230..29aad35d4a8 100644
--- a/ld/testsuite/ld-h8300/relax-4.s
+++ b/ld/testsuite/ld-h8300/relax-4.s
@@ -1,8 +1,8 @@ 
 ; Relaxation is possible for following bit manipulation instructions
 ; BAND, BCLR, BIAND, BILD, BIOR, BIST, BIXOR, BLD, BNOT, BOR, BSET, BST, BTST, BXOR
 	.h8300s
-	.globl	_start
-_start:
+	.globl	__start
+__start:
 	# s3-s6 aren't valid 16-bit addresses.
 	mov.b	#0x3,r0l
 	mov.b	#0x5,r2l
diff --git a/ld/testsuite/ld-h8300/relax-5.d b/ld/testsuite/ld-h8300/relax-5.d
index 00c4fa89ee4..b678fec1f86 100644
--- a/ld/testsuite/ld-h8300/relax-5.d
+++ b/ld/testsuite/ld-h8300/relax-5.d
@@ -7,7 +7,7 @@ 
 
 Disassembly of section .text:
 
-00000100 <_start>:
+00000100 <__start>:
  100:	ldc	@0x0:16,ccr
  106:	ldc	@0x7fff:16,ccr
  10c:	ldc	@0x8000:32,ccr
diff --git a/ld/testsuite/ld-h8300/relax-5.s b/ld/testsuite/ld-h8300/relax-5.s
index b5afedbfcca..6264c6d5848 100644
--- a/ld/testsuite/ld-h8300/relax-5.s
+++ b/ld/testsuite/ld-h8300/relax-5.s
@@ -4,11 +4,11 @@ 
 ; ldc.w @aa:32,exr
 ; stc.w exr,@aa:32
 	.h8300s
-    	.globl	_start
+    	.globl	__start
 ;
 ; Relaxation of aa:32
 ;
-    _start:
+    __start:
     	ldc  @s1:32,ccr
 	ldc  @s2:32,ccr
 	ldc  @s3:32,ccr
diff --git a/ld/testsuite/ld-h8300/relax-6.d b/ld/testsuite/ld-h8300/relax-6.d
index 54853ef6dbc..17eeed14932 100644
--- a/ld/testsuite/ld-h8300/relax-6.d
+++ b/ld/testsuite/ld-h8300/relax-6.d
@@ -6,6 +6,6 @@ 
 .*:     file format .*
 Disassembly of section .text:
 
-00000100 <_start>:
+00000100 <__start>:
  100:	mov.b	r2l,@0xbd:8
  102:	rts	
diff --git a/ld/testsuite/ld-h8300/relax-6.s b/ld/testsuite/ld-h8300/relax-6.s
index fb44b54cb1d..abf7cdcd42a 100644
--- a/ld/testsuite/ld-h8300/relax-6.s
+++ b/ld/testsuite/ld-h8300/relax-6.s
@@ -1,5 +1,5 @@ 
 	.h8300s
-	.global _start
-_start:
+	.global __start
+__start:
 	mov.b	r2l,@0xFFFFFFBD:32
 	rts
diff --git a/ld/testsuite/ld-h8300/relax-7.d b/ld/testsuite/ld-h8300/relax-7.d
index f45787c75ce..c3e0846721e 100644
--- a/ld/testsuite/ld-h8300/relax-7.d
+++ b/ld/testsuite/ld-h8300/relax-7.d
@@ -27,7 +27,7 @@  Contents of section .rodata:
 
 Disassembly of section .text:
 
-00000100 <_start>:
+00000100 <__start>:
  100:	sub.l	er0,er0
  102:	sub.l	er2,er2
  104:	mov.l	#0xffff8000,er1
diff --git a/ld/testsuite/ld-h8300/relax-7a.s b/ld/testsuite/ld-h8300/relax-7a.s
index 915fb79caed..fa0a4b08917 100644
--- a/ld/testsuite/ld-h8300/relax-7a.s
+++ b/ld/testsuite/ld-h8300/relax-7a.s
@@ -1,9 +1,9 @@ 
 	.h8300s
 # relax expected
-	.global _start
+	.global __start
 	.section	.text.func1,"ax",@progbits
 	.align 1
-_start:
+__start:
 	sub.l	er0,er0
 	sub.l	er2,er2
 	mov.l	#var3,er1
diff --git a/ld/testsuite/ld-h8300/relax.d b/ld/testsuite/ld-h8300/relax.d
index fb863586bfb..90e3b650d99 100644
--- a/ld/testsuite/ld-h8300/relax.d
+++ b/ld/testsuite/ld-h8300/relax.d
@@ -9,7 +9,7 @@ 
 
 Disassembly of section .text:
 
-00000100 <_start>:
+00000100 <__start>:
  100:	0d 00.*mov.w	r0,r0
  102:	47 02.*beq	.+2 \(0x106\)
  104:	55 02.*bsr	.+2 \(0x108\)
diff --git a/ld/testsuite/ld-h8300/relax.s b/ld/testsuite/ld-h8300/relax.s
index b06f3a921c6..c47943dfacf 100644
--- a/ld/testsuite/ld-h8300/relax.s
+++ b/ld/testsuite/ld-h8300/relax.s
@@ -1,6 +1,6 @@ 
 	.text
-	.global _start
-_start:
+	.global __start
+__start:
         mov.w   r0,r0
         beq     .L1
         jsr     @_bar
diff --git a/sim/testsuite/h8300/testutils.inc b/sim/testsuite/h8300/testutils.inc
index 63d27d45c14..7676ff58c58 100644
--- a/sim/testsuite/h8300/testutils.inc
+++ b/sim/testsuite/h8300/testutils.inc
@@ -20,8 +20,8 @@ 
 
 	.text
 	.align 2
-	.global _start
-_start:
+	.global __start
+__start:
 	jmp	_main
 
 	.data