Subject: Re: Killing linker script in NetBSD/sh3
To: None <port-sh3@NetBSD.org>
From: Masao Uebayashi <uebayasi@brains.co.jp>
List: port-sh3
Date: 03/16/2006 17:52:31
(Only to port-sh3, because this is sh3 generic.)

This is a simplified (don't disturb irrelevant parts) version of
previous, plus converting all sh3 ports (dreamcast and mmeye were
missed).

Each port defines default TEXTADDR as DEFTEXTADDR.  If each kernel
config doesn't define TEXTADDR, DEFTEXTADDR is used.  This is what
other ports are doing. LINKFLAGS_NORMAL=-X is most ports are use too.

Tested only on COMPUTEXEVB (evbsh3).

Masao

Index: arch/dreamcast/conf/std.dreamcast
===================================================================
RCS file: /src/NetBSD/cvsroot/src/sys/arch/dreamcast/conf/std.dreamcast,v
retrieving revision 1.7
diff -u -r1.7 std.dreamcast
--- arch/dreamcast/conf/std.dreamcast	11 Dec 2005 12:17:06 -0000	1.7
+++ arch/dreamcast/conf/std.dreamcast	16 Mar 2006 08:29:21 -0000
@@ -18,4 +18,5 @@
 options 	IOM_RAM_SIZE=0x01000000         # 16MB
 
 makeoptions	ENDIAN="-EL"
-makeoptions	LDSCRIPTBASE="shl.x"	# for little endian
+#makeoptions	LDSCRIPTBASE="shl.x"	# for little endian
+makeoptions	DEFTEXTADDR="0x8c001000"
Index: arch/evbsh3/conf/std.evbsh3.eb
===================================================================
RCS file: /src/NetBSD/cvsroot/src/sys/arch/evbsh3/conf/std.evbsh3.eb,v
retrieving revision 1.5
diff -u -r1.5 std.evbsh3.eb
--- arch/evbsh3/conf/std.evbsh3.eb	11 Dec 2005 12:17:13 -0000	1.5
+++ arch/evbsh3/conf/std.evbsh3.eb	16 Mar 2006 08:29:28 -0000
@@ -8,5 +8,6 @@
 options 	EXEC_SCRIPT	# exec #! scripts
 
 makeoptions	ENDIAN="-EB"
-makeoptions	LDSCRIPTBASE="sh.x"	# for big endian
+#makeoptions	LDSCRIPTBASE="sh.x"	# for big endian
+makeoptions	DEFTEXTADDR="0x8c010000"
 makeoptions	MACHINE_ARCH=sh3eb
Index: arch/evbsh3/conf/std.evbsh3.el
===================================================================
RCS file: /src/NetBSD/cvsroot/src/sys/arch/evbsh3/conf/std.evbsh3.el,v
retrieving revision 1.5
diff -u -r1.5 std.evbsh3.el
--- arch/evbsh3/conf/std.evbsh3.el	11 Dec 2005 12:17:13 -0000	1.5
+++ arch/evbsh3/conf/std.evbsh3.el	16 Mar 2006 08:29:36 -0000
@@ -8,5 +8,6 @@
 options 	EXEC_SCRIPT	# exec #! scripts
 
 makeoptions	ENDIAN="-EL"
-makeoptions	LDSCRIPTBASE="shl.x"	# for little endian
+#makeoptions	LDSCRIPTBASE="shl.x"	# for little endian
+makeoptions	DEFTEXTADDR="0x8c010000"
 makeoptions	MACHINE_ARCH=sh3el
Index: arch/evbsh3/evbsh3/locore.S
===================================================================
RCS file: /src/NetBSD/cvsroot/src/sys/arch/evbsh3/evbsh3/locore.S,v
retrieving revision 1.9
diff -u -r1.9 locore.S
--- arch/evbsh3/evbsh3/locore.S	11 Dec 2005 12:17:13 -0000	1.9
+++ arch/evbsh3/evbsh3/locore.S	14 Mar 2006 06:24:38 -0000
@@ -218,8 +218,8 @@
 XLInitializeBsc:.long	_C_LABEL(InitializeBsc)
 #endif /* DONT_INIT_BSC */
 ___start:	.long	start
-___etext:	.long	_etext
-___end:		.long	_end
+___etext:	.long	_C_LABEL(etext)
+___end:		.long	_C_LABEL(end)
 XLtmpstk:	.long	INIT_STACK
 _KERNBASE:	.long	0x8c000000
 _ROM_START:	.long	IOM_ROM_BEGIN
Index: arch/evbsh3/evbsh3/machdep.c
===================================================================
RCS file: /src/NetBSD/cvsroot/src/sys/arch/evbsh3/evbsh3/machdep.c,v
retrieving revision 1.56
diff -u -r1.56 machdep.c
--- arch/evbsh3/evbsh3/machdep.c	24 Dec 2005 20:07:03 -0000	1.56
+++ arch/evbsh3/evbsh3/machdep.c	16 Mar 2006 05:01:01 -0000
@@ -223,11 +223,11 @@
 void
 initSH3(void *pc)	/* XXX return address */
 {
-	extern char _edata[], _end[];
+	extern char edata[], end[];
 	vaddr_t kernend;
 
 	/* Clear bss */
-	memset(_edata, 0, _end - _edata);
+	memset(edata, 0, end - edata);
 
 	/* Initilize CPU ops. */
 #if defined(SH3) && defined(SH4)
@@ -261,7 +261,7 @@
 	consinit();
 
 	/* Load memory to UVM */
-	kernend = atop(round_page(SH3_P1SEG_TO_PHYS(_end)));
+	kernend = atop(round_page(SH3_P1SEG_TO_PHYS(end)));
 	physmem = atop(IOM_RAM_SIZE);
 	uvm_page_physload(
 		kernend, atop(IOM_RAM_BEGIN + IOM_RAM_SIZE),
Index: arch/hpcsh/conf/std.hpcsh
===================================================================
RCS file: /src/NetBSD/cvsroot/src/sys/arch/hpcsh/conf/std.hpcsh,v
retrieving revision 1.7
diff -u -r1.7 std.hpcsh
--- arch/hpcsh/conf/std.hpcsh	11 Dec 2005 12:17:36 -0000	1.7
+++ arch/hpcsh/conf/std.hpcsh	16 Mar 2006 08:29:41 -0000
@@ -10,5 +10,6 @@
 
 makeoptions	ENDIAN="-EL"
 #makeoptions	LDSCRIPTBASE="shl-coff.x"	# for COFF kernel
-makeoptions	LDSCRIPTBASE="shl-elf.x"	# for ELF kernel
+#makeoptions	LDSCRIPTBASE="shl-elf.x"	# for ELF kernel
+makeoptions	DEFTEXTADDR="0x8c001000"
 makeoptions	MACHINE_ARCH=sh3el
Index: arch/mmeye/conf/std.mmeye
===================================================================
RCS file: /src/NetBSD/cvsroot/src/sys/arch/mmeye/conf/std.mmeye,v
retrieving revision 1.10
diff -u -r1.10 std.mmeye
--- arch/mmeye/conf/std.mmeye	11 Dec 2005 12:18:16 -0000	1.10
+++ arch/mmeye/conf/std.mmeye	16 Mar 2006 08:29:49 -0000
@@ -13,4 +13,5 @@
 options 	EXEC_SCRIPT			# exec #! scripts
 
 makeoptions	ENDIAN="-EB"
-makeoptions	LDSCRIPTBASE="sh.x"		# for big endian
+#makeoptions	LDSCRIPTBASE="sh.x"		# for big endian
+makeoptions	DEFTEXTADDR="0x8c010000"
Index: arch/sh3/conf/Makefile.sh3
===================================================================
RCS file: /src/NetBSD/cvsroot/src/sys/arch/sh3/conf/Makefile.sh3,v
retrieving revision 1.21
diff -u -r1.21 Makefile.sh3
--- arch/sh3/conf/Makefile.sh3	11 Dec 2005 12:18:58 -0000	1.21
+++ arch/sh3/conf/Makefile.sh3	16 Mar 2006 08:28:18 -0000
@@ -59,9 +59,8 @@
 ##
 ## (5) link settings
 ##
-# LINKFORMAT possibly set by individual sh3 port
-# LDSCRIPTBASE comes from the kernel's config
-LINKFORMAT?=	-T ${THISSH3}/conf/${LDSCRIPTBASE}
+TEXTADDR?=	${DEFTEXTADDR}
+LINKFLAGS_NORMAL=	-X
 
 ##
 ## (6) port specific target dependencies