[Patch 1/8]: 68HC11 port of Binutils (bfd)

Stephane Carrez Stephane.Carrez@worldnet.fr
Fri Jun 16 14:46:00 GMT 2000


Hi!

Here are the Binutils patches. I've split them in 8 parts corresponding
to the various binutils directories:

  [1] - bfd
  [2] - include + include/elf + include/opcodes
  [3] - opcodes
  [4] - ld
  [5] - binutils/testsuite
  [6] - gas
  [7] - gas/doc
  [8] - gas/testsuite/gas/m68k, gas/testsuite/gas/m68hc11

I still need to do a patch to the top level configure (config.sub
and configure.in), but I'm not sure if binutils is the good place.

New files should follow the GNU coding standard as I've indented
them with indent (-gnu mode). Except for the opcodes table for
which I prefer keep the current readable indentation.

Can you take some time to integrate these patches?

Thanks a lot,

	Stephane


This patch corresponds to the support for 68HC11 and 68HC12 in bfd
library (only binutils/bfd directory, includes will follow).

The diffs do not include the generated files. I assume you will
re-generate them (list on first line of changelog).

The diffs are against CVS 2000-06-15.


ChangeLog for binutils/bfd

2000-06-16  Stephane Carrez  <stcarrez@worldnet.fr>

	* Makefile.in, bfd-in2.h, libbfd.h, configure: Rebuild.
	* Makefile.am (ALL_MACHINES, ALL_MACHINES_CFILES, BFD32_BACKENDS,
	BFD32_BACKENDS_CFILES): Add 68hc12, 68hc11 files.
	* configure.in (bfd_elf32_m68hc12_vec): Recognize.
	(bfd_elf32_m68hc11_vec): Likewise.
	* config.bfd (targ_cpu): Recognize 68hc12 and 68hc11. 
	Supports 68hc11 & 68hc12  at the same time.
	* targets.c (bfd_elf32_m68hc12_vec): Declare and put in
	bfd_target_vector.
	(bfd_elf32_m68hc11_vec): Likewise.
	* elf.c (prep_headers): Recognize bfd_arch_m68hc12 and 68hc11.
	* archures.c (bfd_m68hc12_arch): Define and register in global list
	(bfd_m68hc11_arch): Likewise.
	* reloc.c (BFD_RELOC_M68HC11_HI8, BFD_RELOC_M68HC11_LO8,
	BFD_RELOC_M68HC11_3B): Define.
	* cpu-m68hc12.c, elf32-m68hc12.c: New files for 68hc12 support.
	* cpu-m68hc11.c, elf32-m68hc11.c: New files for 68hc11 support.
diff -Nrup --exclude-from=binutils-exclude.lst /src/gnu/cygnus/binutils/bfd/Makefile.am binutils/bfd/Makefile.am
--- /src/gnu/cygnus/binutils/bfd/Makefile.am	Sun Jun 11 00:15:07 2000
+++ binutils/bfd/Makefile.am	Fri Jun 16 00:23:48 2000
@@ -57,6 +57,8 @@ ALL_MACHINES = \
 	cpu-i860.lo \
 	cpu-i960.lo \
 	cpu-m32r.lo \
+	cpu-m68hc11.lo \
+	cpu-m68hc12.lo \
 	cpu-m68k.lo \
 	cpu-m88k.lo \
 	cpu-m10200.lo \
@@ -96,6 +98,8 @@ ALL_MACHINES_CFILES = \
 	cpu-i860.c \
 	cpu-i960.c \
 	cpu-m32r.c \
+	cpu-m68hc11.c \
+	cpu-m68hc12.c \
 	cpu-m68k.c \
 	cpu-m88k.c \
 	cpu-m10200.c \
@@ -179,6 +183,8 @@ BFD32_BACKENDS = \
 	elf32-i860.lo \
 	elf32-i960.lo \
 	elf32-m32r.lo \
+	elf32-m68hc11.lo \
+	elf32-m68hc12.lo \
 	elf32-m68k.lo \
 	elf32-m88k.lo \
 	elf-m10200.lo \
@@ -313,6 +319,8 @@ BFD32_BACKENDS_CFILES = \
 	elf32-i960.c \
 	elf32-m32r.c \
 	elf32-m68k.c \
+	elf32-m68hc11.c \
+	elf32-m68hc12.c \
 	elf32-m88k.c \
 	elf-m10200.c \
 	elf-m10300.c \
@@ -721,6 +729,8 @@ cpu-i860.lo: cpu-i860.c $(INCDIR)/filena
 cpu-i960.lo: cpu-i960.c $(INCDIR)/filenames.h
 cpu-m32r.lo: cpu-m32r.c $(INCDIR)/filenames.h
 cpu-m68k.lo: cpu-m68k.c $(INCDIR)/filenames.h
+cpu-m68hc11.lo: cpu-m68hc11.c $(INCDIR)/filenames.h
+cpu-m68hc12.lo: cpu-m68hc12.c $(INCDIR)/filenames.h
 cpu-m88k.lo: cpu-m88k.c $(INCDIR)/filenames.h
 cpu-m10200.lo: cpu-m10200.c $(INCDIR)/filenames.h
 cpu-m10300.lo: cpu-m10300.c $(INCDIR)/filenames.h
@@ -913,6 +923,10 @@ elf32-fr30.lo: elf32-fr30.c $(INCDIR)/fi
 elf32-gen.lo: elf32-gen.c $(INCDIR)/filenames.h elf-bfd.h \
   $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
   $(INCDIR)/bfdlink.h elf32-target.h
+elf32-m68hc11.lo: elf32-m68hc11.c $(INCDIR)/bfdlink.h elf-bfd.h \
+  $(INCDIR)/elf/m68hc11.h elf32-target.h
+elf32-m68hc12.lo: elf32-m68hc12.c $(INCDIR)/bfdlink.h elf-bfd.h \
+  $(INCDIR)/elf/m68hc11.h elf32-target.h
 elf32-hppa.lo: elf32-hppa.c $(INCDIR)/filenames.h elf-bfd.h \
   $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \
   $(INCDIR)/bfdlink.h $(INCDIR)/elf/hppa.h $(INCDIR)/elf/reloc-macros.h \
diff -Nrup --exclude-from=binutils-exclude.lst /src/gnu/cygnus/binutils/bfd/archures.c binutils/bfd/archures.c
--- /src/gnu/cygnus/binutils/bfd/archures.c	Wed Apr 26 20:56:43 2000
+++ binutils/bfd/archures.c	Sat Apr 29 21:42:54 2000
@@ -153,6 +153,8 @@ DESCRIPTION
 .#define bfd_mach_d10v_ts2	2
 .#define bfd_mach_d10v_ts3	3
 .  bfd_arch_d30v,      {* Mitsubishi D30V *}
+.  bfd_arch_m68hc11,   {* Motorola 68HC11 *}
+.  bfd_arch_m68hc12,   {* Motorola 68HC12 *}
 .  bfd_arch_z8k,       {* Zilog Z8000 *}
 .#define bfd_mach_z8001		1
 .#define bfd_mach_z8002		2
@@ -258,6 +260,8 @@ extern const bfd_arch_info_type bfd_i386
 extern const bfd_arch_info_type bfd_i860_arch;
 extern const bfd_arch_info_type bfd_i960_arch;
 extern const bfd_arch_info_type bfd_m32r_arch;
+extern const bfd_arch_info_type bfd_m68hc11_arch;
+extern const bfd_arch_info_type bfd_m68hc12_arch;
 extern const bfd_arch_info_type bfd_m68k_arch;
 extern const bfd_arch_info_type bfd_m88k_arch;
 extern const bfd_arch_info_type bfd_mips_arch;
@@ -301,6 +305,8 @@ static const bfd_arch_info_type * const 
   &bfd_i860_arch,
   &bfd_i960_arch,
   &bfd_m32r_arch,
+  &bfd_m68hc11_arch,
+  &bfd_m68hc12_arch,
   &bfd_m68k_arch,
   &bfd_m88k_arch,
   &bfd_mips_arch,
diff -Nrup --exclude-from=binutils-exclude.lst /src/gnu/cygnus/binutils/bfd/config.bfd binutils/bfd/config.bfd
--- /src/gnu/cygnus/binutils/bfd/config.bfd	Sun Jun 11 00:15:10 2000
+++ binutils/bfd/config.bfd	Fri Jun 16 00:23:49 2000
@@ -37,6 +37,8 @@ c54x*)	targ_archs=bfd_tic54x_arch ;;
 hppa*)	targ_archs=bfd_hppa_arch ;;
 i[3456]86) targ_archs=bfd_i386_arch ;;
 i370)   targ_archs=bfd_i370_arch ;;
+m6811*|m68hc11*) targ_archs="bfd_m68hc11_arch bfd_m68hc12_arch" ;;
+m6812*|m68hc12*) targ_archs="bfd_m68hc12_arch bfd_m68hc11_arch" ;;
 m68*)	targ_archs=bfd_m68k_arch ;;
 m88*)	targ_archs=bfd_m88k_arch ;;
 mips*)	targ_archs=bfd_mips_arch ;;
@@ -402,6 +404,15 @@ case "${targ}" in
 
   m32r-*-*)
     targ_defvec=bfd_elf32_m32r_vec
+    ;;
+
+  m68hc11-*-* | m6811-*-*)
+    targ_defvec=bfd_elf32_m68hc11_vec
+    targ_selvecs="bfd_elf32_m68hc11_vec bfd_elf32_m68hc12_vec"
+    ;;
+  m68hc12-*-* | m6812-*-*)
+    targ_defvec=bfd_elf32_m68hc12_vec
+    targ_selvecs="bfd_elf32_m68hc11_vec bfd_elf32_m68hc12_vec"
     ;;
 
   m68*-apollo-*)
diff -Nrup --exclude-from=binutils-exclude.lst /src/gnu/cygnus/binutils/bfd/configure.in binutils/bfd/configure.in
--- /src/gnu/cygnus/binutils/bfd/configure.in	Sun Jun 11 00:15:12 2000
+++ binutils/bfd/configure.in	Fri Jun 16 00:23:50 2000
@@ -501,6 +501,8 @@ do
     bfd_elf64_littlemips_vec) 	tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"
 				target64=true ;;
     bfd_elf32_m32r_vec)		tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
+    bfd_elf32_m68hc11_vec)	tb="$tb elf32-m68hc11.lo elf32.lo $elf" ;;
+    bfd_elf32_m68hc12_vec)	tb="$tb elf32-m68hc12.lo elf32.lo $elf" ;;
     bfd_elf32_m68k_vec)		tb="$tb elf32-m68k.lo elf32.lo $elf" ;;
     bfd_elf32_m88k_vec)		tb="$tb elf32-m88k.lo elf32.lo $elf" ;;
     bfd_elf32_mcore_big_vec)	tb="$tb elf32-mcore.lo elf32.lo $elf" ;;
diff -Nrup --exclude-from=binutils-exclude.lst /src/gnu/cygnus/binutils/bfd/cpu-m68hc11.c binutils/bfd/cpu-m68hc11.c
--- /src/gnu/cygnus/binutils/bfd/cpu-m68hc11.c	Thu Jan  1 01:00:00 1970
+++ binutils/bfd/cpu-m68hc11.c	Fri Jun 16 00:49:05 2000
@@ -0,0 +1,39 @@
+/* BFD support for the Motorola 68HC11 processor
+   Copyright 1999, 2000 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_m68hc11_arch = 
+{					
+    16,	/* 16 bits in a word */
+    16,	/* 16 bits in an address */	
+    8,	/* 8 bits in a byte */		
+    bfd_arch_m68hc11,
+    0,		
+    "m68hc11",
+    "m68hc11",				
+    4, /* section alignment power */	
+    true,				
+    bfd_default_compatible, 		
+    bfd_default_scan,			
+    0,				
+};
+
diff -Nrup --exclude-from=binutils-exclude.lst /src/gnu/cygnus/binutils/bfd/cpu-m68hc12.c binutils/bfd/cpu-m68hc12.c
--- /src/gnu/cygnus/binutils/bfd/cpu-m68hc12.c	Thu Jan  1 01:00:00 1970
+++ binutils/bfd/cpu-m68hc12.c	Fri Jun 16 00:49:15 2000
@@ -0,0 +1,38 @@
+/* BFD support for the Motorola 68HC12 processor
+   Copyright 1999, 2000 Free Software Foundation, Inc.
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_m68hc12_arch = 
+{					
+    16,	/* 16 bits in a word */
+    16,	/* 16 bits in an address */	
+    8,	/* 8 bits in a byte */		
+    bfd_arch_m68hc12,
+    0,		
+    "m68hc12",
+    "m68hc12",				
+    4, /* section alignment power */	
+    true,				
+    bfd_default_compatible, 		
+    bfd_default_scan,			
+    0,				
+};
diff -Nrup --exclude-from=binutils-exclude.lst /src/gnu/cygnus/binutils/bfd/elf.c binutils/bfd/elf.c
--- /src/gnu/cygnus/binutils/bfd/elf.c	Sun Jun 11 00:15:19 2000
+++ binutils/bfd/elf.c	Fri Jun 16 00:28:13 2000
@@ -3264,6 +3264,12 @@ prep_headers (abfd)
     case bfd_arch_ia64:
       i_ehdrp->e_machine = EM_IA_64;
       break;
+    case bfd_arch_m68hc11:
+      i_ehdrp->e_machine = EM_68HC11;
+      break;
+    case bfd_arch_m68hc12:
+      i_ehdrp->e_machine = EM_68HC12;
+      break;
     case bfd_arch_m68k:
       i_ehdrp->e_machine = EM_68K;
       break;
diff -Nrup --exclude-from=binutils-exclude.lst /src/gnu/cygnus/binutils/bfd/elf32-m68hc11.c binutils/bfd/elf32-m68hc11.c
--- /src/gnu/cygnus/binutils/bfd/elf32-m68hc11.c	Thu Jan  1 01:00:00 1970
+++ binutils/bfd/elf32-m68hc11.c	Fri Jun 16 10:31:33 2000
@@ -0,0 +1,281 @@
+/* Motorola 68HC11-specific support for 32-bit ELF
+   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+   Contributed by Stephane Carrez (stcarrez@worldnet.fr)
+   (Heavily copied from the D10V port by Martin Hunt (hunt@cygnus.com))
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/m68hc11.h"
+
+static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
+PARAMS ((bfd * abfd, bfd_reloc_code_real_type code));
+static void m68hc11_info_to_howto_rel
+PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+
+
+/* Use REL instead of RELA to save space */
+#define USE_REL
+
+/* The Motorola 68HC11 microcontroler only addresses 64Kb.
+   We must handle 8 and 16-bit relocations.  The 32-bit relocation
+   is defined but not used except by gas when -gstabs is used (which
+   is wrong).
+   The 3-bit and 16-bit PC rel relocation is only used by 68HC12.  */
+static reloc_howto_type elf_m68hc11_howto_table[] = {
+  /* This reloc does nothing.  */
+  HOWTO (R_M68HC11_NONE,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_NONE",	/* name */
+	 false,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* A 8 bit absolute relocation */
+  HOWTO (R_M68HC11_8,		/* type */
+	 0,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_8",		/* name */
+	 false,			/* partial_inplace */
+	 0x00ff,		/* src_mask */
+	 0x00ff,		/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* A 8 bit absolute relocation (upper address) */
+  HOWTO (R_M68HC11_HI8,		/* type */
+	 8,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_HI8",	/* name */
+	 false,			/* partial_inplace */
+	 0x00ff,		/* src_mask */
+	 0x00ff,		/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* A 8 bit absolute relocation (upper address) */
+  HOWTO (R_M68HC11_LO8,		/* type */
+	 0,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_LO8",	/* name */
+	 false,			/* partial_inplace */
+	 0x00ff,		/* src_mask */
+	 0x00ff,		/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* A 8 bit PC-rel relocation */
+  HOWTO (R_M68HC11_PCREL_8,	/* type */
+	 0,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 true,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_PCREL_8",	/* name */
+	 false,			/* partial_inplace */
+	 0x0,			/* src_mask */
+	 0x00ff,		/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* A 16 bit absolute relocation */
+  HOWTO (R_M68HC11_16,		/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont /*bitfield */ ,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_16",	/* name */
+	 false,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* A 32 bit absolute relocation.  This one is never used for the
+     code relocation.  It's used by gas for -gstabs generation.  */
+  HOWTO (R_M68HC11_32,		/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_32",	/* name */
+	 false,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* A 3 bit absolute relocation */
+  HOWTO (R_M68HC11_3B,		/* type */
+	 0,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 3,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_4B",	/* name */
+	 false,			/* partial_inplace */
+	 0x003,			/* src_mask */
+	 0x003,			/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* A 16 bit PC-rel relocation */
+  HOWTO (R_M68HC11_PCREL_16,	/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 true,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_PCREL_16",	/* name */
+	 false,			/* partial_inplace */
+	 0x0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* GNU extension to record C++ vtable hierarchy */
+  HOWTO (R_M68HC11_GNU_VTINHERIT,	/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 0,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 NULL,			/* special_function */
+	 "R_M68HC11_GNU_VTINHERIT",	/* name */
+	 false,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* GNU extension to record C++ vtable member usage */
+  HOWTO (R_M68HC11_GNU_VTENTRY,	/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 0,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 _bfd_elf_rel_vtable_reloc_fn,	/* special_function */
+	 "R_M68HC11_GNU_VTENTRY",	/* name */
+	 false,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 false),		/* pcrel_offset */
+};
+
+/* Map BFD reloc types to M68HC11 ELF reloc types.  */
+
+struct m68hc11_reloc_map
+{
+  bfd_reloc_code_real_type bfd_reloc_val;
+  unsigned char elf_reloc_val;
+};
+
+static const struct m68hc11_reloc_map m68hc11_reloc_map[] = {
+  {BFD_RELOC_NONE, R_M68HC11_NONE,},
+  {BFD_RELOC_8, R_M68HC11_8},
+  {BFD_RELOC_M68HC11_HI8, R_M68HC11_HI8},
+  {BFD_RELOC_M68HC11_LO8, R_M68HC11_LO8},
+  {BFD_RELOC_8_PCREL, R_M68HC11_PCREL_8},
+  {BFD_RELOC_16_PCREL, R_M68HC11_PCREL_16},
+  {BFD_RELOC_16, R_M68HC11_16},
+  {BFD_RELOC_32, R_M68HC11_32},
+  {BFD_RELOC_M68HC11_3B, R_M68HC11_3B},
+
+  /* The following relocs are defined but they probably don't work yet.  */
+  {BFD_RELOC_VTABLE_INHERIT, R_M68HC11_GNU_VTINHERIT},
+  {BFD_RELOC_VTABLE_ENTRY, R_M68HC11_GNU_VTENTRY},
+};
+
+static reloc_howto_type *
+bfd_elf32_bfd_reloc_type_lookup (abfd, code)
+     bfd *abfd ATTRIBUTE_UNUSED;
+     bfd_reloc_code_real_type code;
+{
+  unsigned int i;
+
+  for (i = 0;
+       i < sizeof (m68hc11_reloc_map) / sizeof (struct m68hc11_reloc_map);
+       i++)
+    {
+      if (m68hc11_reloc_map[i].bfd_reloc_val == code)
+	return &elf_m68hc11_howto_table[m68hc11_reloc_map[i].elf_reloc_val];
+    }
+
+  return NULL;
+}
+
+/* Set the howto pointer for an M68HC11 ELF reloc.  */
+
+static void
+m68hc11_info_to_howto_rel (abfd, cache_ptr, dst)
+     bfd *abfd ATTRIBUTE_UNUSED;
+     arelent *cache_ptr;
+     Elf32_Internal_Rel *dst;
+{
+  unsigned int r_type;
+
+  r_type = ELF32_R_TYPE (dst->r_info);
+  BFD_ASSERT (r_type < (unsigned int) R_M68HC11_max);
+  cache_ptr->howto = &elf_m68hc11_howto_table[r_type];
+}
+
+/* Below is the only difference between elf32-m68hc12.c and elf32-m68hc11.c.
+   The Motorola spec says to use a different Elf machine code.  */
+#define ELF_ARCH		bfd_arch_m68hc11
+#define ELF_MACHINE_CODE	EM_68HC11
+#define ELF_MAXPAGESIZE		0x1000
+
+#define TARGET_BIG_SYM          bfd_elf32_m68hc11_vec
+#define TARGET_BIG_NAME		"elf32-m68hc11"
+
+#define elf_info_to_howto	0
+#define elf_info_to_howto_rel	m68hc11_info_to_howto_rel
+#define elf_backend_object_p	0
+#define elf_backend_final_write_processing	0
+
+#include "elf32-target.h"
diff -Nrup --exclude-from=binutils-exclude.lst /src/gnu/cygnus/binutils/bfd/elf32-m68hc12.c binutils/bfd/elf32-m68hc12.c
--- /src/gnu/cygnus/binutils/bfd/elf32-m68hc12.c	Thu Jan  1 01:00:00 1970
+++ binutils/bfd/elf32-m68hc12.c	Fri Jun 16 10:31:52 2000
@@ -0,0 +1,281 @@
+/* Motorola 68HC12-specific support for 32-bit ELF
+   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+   Contributed by Stephane Carrez (stcarrez@worldnet.fr)
+   (Heavily copied from the D10V port by Martin Hunt (hunt@cygnus.com))
+
+This file is part of BFD, the Binary File Descriptor library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/m68hc11.h"
+
+static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
+PARAMS ((bfd * abfd, bfd_reloc_code_real_type code));
+static void m68hc11_info_to_howto_rel
+PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
+
+
+/* Use REL instead of RELA to save space */
+#define USE_REL
+
+/* The Motorola 68HC11 microcontroler only addresses 64Kb.
+   We must handle 8 and 16-bit relocations.  The 32-bit relocation
+   is defined but not used except by gas when -gstabs is used (which
+   is wrong).
+   The 3-bit and 16-bit PC rel relocation is only used by 68HC12.  */
+static reloc_howto_type elf_m68hc11_howto_table[] = {
+  /* This reloc does nothing.  */
+  HOWTO (R_M68HC11_NONE,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_NONE",	/* name */
+	 false,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* A 8 bit absolute relocation */
+  HOWTO (R_M68HC11_8,		/* type */
+	 0,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_8",		/* name */
+	 false,			/* partial_inplace */
+	 0x00ff,		/* src_mask */
+	 0x00ff,		/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* A 8 bit absolute relocation (upper address) */
+  HOWTO (R_M68HC11_HI8,		/* type */
+	 8,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_HI8",	/* name */
+	 false,			/* partial_inplace */
+	 0x00ff,		/* src_mask */
+	 0x00ff,		/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* A 8 bit absolute relocation (upper address) */
+  HOWTO (R_M68HC11_LO8,		/* type */
+	 0,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_LO8",	/* name */
+	 false,			/* partial_inplace */
+	 0x00ff,		/* src_mask */
+	 0x00ff,		/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* A 8 bit PC-rel relocation */
+  HOWTO (R_M68HC11_PCREL_8,	/* type */
+	 0,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 true,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_PCREL_8",	/* name */
+	 false,			/* partial_inplace */
+	 0x0,			/* src_mask */
+	 0x00ff,		/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* A 16 bit absolute relocation */
+  HOWTO (R_M68HC11_16,		/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont /*bitfield */ ,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_16",	/* name */
+	 false,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* A 32 bit absolute relocation.  This one is never used for the
+     code relocation.  It's used by gas for -gstabs generation.  */
+  HOWTO (R_M68HC11_32,		/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_32",	/* name */
+	 false,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* A 3 bit absolute relocation */
+  HOWTO (R_M68HC11_3B,		/* type */
+	 0,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 3,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_4B",	/* name */
+	 false,			/* partial_inplace */
+	 0x003,			/* src_mask */
+	 0x003,			/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* A 16 bit PC-rel relocation */
+  HOWTO (R_M68HC11_PCREL_16,	/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 true,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC11_PCREL_16",	/* name */
+	 false,			/* partial_inplace */
+	 0x0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* GNU extension to record C++ vtable hierarchy */
+  HOWTO (R_M68HC11_GNU_VTINHERIT,	/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 0,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 NULL,			/* special_function */
+	 "R_M68HC11_GNU_VTINHERIT",	/* name */
+	 false,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 false),		/* pcrel_offset */
+
+  /* GNU extension to record C++ vtable member usage */
+  HOWTO (R_M68HC11_GNU_VTENTRY,	/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 0,			/* bitsize */
+	 false,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 _bfd_elf_rel_vtable_reloc_fn,	/* special_function */
+	 "R_M68HC11_GNU_VTENTRY",	/* name */
+	 false,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 false),		/* pcrel_offset */
+};
+
+/* Map BFD reloc types to M68HC11 ELF reloc types.  */
+
+struct m68hc11_reloc_map
+{
+  bfd_reloc_code_real_type bfd_reloc_val;
+  unsigned char elf_reloc_val;
+};
+
+static const struct m68hc11_reloc_map m68hc11_reloc_map[] = {
+  {BFD_RELOC_NONE, R_M68HC11_NONE,},
+  {BFD_RELOC_8, R_M68HC11_8},
+  {BFD_RELOC_M68HC11_HI8, R_M68HC11_HI8},
+  {BFD_RELOC_M68HC11_LO8, R_M68HC11_LO8},
+  {BFD_RELOC_8_PCREL, R_M68HC11_PCREL_8},
+  {BFD_RELOC_16_PCREL, R_M68HC11_PCREL_16},
+  {BFD_RELOC_16, R_M68HC11_16},
+  {BFD_RELOC_32, R_M68HC11_32},
+  {BFD_RELOC_M68HC11_3B, R_M68HC11_3B},
+
+  /* The following relocs are defined but they probably don't work yet.  */
+  {BFD_RELOC_VTABLE_INHERIT, R_M68HC11_GNU_VTINHERIT},
+  {BFD_RELOC_VTABLE_ENTRY, R_M68HC11_GNU_VTENTRY},
+};
+
+static reloc_howto_type *
+bfd_elf32_bfd_reloc_type_lookup (abfd, code)
+     bfd *abfd ATTRIBUTE_UNUSED;
+     bfd_reloc_code_real_type code;
+{
+  unsigned int i;
+
+  for (i = 0;
+       i < sizeof (m68hc11_reloc_map) / sizeof (struct m68hc11_reloc_map);
+       i++)
+    {
+      if (m68hc11_reloc_map[i].bfd_reloc_val == code)
+	return &elf_m68hc11_howto_table[m68hc11_reloc_map[i].elf_reloc_val];
+    }
+
+  return NULL;
+}
+
+/* Set the howto pointer for an M68HC11 ELF reloc.  */
+
+static void
+m68hc11_info_to_howto_rel (abfd, cache_ptr, dst)
+     bfd *abfd ATTRIBUTE_UNUSED;
+     arelent *cache_ptr;
+     Elf32_Internal_Rel *dst;
+{
+  unsigned int r_type;
+
+  r_type = ELF32_R_TYPE (dst->r_info);
+  BFD_ASSERT (r_type < (unsigned int) R_M68HC11_max);
+  cache_ptr->howto = &elf_m68hc11_howto_table[r_type];
+}
+
+/* Below is the only difference between elf32-m68hc12.c and elf32-m68hc11.c.
+   The Motorola spec says to use a different Elf machine code.  */
+#define ELF_ARCH		bfd_arch_m68hc12
+#define ELF_MACHINE_CODE	EM_68HC12
+#define ELF_MAXPAGESIZE		0x1000
+
+#define TARGET_BIG_SYM          bfd_elf32_m68hc12_vec
+#define TARGET_BIG_NAME		"elf32-m68hc12"
+
+#define elf_info_to_howto	0
+#define elf_info_to_howto_rel	m68hc11_info_to_howto_rel
+#define elf_backend_object_p	0
+#define elf_backend_final_write_processing	0
+
+#include "elf32-target.h"
diff -Nrup --exclude-from=binutils-exclude.lst /src/gnu/cygnus/binutils/bfd/reloc.c binutils/bfd/reloc.c
--- /src/gnu/cygnus/binutils/bfd/reloc.c	Thu Jun  1 00:57:35 2000
+++ binutils/bfd/reloc.c	Thu Jun  1 11:17:53 2000
@@ -2888,6 +2888,23 @@ ENUMX
 ENUMDOC
   Intel IA64 Relocations.
 ENDSENUM
+
+ENUM
+  BFD_RELOC_M68HC11_HI8
+ENUMDOC
+  Motorola 68HC11 reloc.
+  This is the 8 bits high part of an absolute address.
+ENUM
+  BFD_RELOC_M68HC11_LO8
+ENUMDOC
+  Motorola 68HC11 reloc.
+  This is the 8 bits low part of an absolute address.
+ENUM
+  BFD_RELOC_M68HC11_3B
+ENUMDOC
+  Motorola 68HC11 reloc.
+  This is the 3 bits of a value.
+
   BFD_RELOC_UNUSED
 CODE_FRAGMENT
 .
diff -Nrup --exclude-from=binutils-exclude.lst /src/gnu/cygnus/binutils/bfd/targets.c binutils/bfd/targets.c
--- /src/gnu/cygnus/binutils/bfd/targets.c	Thu Jun  1 00:58:05 2000
+++ binutils/bfd/targets.c	Thu Jun  1 11:17:54 2000
@@ -532,6 +532,8 @@ extern const bfd_target bfd_elf32_little
 extern const bfd_target bfd_elf32_littlemips_vec;
 extern const bfd_target bfd_elf64_littlemips_vec;
 extern const bfd_target bfd_elf32_m32r_vec;
+extern const bfd_target bfd_elf32_m68hc11_vec;
+extern const bfd_target bfd_elf32_m68hc12_vec;
 extern const bfd_target bfd_elf32_m68k_vec;
 extern const bfd_target bfd_elf32_m88k_vec;
 extern const bfd_target bfd_elf32_mn10200_vec;
@@ -737,6 +739,8 @@ const bfd_target * const bfd_target_vect
 	&bfd_elf32_m32r_vec,
 	&bfd_elf32_mn10200_vec,
 	&bfd_elf32_mn10300_vec,
+	&bfd_elf32_m68hc11_vec,
+	&bfd_elf32_m68hc12_vec,
 	&bfd_elf32_m68k_vec,
 	&bfd_elf32_m88k_vec,
 	&bfd_elf32_sparc_vec,


More information about the Binutils mailing list