$NetBSD: patch-sh,v 1.1 2001/01/04 01:18:08 itojun Exp $

ftp://ftp.netbsd.org/pub/NetBSD/arch/sh3/crosskit/

diff -u -r -N -x *.orig -x CVS old/bfd/Makefile.am binutils-2.9.1/bfd/Makefile.am
--- bfd/Makefile.am	Wed Jan  3 20:40:59 2001
+++ bfd/Makefile.am	Wed Jan  3 20:44:17 2001
@@ -153,6 +153,7 @@
 	elf-m10200.lo \
 	elf-m10300.lo \
 	elf32-ppc.lo \
+	elf32-shunx.lo \
 	elf32-sh.lo \
 	elf32-sparc.lo \
 	elf32-v850.lo \
@@ -260,6 +261,7 @@
 	elf-m10200.c \
 	elf-m10300.c \
 	elf32-ppc.c \
+	elf32-shunx.c \
 	elf32-sh.c \
 	elf32-sparc.c \
 	elf32-v850.c \
@@ -797,6 +799,9 @@
 elf32-ppc.lo: elf32-ppc.c $(INCDIR)/bfdlink.h elf-bfd.h \
   $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
   $(INCDIR)/elf/ppc.h elf32-target.h
+elf32-shunx.lo: elf32-shunx.c $(INCDIR)/bfdlink.h elf-bfd.h \
+  $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+  elf32-target.h
 elf32-sh.lo: elf32-sh.c $(INCDIR)/bfdlink.h elf-bfd.h \
   $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
   elf32-target.h
diff -u -r -N -x *.orig -x CVS old/bfd/Makefile.in binutils-2.9.1/bfd/Makefile.in
--- bfd/Makefile.in	Wed Jan  3 20:40:59 2001
+++ bfd/Makefile.in	Wed Jan  3 20:44:04 2001
@@ -242,6 +242,7 @@
 	elf-m10200.lo \
 	elf-m10300.lo \
 	elf32-ppc.lo \
+	elf32-shunx.lo \
 	elf32-sh.lo \
 	elf32-sparc.lo \
 	elf32-v850.lo \
@@ -349,6 +350,7 @@
 	elf-m10200.c \
 	elf-m10300.c \
 	elf32-ppc.c \
+	elf32-shunx.c \
 	elf32-sh.c \
 	elf32-sparc.c \
 	elf32-v850.c \
@@ -1254,6 +1256,9 @@
 elf32-ppc.lo: elf32-ppc.c $(INCDIR)/bfdlink.h elf-bfd.h \
   $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
   $(INCDIR)/elf/ppc.h elf32-target.h
+elf32-shunx.lo: elf32-shunx.c $(INCDIR)/bfdlink.h elf-bfd.h \
+  $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+  elf32-target.h
 elf32-sh.lo: elf32-sh.c $(INCDIR)/bfdlink.h elf-bfd.h \
   $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
   elf32-target.h
diff -u -r -N -x *.orig -x CVS old/bfd/config.bfd binutils-2.9.1/bfd/config.bfd
--- bfd/config.bfd	Wed Jan  3 20:55:42 2001
+++ bfd/config.bfd	Wed Jan  3 20:46:00 2001
@@ -40,6 +40,7 @@
 powerpc*) targ_archs="bfd_rs6000_arch bfd_powerpc_arch" ;;
 rs6000)	targ_archs="bfd_rs6000_arch bfd_powerpc_arch" ;;
 sparc*)	targ_archs=bfd_sparc_arch ;;
+sh*)	targ_archs=bfd_sh_arch ;;
 v850*)	targ_archs=bfd_v850_arch ;;
 z8k*)	targ_archs=bfd_z8k_arch ;;
 *)	targ_archs=bfd_${targ_cpu}_arch ;;
@@ -494,14 +495,34 @@
     targ_defvec=rs6000coff_vec
     ;;
 
+  sh-*-netbsdelf)
+    targ_defvec=bfd_elf32_shunx_vec
+    targ_selvecs="bfd_elf32_shlunx_vec shcoff_vec shlcoff_vec "
+    targ_underscore=yes
+    ;;
+  shel-*-netbsdelf)
+    targ_defvec=bfd_elf32_shlunx_vec
+    targ_selvecs="bfd_elf32_shunx_vec shcoff_vec shlcoff_vec "
+    targ_underscore=yes
+    ;;
   sh-*-elf*)
     targ_defvec=bfd_elf32_sh_vec
-    targ_selvecs="bfd_elf32_shl_vec shcoff_vec shlcoff_vec shcoff_small_vec shlcoff_small_vec"
+    targ_selvecs="bfd_elf32_shl_vec shcoff_vec shlcoff_vec "
+    targ_underscore=yes
+    ;;
+  sh-*-netbsdcoff)
+    targ_defvec=shcoff_vec
+    targ_selvecs="shlcoff_vec "
+    targ_underscore=yes
+    ;;
+  shel-*-netbsdcoff)
+    targ_defvec=shlcoff_vec
+    targ_selvecs="shcoff_vec "
     targ_underscore=yes
     ;;
   sh-*-* | sh-*-rtems*)
     targ_defvec=shcoff_vec
-    targ_selvecs="shcoff_vec shlcoff_vec shcoff_small_vec shlcoff_small_vec"
+    targ_selvecs="shlcoff_vec "
     targ_underscore=yes
     ;;
 
diff -u -r -N -x *.orig -x CVS old/bfd/configure binutils-2.9.1/bfd/configure
--- bfd/configure	Wed Jan  3 20:40:59 2001
+++ bfd/configure	Wed Jan  3 20:46:23 2001
@@ -2738,6 +2738,8 @@
     bfd_elf32_mn10300_vec)	tb="$tb elf-m10300.lo elf32.lo $elf" ;;
     bfd_elf32_powerpc_vec)	tb="$tb elf32-ppc.lo elf32.lo $elf" ;;
     bfd_elf32_powerpcle_vec)	tb="$tb elf32-ppc.lo elf32.lo $elf" ;;
+    bfd_elf32_shunx_vec)	tb="$tb elf32-shunx.lo elf32.lo $elf coff-sh.lo" ;;
+    bfd_elf32_shlunx_vec)	tb="$tb elf32-shunx.lo elf32.lo $elf coff-sh.lo" ;;
     bfd_elf32_sh_vec)		tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
     bfd_elf32_shl_vec)		tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
     bfd_elf32_sparc_vec)	tb="$tb elf32-sparc.lo elf32.lo $elf" ;;
diff -u -r -N -x *.orig -x CVS old/bfd/configure.in binutils-2.9.1/bfd/configure.in
--- bfd/configure.in	Wed Jan  3 20:40:59 2001
+++ bfd/configure.in	Wed Jan  3 20:46:30 2001
@@ -423,6 +423,8 @@
     bfd_elf32_mn10300_vec)	tb="$tb elf-m10300.lo elf32.lo $elf" ;;
     bfd_elf32_powerpc_vec)	tb="$tb elf32-ppc.lo elf32.lo $elf" ;;
     bfd_elf32_powerpcle_vec)	tb="$tb elf32-ppc.lo elf32.lo $elf" ;;
+    bfd_elf32_shunx_vec)	tb="$tb elf32-shunx.lo elf32.lo $elf coff-sh.lo" ;;
+    bfd_elf32_shlunx_vec)	tb="$tb elf32-shunx.lo elf32.lo $elf coff-sh.lo" ;;
     bfd_elf32_sh_vec)		tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
     bfd_elf32_shl_vec)		tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
     bfd_elf32_sparc_vec)	tb="$tb elf32-sparc.lo elf32.lo $elf" ;;
diff -u -r -N -x *.orig -x CVS old/bfd/elf32-sh.c binutils-2.9.1/bfd/elf32-sh.c
--- bfd/elf32-sh.c	Sat May  2 00:48:09 1998
+++ bfd/elf32-sh.c	Wed Jan  3 20:47:15 2001
@@ -1889,13 +1889,28 @@
   return NULL;
 }
 
+#ifndef TARGET_BIG_SYM
 #define TARGET_BIG_SYM		bfd_elf32_sh_vec
+#endif
+
+#ifndef TARGET_BIG_NAME
 #define TARGET_BIG_NAME		"elf32-sh"
+#endif
+
+#ifndef TARGET_LITTLE_SYM
 #define TARGET_LITTLE_SYM	bfd_elf32_shl_vec
+#endif
+
+#ifndef TARGET_LITTLE_NAME
 #define TARGET_LITTLE_NAME	"elf32-shl"
+#endif
+
 #define ELF_ARCH		bfd_arch_sh
 #define ELF_MACHINE_CODE	EM_SH
+
+#ifndef ELF_MAXPAGESIZE
 #define ELF_MAXPAGESIZE		0x1
+#endif
 
 #define elf_symbol_leading_char '_'
 
diff -u -r -N -x *.orig -x CVS old/bfd/elf32-shunx.c binutils-2.9.1/bfd/elf32-shunx.c
--- bfd/elf32-shunx.c	Thu Jan  1 09:00:00 1970
+++ bfd/elf32-shunx.c	Wed Jan  3 20:47:30 2001
@@ -0,0 +1,7 @@
+#define TARGET_BIG_SYM                bfd_elf32_shunx_vec
+#define TARGET_BIG_NAME               "elf32-sh-unx"
+#define TARGET_LITTLE_SYM     bfd_elf32_shlunx_vec
+#define TARGET_LITTLE_NAME    "elf32-shl-unx"
+#define ELF_MAXPAGESIZE               0x1000
+
+#include "elf32-sh.c"
diff -u -r -N -x *.orig -x CVS old/bfd/targets.c binutils-2.9.1/bfd/targets.c
--- bfd/targets.c	Wed Jan  3 20:40:59 2001
+++ bfd/targets.c	Wed Jan  3 20:47:40 2001
@@ -504,6 +504,8 @@
 extern const bfd_target bfd_elf32_mn10300_vec;
 extern const bfd_target bfd_elf32_powerpc_vec;
 extern const bfd_target bfd_elf32_powerpcle_vec;
+extern const bfd_target bfd_elf32_shunx_vec;
+extern const bfd_target bfd_elf32_shlunx_vec;
 extern const bfd_target bfd_elf32_sh_vec;
 extern const bfd_target bfd_elf32_shl_vec;
 extern const bfd_target bfd_elf32_sparc_vec;
diff -u -r -N -x *.orig -x CVS old/config.sub binutils-2.9.1/config.sub
--- config.sub	Wed Jan  3 20:41:00 2001
+++ config.sub	Wed Jan  3 20:47:56 2001
@@ -175,7 +175,7 @@
 		| arme[lb] | pyramid | mn10200 | mn10300 \
 		| tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \
 		| alpha | alphaev5 | alphaev56 | alphapca56 | alphaev6 \
-		| we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \
+		| we32k | ns16k | clipper | i370 | sh | shel | powerpc | powerpcle \
 		| 1750a | dsp16xx | pdp11 \
 		| mips64 | mipsel | mipseb | mips64el | mips64orion | mips64orionel \
 		| mipstx39 | mipstx39el \
@@ -229,7 +229,7 @@
 	      | alpha-* | alphaev5-* | alphaev56-* | alphapca56-* \
 	      | alphaev6-* | we32k-* | cydra-* | ns16k-* | pn-* | np1-* \
 	      | xps100-* | clipper-* | orion-* \
-	      | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
+	      | sparclite-* | pdp11-* | sh-* | shel-* | powerpc-* | powerpcle-* \
 	      | sparc64-* | mips64-* | mipsel-* | mipseb-* \
 	      | mips64el-* | mips64orion-* | mips64orionel-* \
 	      | mipstx39-* | mipstx39el-* \
diff -u -r -N -x *.orig -x CVS old/ld/Makefile.am binutils-2.9.1/ld/Makefile.am
--- ld/Makefile.am	Wed Jan  3 20:40:59 2001
+++ ld/Makefile.am	Wed Jan  3 20:49:44 2001
@@ -169,6 +169,10 @@
 	eshelf.o \
 	eshlelf.o \
 	eshl.o \
+	eshunx.o \
+	eshlunx.o \
+	eelf32shunx.o \
+	eelf32shlunx.o \
 	esparcaout.o \
 	esparclinux.o \
 	esparclynx.o \
@@ -488,6 +492,18 @@
 eshl.c: $(srcdir)/emulparams/shl.sh \
   $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sh.sc ${GEN_DEPENDS}
 	${GENSCRIPTS} shl "$(tdir_shl)"
+eshunx.c: $(srcdir)/emulparams/shunx.sh \
+  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sh.sc ${GEN_DEPENDS}
+	${GENSCRIPTS} shunx "$(tdir_shunx)"
+eshlunx.c: $(srcdir)/emulparams/shlunx.sh \
+  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sh.sc ${GEN_DEPENDS}
+	${GENSCRIPTS} shlunx "$(tdir_shlunx)"
+eelf32shunx.c: $(srcdir)/emulparams/elf32shunx.sh \
+  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sh.sc ${GEN_DEPENDS}
+	${GENSCRIPTS} elf32shunx "$(tdir_elf32shunx)"
+eelf32shlunx.c: $(srcdir)/emulparams/elf32shlunx.sh \
+  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sh.sc ${GEN_DEPENDS}
+	${GENSCRIPTS} elf32shlunx "$(tdir_elf32shlunx)"
 esparcaout.c: $(srcdir)/emulparams/sparcaout.sh \
   $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
 	${GENSCRIPTS} sparcaout "$(tdir_sparcaout)"
diff -u -r -N -x *.orig -x CVS old/ld/Makefile.in binutils-2.9.1/ld/Makefile.in
--- ld/Makefile.in	Wed Jan  3 20:40:59 2001
+++ ld/Makefile.in	Wed Jan  3 20:49:38 2001
@@ -245,6 +245,10 @@
 	eshelf.o \
 	eshlelf.o \
 	eshl.o \
+	eshunx.o \
+	eshlunx.o \
+	eelf32shunx.o \
+	eelf32shlunx.o \
 	esparcaout.o \
 	esparclinux.o \
 	esparclynx.o \
@@ -998,6 +1002,18 @@
 eshl.c: $(srcdir)/emulparams/shl.sh \
   $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sh.sc ${GEN_DEPENDS}
 	${GENSCRIPTS} shl "$(tdir_shl)"
+eshunx.c: $(srcdir)/emulparams/shunx.sh \
+  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sh.sc ${GEN_DEPENDS}
+	${GENSCRIPTS} shunx "$(tdir_shunx)"
+eshlunx.c: $(srcdir)/emulparams/shlunx.sh \
+  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sh.sc ${GEN_DEPENDS}
+	${GENSCRIPTS} shlunx "$(tdir_shlunx)"
+eelf32shunx.c: $(srcdir)/emulparams/elf32shunx.sh \
+  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sh.sc ${GEN_DEPENDS}
+	${GENSCRIPTS} elf32shunx "$(tdir_elf32shunx)"
+eelf32shlunx.c: $(srcdir)/emulparams/elf32shlunx.sh \
+  $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sh.sc ${GEN_DEPENDS}
+	${GENSCRIPTS} elf32shlunx "$(tdir_elf32shlunx)"
 esparcaout.c: $(srcdir)/emulparams/sparcaout.sh \
   $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
 	${GENSCRIPTS} sparcaout "$(tdir_sparcaout)"
diff -u -r -N -x *.orig -x CVS old/ld/configure.tgt binutils-2.9.1/ld/configure.tgt
--- ld/configure.tgt	Wed Jan  3 20:41:00 2001
+++ ld/configure.tgt	Wed Jan  3 20:51:01 2001
@@ -114,8 +114,16 @@
 			targ_extra_emuls="h8500s h8500b h8500m h8500c"
 			;;
 sh-*-elf*)		targ_emul=shelf
-			targ_extra_emuls="shlelf sh shl"
+			targ_extra_emuls="shlelf shunx shlunx"
 			;;
+sh-*-netbsdelf)		targ_emul=elf32shunx
+			targ_extra_emuls="elf32shlunx shunx shlunx"
+			;;
+shel-*-netbsdelf)	targ_emul=elf32shlunx
+			targ_extra_emuls="elf32shunx shunx shlunx"
+			;;
+sh-*-netbsdcoff)	targ_emul=shunx; targ_extra_emuls=shlunx ;;
+shel-*-netbsdcoff)	targ_emul=shlunx; targ_extra_emuls=shunx ;;
 sh-*-*|sh-*-rtems*)	targ_emul=sh; targ_extra_emuls=shl ;;
 m68k-sony-*)		targ_emul=news ;;
 m68k-hp-bsd*)		targ_emul=hp300bsd ;;
diff -u -r -N -x *.orig -x CVS old/ld/emulparams/elf32shlunx.sh binutils-2.9.1/ld/emulparams/elf32shlunx.sh
--- ld/emulparams/elf32shlunx.sh	Thu Jan  1 09:00:00 1970
+++ ld/emulparams/elf32shlunx.sh	Wed Jan  3 20:51:16 2001
@@ -0,0 +1,15 @@
+SCRIPT_NAME=elf
+OUTPUT_FORMAT="elf32-shl-unx"
+TEXT_START_ADDR=0x1000
+MAXPAGESIZE=0x1000
+ARCH=sh
+MACHINE=
+TEMPLATE_NAME=elf32
+GENERATE_SHLIB_SCRIPT=yes
+
+# These are for compatibility with the COFF toolchain.
+ENTRY=start
+CTOR_START='___ctors = .;'
+CTOR_END='___ctors_end = .;'
+DTOR_START='___dtors = .;'
+DTOR_END='___dtors_end = .;'
diff -u -r -N -x *.orig -x CVS old/ld/emulparams/elf32shunx.sh binutils-2.9.1/ld/emulparams/elf32shunx.sh
--- ld/emulparams/elf32shunx.sh	Thu Jan  1 09:00:00 1970
+++ ld/emulparams/elf32shunx.sh	Wed Jan  3 20:51:33 2001
@@ -0,0 +1,15 @@
+SCRIPT_NAME=elf
+OUTPUT_FORMAT="elf32-sh-unx"
+TEXT_START_ADDR=0x1000
+MAXPAGESIZE=0x1000
+ARCH=sh
+MACHINE=
+TEMPLATE_NAME=elf32
+GENERATE_SHLIB_SCRIPT=yes
+
+# These are for compatibility with the COFF toolchain.
+ENTRY=start
+CTOR_START='___ctors = .;'
+CTOR_END='___ctors_end = .;'
+DTOR_START='___dtors = .;'
+DTOR_END='___dtors_end = .;'
diff -u -r -N -x *.orig -x CVS old/ld/emulparams/shlunx.sh binutils-2.9.1/ld/emulparams/shlunx.sh
--- ld/emulparams/shlunx.sh	Thu Jan  1 09:00:00 1970
+++ ld/emulparams/shlunx.sh	Wed Jan  3 20:51:54 2001
@@ -0,0 +1,5 @@
+SCRIPT_NAME=shunx
+OUTPUT_FORMAT="coff-shl"
+TEXT_START_ADDR=0x1000
+TARGET_PAGE_SIZE=0x1000
+ARCH=sh
diff -u -r -N -x *.orig -x CVS old/ld/emulparams/shunx.sh binutils-2.9.1/ld/emulparams/shunx.sh
--- ld/emulparams/shunx.sh	Thu Jan  1 09:00:00 1970
+++ ld/emulparams/shunx.sh	Wed Jan  3 20:52:04 2001
@@ -0,0 +1,5 @@
+SCRIPT_NAME=shunx
+OUTPUT_FORMAT="coff-sh"
+TEXT_START_ADDR=0x1000
+TARGET_PAGE_SIZE=0x1000
+ARCH=sh
diff -u -r -N -x *.orig -x CVS old/ld/scripttempl/shunx.sc binutils-2.9.1/ld/scripttempl/shunx.sc
--- ld/scripttempl/shunx.sc	Thu Jan  1 09:00:00 1970
+++ ld/scripttempl/shunx.sc	Wed Jan  3 20:52:24 2001
@@ -0,0 +1,53 @@
+TORS=".tors :
+  {
+    ___ctors = . ;
+    *(.ctors)
+    ___ctors_end = . ;
+    ___dtors = . ;
+    *(.dtors)
+    ___dtors_end = . ;
+  }"
+
+
+cat <<EOF
+OUTPUT_FORMAT("${OUTPUT_FORMAT}")
+OUTPUT_ARCH(${ARCH})
+${LIB_SEARCH_DIRS}
+
+SECTIONS
+{
+  . = ${TEXT_START_ADDR} + SIZEOF_HEADERS;
+  .text ALIGN(0x10):
+  {
+    *(.text)
+    *(.strings)
+    ${RELOCATING+ _etext = . ; }
+  }
+  ${CONSTRUCTING+${TORS}}
+  .data  ${RELOCATING+ ALIGN(${TARGET_PAGE_SIZE})} :
+  {
+    *(.data)
+    ${RELOCATING+ _edata = . ; }
+  }
+  .bss ${RELOCATING+ ALIGN(${TARGET_PAGE_SIZE})} :
+  {
+    ${RELOCATING+ _bss_start = . ; }
+    *(.bss)
+    *(COMMON)
+    ${RELOCATING+ _end = . ;  }
+  }
+  .stack :
+  {
+    ${RELOCATING+ _stack = . ; }
+    *(.stack)
+  }
+  .stab 0 ${RELOCATING+(NOLOAD)} :
+  {
+    *(.stab)
+  }
+  .stabstr 0 ${RELOCATING+(NOLOAD)} :
+  {
+    *(.stabstr)
+  }
+}
+EOF
