[patch] BFD support for OpenRISC

Johan Rydberg johan.rydberg@netinsight.se
Sun Jan 7 10:57:00 GMT 2001


Andreas Jaeger wrote:

> [...]

*DOH*

It seems that I attached the wrong patch.  I'm SO, SO sorry for this.
Well, here's the correct one!

Regards,
Johan.
Index: bfd/ChangeLog
===================================================================
RCS file: /cvs/src/src/bfd/ChangeLog,v
retrieving revision 1.725
diff -u -r1.725 ChangeLog
--- ChangeLog	2001/01/07 14:53:57	1.725
+++ ChangeLog	2001/01/07 18:20:31
@@ -1,3 +1,27 @@
+2001-01-07  Johan Rydberg  <jrydberg@opencores.org>
+
+	* elf.c (prep_headers): Add bfd_arch_openrisc.
+
+        * archures.c (bfd_architecture): Add bfd_arch_openrisc.
+	(bfd_mach_or1300): New constant.
+	(bfd_archures_list): Add bfd_openrisc_arch.
+	* targets.c (bfd_target_vector): Add bfd_elf32_openrisc_vec.
+	* reloc.c (bfd_reloc_code_type): Add OpenRISC relocations.  
+	* bfd-in2.h: Regenerated.
+	* libbfd.h: Likewise.
+
+	* Makefile.am (ALL_MACHINES): Add cpu-openrisc.lo.
+	(ALL_MACHINES_CFILES): Add cpu-openrisc.c.
+	(BFD32_BACKENDS): Add elf32-openrisc.lo.
+	(BFD32_BACKENDS_CFILES): Add elf32-openrisc.c.
+	(cpu-openrisc.lo): New dependency.
+	(elf32-openrisc.lo): New dependency.
+	* Makefile.in: Regenerated.
+	
+	* configure.in: Add support for bfd_elf32_openrisc_vec.
+	* config.bfd (openrisc-*-elf): New target.
+	* configure: Regenerated.
+	
 2001-01-07  Philip Blundell  <philb@gnu.org>
 
 	* README: Replace `bug-gnu-utils@gnu.org' with
Index: bfd/Makefile.am
===================================================================
RCS file: /cvs/src/src/bfd/Makefile.am,v
retrieving revision 1.43
diff -u -r1.43 Makefile.am
--- Makefile.am	2000/12/08 22:50:07	1.43
+++ Makefile.am	2001/01/07 18:20:31
@@ -69,6 +69,7 @@
 	cpu-mcore.lo \
 	cpu-mips.lo \
 	cpu-ns32k.lo \
+	cpu-openrisc.lo \
 	cpu-pj.lo \
 	cpu-powerpc.lo \
 	cpu-rs6000.lo \
@@ -111,6 +112,7 @@
 	cpu-mcore.c \
 	cpu-mips.c \
 	cpu-ns32k.c \
+	cpu-openrisc.c \
 	cpu-pj.c \
 	cpu-powerpc.c \
 	cpu-rs6000.c \
@@ -197,6 +199,7 @@
 	elf-m10300.lo \
 	elf32-mcore.lo \
 	elf32-mips.lo \
+	elf32-openrisc.lo \
 	elf32-pj.lo \
 	elf32-ppc.lo \
 	elf32-sh.lo \
@@ -334,6 +337,7 @@
 	elf-m10300.c \
 	elf32-mcore.c \
 	elf32-mips.c \
+	elf32-openrisc.c \
 	elf32-pj.c \
 	elf32-ppc.c \
 	elf32-sh.c \
@@ -764,6 +768,7 @@
 cpu-mcore.lo: cpu-mcore.c $(INCDIR)/filenames.h
 cpu-mips.lo: cpu-mips.c $(INCDIR)/filenames.h
 cpu-ns32k.lo: cpu-ns32k.c $(INCDIR)/filenames.h ns32k.h
+cpu-openrisc.lo: cpu-openrisc.c $(INCDIR)/filenames.h
 cpu-pj.lo: cpu-pj.c $(INCDIR)/filenames.h
 cpu-powerpc.lo: cpu-powerpc.c $(INCDIR)/filenames.h
 cpu-rs6000.lo: cpu-rs6000.c $(INCDIR)/filenames.h
@@ -1016,6 +1021,10 @@
   $(INCDIR)/elf/external.h $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h \
   $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \
   $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h ecoffswap.h \
+  elf32-target.h
+elf32-openrisc.lo: elf32-openrisc.c $(INCDIR)/filenames.h elf-bfd.h \
+  $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+  $(INCDIR)/bfdlink.h $(INCDIR)/elf/openrisc.h $(INCDIR)/elf/reloc-macros.h \
   elf32-target.h
 elf32-pj.lo: elf32-pj.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
Index: bfd/Makefile.in
===================================================================
RCS file: /cvs/src/src/bfd/Makefile.in,v
retrieving revision 1.50
diff -u -r1.50 Makefile.in
--- Makefile.in	2000/12/08 22:50:07	1.50
+++ Makefile.in	2001/01/07 18:20:31
@@ -190,6 +190,7 @@
 	cpu-mcore.lo \
 	cpu-mips.lo \
 	cpu-ns32k.lo \
+	cpu-openrisc.lo \
 	cpu-pj.lo \
 	cpu-powerpc.lo \
 	cpu-rs6000.lo \
@@ -233,6 +234,7 @@
 	cpu-mcore.c \
 	cpu-mips.c \
 	cpu-ns32k.c \
+	cpu-openrisc.c \
 	cpu-pj.c \
 	cpu-powerpc.c \
 	cpu-rs6000.c \
@@ -320,6 +322,7 @@
 	elf-m10300.lo \
 	elf32-mcore.lo \
 	elf32-mips.lo \
+	elf32-openrisc.lo \
 	elf32-pj.lo \
 	elf32-ppc.lo \
 	elf32-sh.lo \
@@ -458,6 +461,7 @@
 	elf-m10300.c \
 	elf32-mcore.c \
 	elf32-mips.c \
+	elf32-openrisc.c \
 	elf32-pj.c \
 	elf32-ppc.c \
 	elf32-sh.c \
@@ -1304,6 +1308,7 @@
 cpu-mcore.lo: cpu-mcore.c $(INCDIR)/filenames.h
 cpu-mips.lo: cpu-mips.c $(INCDIR)/filenames.h
 cpu-ns32k.lo: cpu-ns32k.c $(INCDIR)/filenames.h ns32k.h
+cpu-openrisc.lo: cpu-openrisc.c $(INCDIR)/filenames.h
 cpu-pj.lo: cpu-pj.c $(INCDIR)/filenames.h
 cpu-powerpc.lo: cpu-powerpc.c $(INCDIR)/filenames.h
 cpu-rs6000.lo: cpu-rs6000.c $(INCDIR)/filenames.h
@@ -1556,6 +1561,10 @@
   $(INCDIR)/elf/external.h $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h \
   $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \
   $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h ecoffswap.h \
+  elf32-target.h
+elf32-openrisc.lo: elf32-openrisc.c $(INCDIR)/filenames.h elf-bfd.h \
+  $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
+  $(INCDIR)/bfdlink.h $(INCDIR)/elf/openrisc.h $(INCDIR)/elf/reloc-macros.h \
   elf32-target.h
 elf32-pj.lo: elf32-pj.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
   elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
Index: bfd/archures.c
===================================================================
RCS file: /cvs/src/src/bfd/archures.c,v
retrieving revision 1.29
diff -u -r1.29 archures.c
--- archures.c	2000/12/02 01:10:31	1.29
+++ archures.c	2001/01/07 18:20:31
@@ -245,6 +245,8 @@
 .#define bfd_mach_avr4		4
 .#define bfd_mach_avr5		5
 .  bfd_arch_cris,      {* Axis CRIS *}
+.  bfd_arch_openrisc,  {* OpenRISC CPU family *}
+.#define bfd_mach_or1300  1
 .  bfd_arch_last
 .  };
 */
@@ -320,6 +322,7 @@
 extern const bfd_arch_info_type bfd_mcore_arch;
 extern const bfd_arch_info_type bfd_avr_arch;
 extern const bfd_arch_info_type bfd_ia64_arch;
+extern const bfd_arch_info_type bfd_openrisc_arch;
 
 static const bfd_arch_info_type * const bfd_archures_list[] = {
 #ifdef SELECT_ARCHITECTURES
@@ -364,6 +367,7 @@
   &bfd_mcore_arch,
   &bfd_avr_arch,
   &bfd_ia64_arch,
+  &bfd_openrisc_arch,
 #endif
   0
 };
Index: bfd/bfd-in2.h
===================================================================
RCS file: /cvs/src/src/bfd/bfd-in2.h,v
retrieving revision 1.81
diff -u -r1.81 bfd-in2.h
--- bfd-in2.h	2000/12/21 18:20:04	1.81
+++ bfd-in2.h	2001/01/07 18:20:31
@@ -813,13 +813,13 @@
 /* Byte swapping macros for user section data.  */
 
 #define bfd_put_8(abfd, val, ptr) \
-                ((void) (*((unsigned char *)(ptr)) = (unsigned char)(val)))
+                ((void) (*((unsigned char *) (ptr)) = (unsigned char) (val)))
 #define bfd_put_signed_8 \
                bfd_put_8
 #define bfd_get_8(abfd, ptr) \
-                (*(unsigned char *)(ptr))
+                (*(unsigned char *) (ptr))
 #define bfd_get_signed_8(abfd, ptr) \
-               ((*(unsigned char *)(ptr) ^ 0x80) - 0x80)
+               ((*(unsigned char *) (ptr) ^ 0x80) - 0x80)
 
 #define bfd_put_16(abfd, val, ptr) \
                 BFD_SEND(abfd, bfd_putx16, ((val),(ptr)))
@@ -1518,6 +1518,8 @@
 #define bfd_mach_avr4          4
 #define bfd_mach_avr5          5
   bfd_arch_cris,      /* Axis CRIS */
+  bfd_arch_openrisc,  /* OpenRISC CPU family */
+#define bfd_mach_or1300  1
   bfd_arch_last
   };
 
@@ -2407,13 +2409,13 @@
 /* This is an extended address 23-bit reloc for the tms320c54x. */
   BFD_RELOC_TIC54X_23,
 
-/* This is a 16-bit reloc for the tms320c54x, where the least 
-significant 16 bits of a 23-bit extended address are placed into 
+/* This is a 16-bit reloc for the tms320c54x, where the least
+significant 16 bits of a 23-bit extended address are placed into
 the opcode. */
   BFD_RELOC_TIC54X_16_OF_23,
 
 /* This is a reloc for the tms320c54x, where the most
-significant 7 bits of a 23-bit extended address are placed into 
+significant 7 bits of a 23-bit extended address are placed into
 the opcode. */
   BFD_RELOC_TIC54X_MS7_OF_23,
 
@@ -2663,6 +2665,10 @@
   BFD_RELOC_860_HIGH,
   BFD_RELOC_860_HIGOT,
   BFD_RELOC_860_HIGOTOFF,
+
+/* OpenRISC Relocations. */
+  BFD_RELOC_OPENRISC_ABS_26,
+  BFD_RELOC_OPENRISC_REL_26,
   BFD_RELOC_UNUSED };
 typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
 reloc_howto_type *
Index: bfd/config.bfd
===================================================================
RCS file: /cvs/src/src/bfd/config.bfd,v
retrieving revision 1.47
diff -u -r1.47 config.bfd
--- config.bfd	2000/12/01 18:37:16	1.47
+++ config.bfd	2001/01/07 18:20:32
@@ -50,6 +50,7 @@
 sparc*) targ_archs=bfd_sparc_arch ;;
 v850*)	targ_archs=bfd_v850_arch ;;
 z8k*)	targ_archs=bfd_z8k_arch ;;
+openrisc*) targ_archs=bfd_openrisc_arch ;;
 *)	targ_archs=bfd_${targ_cpu}_arch ;;
 esac
 
@@ -670,6 +671,10 @@
   ns32k-*-netbsd* | ns32k-*-lites* | ns32k-*-openbsd*)
     targ_defvec=pc532netbsd_vec
     targ_underscore=yes
+    ;;
+
+  openrisc-*-elf)
+    targ_defvec=bfd_elf32_openrisc_vec
     ;;
 
   pj-*-*)
Index: bfd/configure
===================================================================
RCS file: /cvs/src/src/bfd/configure,v
retrieving revision 1.51
diff -u -r1.51 configure
--- configure	2000/12/08 22:50:07	1.51
+++ configure	2001/01/07 18:20:32
@@ -5975,6 +5975,7 @@
     bfd_elf32_mcore_little_vec)	tb="$tb elf32-mcore.lo elf32.lo $elf" ;;
     bfd_elf32_mn10200_vec)	tb="$tb elf-m10200.lo elf32.lo $elf" ;;
     bfd_elf32_mn10300_vec)	tb="$tb elf-m10300.lo elf32.lo $elf" ;;
+    bfd_elf32_openrisc_vec)		tb="$tb elf32-openrisc.lo elf32.lo $elf" ;;
     bfd_elf32_pj_vec)           tb="$tb elf32-pj.lo elf32.lo $elf";;
     bfd_elf32_pjl_vec)          tb="$tb elf32-pj.lo elf32.lo $elf";;
     bfd_elf32_powerpc_vec)	tb="$tb elf32-ppc.lo elf32.lo $elf" ;;
@@ -6176,17 +6177,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:6180: checking for $ac_hdr" >&5
+echo "configure:6181: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6185 "configure"
+#line 6186 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6190: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6191: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -6215,12 +6216,12 @@
 for ac_func in getpagesize
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6219: checking for $ac_func" >&5
+echo "configure:6220: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6224 "configure"
+#line 6225 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6243,7 +6244,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6247: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6248: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -6268,7 +6269,7 @@
 done
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:6272: checking for working mmap" >&5
+echo "configure:6273: checking for working mmap" >&5
 if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6276,7 +6277,7 @@
   ac_cv_func_mmap_fixed_mapped=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 6280 "configure"
+#line 6281 "configure"
 #include "confdefs.h"
 
 /* Thanks to Mike Haertel and Jim Avera for this test.
@@ -6416,7 +6417,7 @@
 }
 
 EOF
-if { (eval echo configure:6420: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6421: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_mmap_fixed_mapped=yes
 else
@@ -6441,12 +6442,12 @@
 for ac_func in madvise mprotect
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6445: checking for $ac_func" >&5
+echo "configure:6446: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6450 "configure"
+#line 6451 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6469,7 +6470,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6473: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6474: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
Index: bfd/configure.in
===================================================================
RCS file: /cvs/src/src/bfd/configure.in,v
retrieving revision 1.38
diff -u -r1.38 configure.in
--- configure.in	2000/12/08 22:50:07	1.38
+++ configure.in	2001/01/07 18:20:32
@@ -524,6 +524,7 @@
     bfd_elf32_mcore_little_vec)	tb="$tb elf32-mcore.lo elf32.lo $elf" ;;
     bfd_elf32_mn10200_vec)	tb="$tb elf-m10200.lo elf32.lo $elf" ;;
     bfd_elf32_mn10300_vec)	tb="$tb elf-m10300.lo elf32.lo $elf" ;;
+    bfd_elf32_openrisc_vec)		tb="$tb elf32-openrisc.lo elf32.lo $elf" ;;
     bfd_elf32_pj_vec)           tb="$tb elf32-pj.lo elf32.lo $elf";;
     bfd_elf32_pjl_vec)          tb="$tb elf32-pj.lo elf32.lo $elf";;
     bfd_elf32_powerpc_vec)	tb="$tb elf32-ppc.lo elf32.lo $elf" ;;
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.61
diff -u -r1.61 elf.c
--- elf.c	2000/12/12 19:23:15	1.61
+++ elf.c	2001/01/07 18:20:33
@@ -3356,6 +3356,9 @@
     case bfd_arch_fr30:
       i_ehdrp->e_machine = EM_CYGNUS_FR30;
       break;
+    case bfd_arch_openrisc:
+      i_ehdrp->e_machine = EM_OPENRISC;
+      break;
     case bfd_arch_mcore:
       i_ehdrp->e_machine = EM_MCORE;
       break;
Index: bfd/libbfd.h
===================================================================
RCS file: /cvs/src/src/bfd/libbfd.h,v
retrieving revision 1.30
diff -u -r1.30 libbfd.h
--- libbfd.h	2000/12/08 22:50:07	1.30
+++ libbfd.h	2001/01/07 18:20:33
@@ -1016,6 +1016,8 @@
   "BFD_RELOC_860_HIGH",
   "BFD_RELOC_860_HIGOT",
   "BFD_RELOC_860_HIGOTOFF",
+  "BFD_RELOC_OPENRISC_ABS_26",
+  "BFD_RELOC_OPENRISC_REL_26",
  "@@overflow: BFD_RELOC_UNUSED@@",
 };
 #endif
Index: bfd/reloc.c
===================================================================
RCS file: /cvs/src/src/bfd/reloc.c,v
retrieving revision 1.33
diff -u -r1.33 reloc.c
--- reloc.c	2001/01/01 21:37:35	1.33
+++ reloc.c	2001/01/07 18:20:33
@@ -2986,6 +2986,13 @@
 ENUMDOC
   Intel i860 Relocations.
 
+ENUM
+  BFD_RELOC_OPENRISC_ABS_26
+ENUMX
+  BFD_RELOC_OPENRISC_REL_26
+ENUMDOC
+  OpenRISC Relocations.
+
 ENDSENUM
   BFD_RELOC_UNUSED
 CODE_FRAGMENT
Index: bfd/targets.c
===================================================================
RCS file: /cvs/src/src/bfd/targets.c,v
retrieving revision 1.31
diff -u -r1.31 targets.c
--- targets.c	2000/12/20 19:53:10	1.31
+++ targets.c	2001/01/07 18:20:33
@@ -541,6 +541,7 @@
 extern const bfd_target bfd_elf32_m88k_vec;
 extern const bfd_target bfd_elf32_mn10200_vec;
 extern const bfd_target bfd_elf32_mn10300_vec;
+extern const bfd_target bfd_elf32_openrisc_vec;
 extern const bfd_target bfd_elf32_pj_vec;
 extern const bfd_target bfd_elf32_pjl_vec;
 extern const bfd_target bfd_elf32_powerpc_vec;
@@ -759,6 +760,7 @@
 	&bfd_elf32_m68k_vec,
 	&bfd_elf32_m88k_vec,
 	&bfd_elf32_sparc_vec,
+	&bfd_elf32_openrisc_vec,
 	&bfd_elf32_pj_vec,
 	&bfd_elf32_pjl_vec,
 	&bfd_elf32_powerpc_vec,
Index: include/elf/ChangeLog
===================================================================
RCS file: /cvs/src/src/include/elf/ChangeLog,v
retrieving revision 1.80
diff -u -r1.80 ChangeLog
--- ChangeLog	2000/12/12 19:25:07	1.80
+++ ChangeLog	2001/01/07 18:20:34
@@ -1,3 +1,8 @@
+2001-01-06  Johan Rydberg  <jrydberg@opencores.org>
+
+	* openrisc.h: New file.
+	* common.h (EM_OPENRISC): New definition.
+
 2000-12-12  Nick Clifton  <nickc@redhat.com>
 
 	* mips.h: Fix formatting.
Index: include/elf/common.h
===================================================================
RCS file: /cvs/src/src/include/elf/common.h,v
retrieving revision 1.27
diff -u -r1.27 common.h
--- common.h	2000/11/30 19:05:18	1.27
+++ common.h	2001/01/07 18:20:34
@@ -216,6 +216,9 @@
    Written in the absense of an ABI.  */
 #define EM_AVR			0x1057
 
+/* OpenRISC backend magic number.  Written in absense of an ABI.  */
+#define EM_OPENRISC 0xde02
+
 /* See the above comment before you add a new EM_* value here.  */
 
 /* Values for e_version.  */


More information about the Binutils mailing list