Subject: Killing linker script in NetBSD/sh3
To: None <port-hpcsh@NetBSD.org, port-sh3@NetBSD.org>
From: Masao Uebayashi <uebayasi@brains.co.jp>
List: port-hpcsh
Date: 03/14/2006 16:30:58
Hi!

This patch kills linker script along with converting evbsh3 from COFF
to ELF.  This fixes evbsh3 kernel build which has been broken for a
while.

Note I set default TEXTADDR to 0x8c010000 on evbsh3, which differs
from that of hpcsh, 0x8c001000.

I tested COMPUTEXEVB.  I need feedback from hpcsh users.

TIA,
Masao

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	14 Mar 2006 07:18:00 -0000
@@ -5,10 +5,10 @@
 # This makefile is constructed from a machine description:
 #	config machineid
 # Most changes should be made in the machine description
-#	/sys/arch/<machine>/conf/``machineid''
+#	/sys/arch/<arch>/conf/``machineid''
 # after which you should do
 #	config machineid
-# CPU generic makefile changes should be made in
+# Machine generic makefile changes should be made in
 #	/sys/arch/sh3/conf/Makefile.sh3
 # after which config should be rerun for all machines of that type.
 #
@@ -32,8 +32,7 @@
 ##
 ## (2) compile settings
 ##
-CPPFLAGS+=	-D${MACHINE}
-CWARNFLAGS+=	-Wno-parentheses
+# CPPFLAGS set by platform-specific Makefile fragment.
 AFLAGS+=	-x assembler-with-cpp -traditional-cpp
 # pkgsrc/cross/sh* dies with -O2, use -O1 for now
 COPTS?=		-O1
@@ -52,16 +51,11 @@
 locore.o: ${THISSH3}/${MACHINE}/locore.S assym.h
 	${NORMAL_S}
 
-# XXX compile ffs_inode.c always with -O0 to avoid egcs-1.1.2 bug.
-#ffs_inode.o: $S/ufs/ffs/ffs_inode.c
-#	${CC} ${CFLAGS} -O0 ${CPPFLAGS} ${PROF} -c $<
-
 ##
 ## (5) link settings
 ##
-# LINKFORMAT possibly set by individual sh3 port
-# LDSCRIPTBASE comes from the kernel's config
-LINKFORMAT?=	-T ${THISSH3}/conf/${LDSCRIPTBASE}
+TEXTADDR?=	0x8c010000
+LINKFLAGS_NORMAL=	-X
 
 ##
 ## (6) port specific target dependencies
Index: arch/evbsh3/conf/COMPUTEXEVB
===================================================================
RCS file: /src/NetBSD/cvsroot/src/sys/arch/evbsh3/conf/COMPUTEXEVB,v
retrieving revision 1.26
diff -u -r1.26 COMPUTEXEVB
--- arch/evbsh3/conf/COMPUTEXEVB	7 Dec 2005 09:10:13 -0000	1.26
+++ arch/evbsh3/conf/COMPUTEXEVB	10 Mar 2006 09:58:41 -0000
@@ -50,7 +50,7 @@
 options		COMPAT_BSDPTY	# /dev/[pt]ty?? ptys.
 
 # Executable format options
-options 	EXEC_COFF	# 32-bit COFF executables (sh-compiler)
+#options 	EXEC_COFF	# 32-bit COFF executables (sh-compiler)
 
 # File systems
 file-system 	FFS		# UFS
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	14 Mar 2006 07:07:30 -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	TEXTADDR=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	14 Mar 2006 07:07:41 -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	TEXTADDR=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	14 Mar 2006 06:22:46 -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	14 Mar 2006 07:04:06 -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	TEXTADDR=0x8c001000
 makeoptions	MACHINE_ARCH=sh3el