Subject: Re: The ELF ABI issue
To: None <port-arm@netbsd.org>
From: Jason R Thorpe <thorpej@wasabisystems.com>
List: port-arm
Date: 03/25/2002 20:31:10
--V0207lvV8h4k8FAm
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Mon, Mar 25, 2002 at 06:33:15PM -0800, Jason R Thorpe wrote:

 > Ok, didn't work -- so I did it a different way.  I'll test if first
 > before posting patches this time :-)

Ok, these work :-)

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>

--V0207lvV8h4k8FAm
Content-Type: text/plain; charset=us-ascii
Content-Description: elf32-arm-nbsd
Content-Disposition: attachment; filename=foo

Index: bfd/config.bfd
===================================================================
RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/bfd/config.bfd,v
retrieving revision 1.11
diff -u -r1.11 config.bfd
--- bfd/config.bfd	2001/12/15 02:18:24	1.11
+++ bfd/config.bfd	2002/03/26 04:17:01
@@ -105,8 +105,8 @@
     ;;
 
   arm-*-netbsdelf*)
-    targ_defvec=bfd_elf32_littlearm_vec
-    targ_selvecs=armnetbsd_vec
+    targ_defvec=bfd_elf32_littlearm_nbsd_vec
+    targ_selvecs="bfd_elf32_littlearm_vec bfd_elf32_bigarm_vec bfd_elf32_bigarm_nbsd_vec armnetbsd_vec"
     ;;
   arm-*-netbsd*)
     targ_defvec=armnetbsd_vec
Index: bfd/configure
===================================================================
RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/bfd/configure,v
retrieving revision 1.14
diff -u -r1.14 configure
--- bfd/configure	2001/12/19 21:32:49	1.14
+++ bfd/configure	2002/03/26 04:17:10
@@ -5930,10 +5930,12 @@
     bfd_elf32_ia64_big_vec)	tb="$tb elf32-ia64.lo elf32.lo $elf" ;;
     bfd_elf32_avr_vec)		tb="$tb elf32-avr.lo elf32.lo $elf" ;;
     bfd_elf32_littlearc_vec)	tb="$tb elf32-arc.lo elf32.lo $elf" ;;
-    bfd_elf32_littlearm_vec)	tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
+    bfd_elf32_littlearm_vec | bfd_elf32_littlearm_nbsd_vec)
+				tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
     bfd_elf32_littlearm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
     bfd_elf32_bigarc_vec)	tb="$tb elf32-arc.lo elf32.lo $elf" ;;
-    bfd_elf32_bigarm_vec)	tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
+    bfd_elf32_bigarm_vec | bfd_elf32_bigarm_nbsd_vec)
+				tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
     bfd_elf32_bigarm_oabi_vec)	tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
     bfd_elf32_big_generic_vec) 	tb="$tb elf32-gen.lo elf32.lo $elf" ;;
     bfd_elf32_bigmips_vec) 	tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
Index: bfd/configure.in
===================================================================
RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/bfd/configure.in,v
retrieving revision 1.13
diff -u -r1.13 configure.in
--- bfd/configure.in	2002/02/26 18:38:38	1.13
+++ bfd/configure.in	2002/03/26 04:17:11
@@ -503,10 +503,12 @@
     bfd_elf32_ia64_big_vec)	tb="$tb elf32-ia64.lo elf32.lo $elf" ;;
     bfd_elf32_avr_vec)		tb="$tb elf32-avr.lo elf32.lo $elf" ;;
     bfd_elf32_littlearc_vec)	tb="$tb elf32-arc.lo elf32.lo $elf" ;;
-    bfd_elf32_littlearm_vec)	tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
+    bfd_elf32_littlearm_vec | bfd_elf32_littlearm_nbsd_vec)
+				tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
     bfd_elf32_littlearm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
     bfd_elf32_bigarc_vec)	tb="$tb elf32-arc.lo elf32.lo $elf" ;;
-    bfd_elf32_bigarm_vec)	tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
+    bfd_elf32_bigarm_vec | bfd_elf32_bigarm_nbsd_vec)
+    				tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
     bfd_elf32_bigarm_oabi_vec)	tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
     bfd_elf32_big_generic_vec) 	tb="$tb elf32-gen.lo elf32.lo $elf" ;;
     bfd_elf32_bigmips_vec) 	tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
Index: bfd/elf32-arm.h
===================================================================
RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/bfd/elf32-arm.h,v
retrieving revision 1.3
diff -u -r1.3 elf32-arm.h
--- bfd/elf32-arm.h	2001/08/14 04:43:06	1.3
+++ bfd/elf32-arm.h	2002/03/26 04:17:15
@@ -3399,6 +3399,16 @@
 
   i_ehdrp = elf_elfheader (abfd);
 
+#ifdef ARM_ELF_OS_ABI_VERSION_NBSD
+  if (strcmp (bfd_get_target (abfd), "elf32-littlearm-nbsd") == 0
+   || strcmp (bfd_get_target (abfd), "elf32-bigarm-nbsd") == 0)
+    {
+      i_ehdrp->e_ident[EI_OSABI]      = ARM_ELF_OS_ABI_VERSION_NBSD;
+      i_ehdrp->e_ident[EI_ABIVERSION] = ARM_ELF_ABI_VERSION_NBSD;
+      return;
+    }
+#endif
+
   i_ehdrp->e_ident[EI_OSABI]      = ARM_ELF_OS_ABI_VERSION;
   i_ehdrp->e_ident[EI_ABIVERSION] = ARM_ELF_ABI_VERSION;
 }
Index: bfd/elfarm-nabi.c
===================================================================
RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/bfd/elfarm-nabi.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 elfarm-nabi.c
--- bfd/elfarm-nabi.c	2001/08/14 02:50:04	1.1.1.3
+++ bfd/elfarm-nabi.c	2002/03/26 04:17:15
@@ -29,17 +29,15 @@
 
 #define USE_REL
 
-#define TARGET_LITTLE_SYM               bfd_elf32_littlearm_vec
-#define TARGET_LITTLE_NAME              "elf32-littlearm"
-#define TARGET_BIG_SYM                  bfd_elf32_bigarm_vec
-#define TARGET_BIG_NAME                 "elf32-bigarm"
-
 #define elf_info_to_howto               0
 #define elf_info_to_howto_rel           elf32_arm_info_to_howto
 
 #define ARM_ELF_ABI_VERSION		0
 #define ARM_ELF_OS_ABI_VERSION		ELFOSABI_ARM
 
+#define ARM_ELF_ABI_VERSION_NBSD	0
+#define ARM_ELF_OS_ABI_VERSION_NBSD	ELFOSABI_NETBSD
+
 static reloc_howto_type * elf32_arm_reloc_type_lookup
   PARAMS ((bfd * abfd, bfd_reloc_code_real_type code));
 
@@ -674,4 +672,23 @@
    }
 }
 
+#define TARGET_LITTLE_SYM               bfd_elf32_littlearm_vec
+#define TARGET_LITTLE_NAME              "elf32-littlearm"
+#define TARGET_BIG_SYM                  bfd_elf32_bigarm_vec
+#define TARGET_BIG_NAME                 "elf32-bigarm"
+
 #include "elf32-arm.h"
+
+#define INCLUDED_TARGET_FILE 1
+
+#undef TARGET_LITTLE_SYM
+#undef TARGET_LITTLE_NAME
+#undef TARGET_BIG_SYM
+#undef TARGET_BIG_NAME
+
+#define TARGET_LITTLE_SYM               bfd_elf32_littlearm_nbsd_vec
+#define TARGET_LITTLE_NAME              "elf32-littlearm-nbsd"
+#define TARGET_BIG_SYM                  bfd_elf32_bigarm_nbsd_vec
+#define TARGET_BIG_NAME                 "elf32-bigarm-nbsd"
+
+#include "elf32-target.h"
Index: bfd/targets.c
===================================================================
RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/bfd/targets.c,v
retrieving revision 1.8
diff -u -r1.8 targets.c
--- bfd/targets.c	2001/12/24 01:55:32	1.8
+++ bfd/targets.c	2002/03/26 04:17:17
@@ -512,6 +512,7 @@
 extern const bfd_target bfd_elf32_bigarc_vec;
 extern const bfd_target bfd_elf32_bigarm_oabi_vec;
 extern const bfd_target bfd_elf32_bigarm_vec;
+extern const bfd_target bfd_elf32_bigarm_nbsd_vec;
 extern const bfd_target bfd_elf32_bigmips_vec;
 extern const bfd_target bfd_elf32_cris_vec;
 extern const bfd_target bfd_elf32_d10v_vec;
@@ -529,6 +530,7 @@
 extern const bfd_target bfd_elf32_littlearc_vec;
 extern const bfd_target bfd_elf32_littlearm_oabi_vec;
 extern const bfd_target bfd_elf32_littlearm_vec;
+extern const bfd_target bfd_elf32_littlearm_nbsd_vec;
 extern const bfd_target bfd_elf32_littlemips_vec;
 extern const bfd_target bfd_elf32_m32r_vec;
 extern const bfd_target bfd_elf32_m68hc11_vec;
@@ -736,6 +738,7 @@
 	&bfd_elf32_avr_vec,
 	&bfd_elf32_bigarc_vec,
         &bfd_elf32_bigarm_vec,
+        &bfd_elf32_bigarm_nbsd_vec,
         &bfd_elf32_bigarm_oabi_vec,
 	&bfd_elf32_bigmips_vec,
 #ifdef BFD64
@@ -758,6 +761,7 @@
 	&bfd_elf32_little_generic_vec,
 	&bfd_elf32_littlearc_vec,
         &bfd_elf32_littlearm_vec,
+        &bfd_elf32_littlearm_nbsd_vec,
         &bfd_elf32_littlearm_oabi_vec,
 	&bfd_elf32_littlemips_vec,
 #ifdef BFD64
Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/gas/config/tc-arm.c,v
retrieving revision 1.10
diff -u -r1.10 tc-arm.c
--- gas/config/tc-arm.c	2001/08/14 04:43:09	1.10
+++ gas/config/tc-arm.c	2002/03/26 04:17:25
@@ -8959,14 +8959,22 @@
       if (target_oabi)
 	return "elf32-bigarm-oabi";
       else
+#ifdef TE_NetBSD
+	return "elf32-bigarm-nbsd";
+#else
 	return "elf32-bigarm";
+#endif
     }
   else
     {
       if (target_oabi)
 	return "elf32-littlearm-oabi";
       else
+#ifdef TE_NetBSD
+	return "elf32-littlearm-nbsd";
+#else
 	return "elf32-littlearm";
+#endif
     }
 }
 
Index: ld/emulparams/armelf_nbsd.sh
===================================================================
RCS file: /cvsroot/gnusrc/gnu/dist/toolchain/ld/emulparams/armelf_nbsd.sh,v
retrieving revision 1.1
diff -u -r1.1 armelf_nbsd.sh
--- ld/emulparams/armelf_nbsd.sh	2001/05/03 17:28:47	1.1
+++ ld/emulparams/armelf_nbsd.sh	2002/03/26 04:17:33
@@ -1,8 +1,8 @@
 ARCH=arm
 SCRIPT_NAME=elf
-OUTPUT_FORMAT="elf32-littlearm"
-BIG_OUTPUT_FORMAT="elf32-bigarm"
-LITTLE_OUTPUT_FORMAT="elf32-littlearm"
+OUTPUT_FORMAT="elf32-littlearm-nbsd"
+BIG_OUTPUT_FORMAT="elf32-bigarm-nbsd"
+LITTLE_OUTPUT_FORMAT="elf32-littlearm-nbsd"
 MAXPAGESIZE=0x8000
 TEMPLATE_NAME=elf32
 EXTRA_EM_FILE=armelf

--V0207lvV8h4k8FAm--