From: Nick Clifton Date: Tue, 15 May 2012 12:55:51 +0000 (+0000) Subject: * config/tc-m68hc11.c: Add S12X and XGATE co-processor support. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6927f98292aaa6f7fcb3152d5d902758538e626c;p=binutils-gdb.git * config/tc-m68hc11.c: Add S12X and XGATE co-processor support. Add option to offset S12 addresses into XGATE memory space. Tweak target flags to match other tools. (i.e. -m m68hc11). * doc/as.texinfo: Mention new options. * doc/c-m68hc11.texi: Document new options. * NEWS: Mention new support. * archures.c: Add bfd_arch_m9s12x and bfd_arch_m9s12xg. * config.bfd: Likewise. * cpu-m9s12x.c: New. * cpu-m9s12xg.c: New. * elf32-m68hc12.c: Add S12X and XGATE co-processor support. Add option to offset S12 addresses into XGATE memory space. Fix carry bug in IMM16 (IMM8 low/high) relocate. * Makefile.am (ALL_MACHINES): Add cpu-m9s12x and cpu-m9s12xg. (ALL_MACHINES_CFILES): Likewise. * reloc.c: Add S12X relocs. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. * gas/m68hc11/insns9s12x.s: New * gas/m68hc11/insns9s12x.d: New * gas/m68hc11/hexprefix.s: New * gas/m68hc11/hexprefix.d: New * gas/m68hc11/9s12x-exg-sex-tfr.s: New * gas/m68hc11/9s12x-exg-sex-tfr.d: New * gas/m68hc11/insns9s12xg.s: New * gas/m68hc11/insns9s12xg.d: New * gas/m68hc11/9s12x-mov.s: New * gas/m68hc11/9s12x-mov.d: New * gas/m68hc11/m68hc11.exp: Updated * gas/m68hc11/*.d: Brought in line with changed objdump output. * gas/all/gas.exp: XFAIL all hc11/12 targets for redef2,3. * gas/elf/elf.exp: XFAIL all hc11/12 targets for redef. * gas/elf/dwarf2-1.d: Skip for hc11/12 targets. * gas/elf/dwarf2-2.d: Likewise. * ld-m68hc11/xgate-link.s: New. * ld-m68hc11/xgate-link.d: New. * ld-m68hc11/xgate-offset.s: New. * ld-m68hc11/xgate-offset.d: New. * ld-m68hc11/xgate1.s: New. * ld-m68hc11/xgate1.d: New. * ld-m68hc11/xgate2.s: New. * ld-m68hc11/m68hc11.exp: Updated. * ld-m68hc11/*.d: Brought in line with changed objdump output. * ld-gc/gc.exp: Update CFLAGS for m68hc11. * ld-plugin/plugin.exp: Likewise. * ld-srec/srec.exp: XFAIL for m68hc11 and m68hc12. * configure.in: Add S12X and XGATE co-processor support to m68hc11 target. * disassemble.c: Likewise. * configure: Regenerate. * m68hc11-dis.c: Make objdump output more consistent, use hex instead of decimal and use 0x prefix for hex. * m68hc11-opc.c: Add S12X and XGATE opcodes. * dis-asm.h (print_insn_m9s12x): Prototype. (print_insn_m9s12xg): Prototype. * m68hc11.h (R_M68HC12_16B, R_M68HC12_PCREL_9, R_M68HC12_PCREL_10) R_M68HC12_HI8XG, R_M68HC12_LO8XG): New relocations. (E_M68HC11_XGATE_RAMOFFSET): Define. * m68hc11.h: Add XGate definitions. (struct m68hc11_opcode): Add xg_mask field. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index be536667e4a..05bc0de6809 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,20 @@ +2012-05-15 James Murray + Stephane Carrez + + * archures.c: Add bfd_arch_m9s12x and bfd_arch_m9s12xg. + * config.bfd: Likewise. + * cpu-m9s12x.c: New. + * cpu-m9s12xg.c: New. + * elf32-m68hc12.c: Add S12X and XGATE co-processor support. + Add option to offset S12 addresses into XGATE memory space. + Fix carry bug in IMM16 (IMM8 low/high) relocate. + * Makefile.am (ALL_MACHINES): Add cpu-m9s12x and cpu-m9s12xg. + (ALL_MACHINES_CFILES): Likewise. + * reloc.c: Add S12X relocs. + * Makefile.in: Regenerate. + * bfd-in2.h: Regenerate. + * libbfd.h: Regenerate. + 2012-05-14 James Lemke Catherine Moore @@ -36,7 +53,7 @@ (elf_backend_lookup_section_flags_hook): Define. (elf_backend_section_flags): Define. (elf_backend_section_processing): Define. - * elf32-ppc.h (ppc_elf_section_processing): Declare. + * elf32-ppc.h (ppc_elf_section_processing): Declare. * libbfd.h: Regenerated. * reloc.c (BFD_RELOC_PPC_VLE_REL8, BFD_RELOC_PPC_VLE_REL15, BFD_RELOC_PPC_VLE_REL24, BFD_RELOC_PPC_VLE_LO16A, diff --git a/bfd/Makefile.am b/bfd/Makefile.am index 0414cc7cee0..b7271cc886f 100644 --- a/bfd/Makefile.am +++ b/bfd/Makefile.am @@ -105,6 +105,8 @@ ALL_MACHINES = \ cpu-m32r.lo \ cpu-m68hc11.lo \ cpu-m68hc12.lo \ + cpu-m9s12x.lo \ + cpu-m9s12xg.lo \ cpu-m68k.lo \ cpu-m88k.lo \ cpu-mcore.lo \ @@ -183,6 +185,8 @@ ALL_MACHINES_CFILES = \ cpu-m32r.c \ cpu-m68hc11.c \ cpu-m68hc12.c \ + cpu-m9s12x.c \ + cpu-m9s12xg.c \ cpu-m68k.c \ cpu-m88k.c \ cpu-mcore.c \ diff --git a/bfd/Makefile.in b/bfd/Makefile.in index bf3a1623991..7a48fdaf1fe 100644 --- a/bfd/Makefile.in +++ b/bfd/Makefile.in @@ -404,6 +404,8 @@ ALL_MACHINES = \ cpu-m32r.lo \ cpu-m68hc11.lo \ cpu-m68hc12.lo \ + cpu-m9s12x.lo \ + cpu-m9s12xg.lo \ cpu-m68k.lo \ cpu-m88k.lo \ cpu-mcore.lo \ @@ -482,6 +484,8 @@ ALL_MACHINES_CFILES = \ cpu-m32r.c \ cpu-m68hc11.c \ cpu-m68hc12.c \ + cpu-m9s12x.c \ + cpu-m9s12xg.c \ cpu-m68k.c \ cpu-m88k.c \ cpu-mcore.c \ diff --git a/bfd/archures.c b/bfd/archures.c index c6f1c2a9f83..a23534b346a 100644 --- a/bfd/archures.c +++ b/bfd/archures.c @@ -266,6 +266,8 @@ DESCRIPTION .#define bfd_mach_m6812_default 0 .#define bfd_mach_m6812 1 .#define bfd_mach_m6812s 2 +. bfd_arch_m9s12x, {* Freescale S12X *} +. bfd_arch_m9s12xg, {* Freescale XGATE *} . bfd_arch_z8k, {* Zilog Z8000 *} .#define bfd_mach_z8001 1 .#define bfd_mach_z8002 2 @@ -535,6 +537,8 @@ extern const bfd_arch_info_type bfd_m32c_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_m9s12x_arch; +extern const bfd_arch_info_type bfd_m9s12xg_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_mcore_arch; @@ -618,6 +622,8 @@ static const bfd_arch_info_type * const bfd_archures_list[] = &bfd_m32r_arch, &bfd_m68hc11_arch, &bfd_m68hc12_arch, + &bfd_m9s12x_arch, + &bfd_m9s12xg_arch, &bfd_m68k_arch, &bfd_m88k_arch, &bfd_mcore_arch, diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 8e6ff42dce5..fa2b9a5688d 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1958,6 +1958,8 @@ enum bfd_architecture #define bfd_mach_m6812_default 0 #define bfd_mach_m6812 1 #define bfd_mach_m6812s 2 + bfd_arch_m9s12x, /* Freescale S12X */ + bfd_arch_m9s12xg, /* Freescale XGATE */ bfd_arch_z8k, /* Zilog Z8000 */ #define bfd_mach_z8001 1 #define bfd_mach_z8002 2 @@ -4546,6 +4548,32 @@ This is a 4-bit pc-relative reloc. */ This is a 5-bit pc-relative reloc. */ BFD_RELOC_XGATE_IMM5, +/* Motorola 68HC12 reloc. +This is the 9 bits of a value. */ + BFD_RELOC_M68HC12_9B, + +/* Motorola 68HC12 reloc. +This is the 16 bits of a value. */ + BFD_RELOC_M68HC12_16B, + +/* Motorola 68HC12/XGATE reloc. +This is a PCREL9 branch. */ + BFD_RELOC_M68HC12_9_PCREL, + +/* Motorola 68HC12/XGATE reloc. +This is a PCREL10 branch. */ + BFD_RELOC_M68HC12_10_PCREL, + +/* Motorola 68HC12/XGATE reloc. +This is the 8 bit low part of an absolute address and immediately precedes +a matching HI8XG part. */ + BFD_RELOC_M68HC12_LO8XG, + +/* Motorola 68HC12/XGATE reloc. +This is the 8 bit high part of an absolute address and immediately follows +a matching LO8XG part. */ + BFD_RELOC_M68HC12_HI8XG, + /* NS CR16C Relocations. */ BFD_RELOC_16C_NUM08, BFD_RELOC_16C_NUM08_C, diff --git a/bfd/config.bfd b/bfd/config.bfd index 3f758c0bdee..783d1f3065f 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -85,8 +85,8 @@ hppa*) targ_archs=bfd_hppa_arch ;; i[3-7]86) targ_archs=bfd_i386_arch ;; i370) targ_archs=bfd_i370_arch ;; lm32) targ_archs=bfd_lm32_arch ;; -m6811*|m68hc11*) targ_archs="bfd_m68hc11_arch bfd_m68hc12_arch" ;; -m6812*|m68hc12*) targ_archs="bfd_m68hc12_arch bfd_m68hc11_arch" ;; +m6811*|m68hc11*) targ_archs="bfd_m68hc11_arch bfd_m68hc12_arch bfd_m9s12x_arch bfd_m9s12xg_arch" ;; +m6812*|m68hc12*) targ_archs="bfd_m68hc12_arch bfd_m68hc11_arch bfd_m9s12x_arch bfd_m9s12xg_arch" ;; m68*) targ_archs=bfd_m68k_arch ;; m88*) targ_archs=bfd_m88k_arch ;; microblaze*) targ_archs=bfd_microblaze_arch ;; diff --git a/bfd/cpu-m9s12x.c b/bfd/cpu-m9s12x.c new file mode 100644 index 00000000000..d224b8355bd --- /dev/null +++ b/bfd/cpu-m9s12x.c @@ -0,0 +1,41 @@ +/* BFD support for the Freescale 9S12X processor + Copyright 2008, 2009, 2010, 2011, 2012 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 3 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., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +#include "sysdep.h" +#include "bfd.h" +#include "libbfd.h" + +const bfd_arch_info_type bfd_m9s12x_arch = +{ + 16, /* 16 bits in a word. */ + 32, /* 16 bits in an address. */ + 8, /* 8 bits in a byte. */ + bfd_arch_m9s12x, + 0, + "m9s12x", + "m9s12x", + 4, /* Section alignment power. */ + TRUE, + bfd_default_compatible, + bfd_default_scan, + bfd_arch_default_fill, + 0, +}; + diff --git a/bfd/cpu-m9s12xg.c b/bfd/cpu-m9s12xg.c new file mode 100644 index 00000000000..6958a13ccb2 --- /dev/null +++ b/bfd/cpu-m9s12xg.c @@ -0,0 +1,41 @@ +/* BFD support for the Freescale 9S12-XGATE co-processor + Copyright 2008, 2009, 2010, 2011, 2012 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 3 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., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ + +#include "sysdep.h" +#include "bfd.h" +#include "libbfd.h" + +const bfd_arch_info_type bfd_m9s12xg_arch = +{ + 16, /* 16 bits in a word. */ + 32, /* 16 bits in an address. */ + 8, /* 8 bits in a byte. */ + bfd_arch_m9s12xg, + 0, + "m9s12xg", + "m9s12xg", + 4, /* Section alignment power. */ + TRUE, + bfd_default_compatible, + bfd_default_scan, + bfd_arch_default_fill, + 0, +}; + diff --git a/bfd/elf32-m68hc12.c b/bfd/elf32-m68hc12.c index 2b166410087..448853db8d8 100644 --- a/bfd/elf32-m68hc12.c +++ b/bfd/elf32-m68hc12.c @@ -324,11 +324,81 @@ static reloc_howto_type elf_m68hc11_howto_table[] = { FALSE), /* pcrel_offset */ EMPTY_HOWTO (14), - EMPTY_HOWTO (15), - EMPTY_HOWTO (16), - EMPTY_HOWTO (17), - EMPTY_HOWTO (18), - EMPTY_HOWTO (19), + + /* A 16 bit absolute relocation. */ + HOWTO (R_M68HC12_16B, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_M68HC12_16B", /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* A 9 bit PC-rel relocation. */ + HOWTO (R_M68HC12_PCREL_9, /* type */ + 1, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 10, /* bitsize (result is >>1) */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_M68HC12_PCREL_9", /* name */ + TRUE, /* partial_inplace */ + 0xfe00, /* src_mask */ + 0x01ff, /* dst_mask */ + TRUE), /* pcrel_offset */ + + /* A 10 bit PC-rel relocation. */ + HOWTO (R_M68HC12_PCREL_10, /* type */ + 1, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 11, /* bitsize (result is >>1) */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_M68HC12_PCREL_10", /* name */ + TRUE, /* partial_inplace */ + 0xfc00, /* src_mask */ + 0x03ff, /* dst_mask */ + TRUE), /* pcrel_offset */ + + /* A 8 bit absolute relocation (upper address). */ + HOWTO (R_M68HC12_HI8XG, /* 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_M68HC12_HI8XG", /* name */ + FALSE, /* partial_inplace */ + 0x00ff, /* src_mask */ + 0x00ff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* A 8 bit absolute relocation (lower address). */ + HOWTO (R_M68HC12_LO8XG, /* 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_M68HC12_LO8XG", /* name */ + FALSE, /* partial_inplace */ + 0x00ff, /* src_mask */ + 0x00ff, /* dst_mask */ + FALSE), /* pcrel_offset */ /* Mark beginning of a jump instruction (any form). */ HOWTO (R_M68HC11_RL_JUMP, /* type */ @@ -369,7 +439,8 @@ struct m68hc11_reloc_map unsigned char elf_reloc_val; }; -static const struct m68hc11_reloc_map m68hc11_reloc_map[] = { +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}, @@ -389,6 +460,13 @@ static const struct m68hc11_reloc_map m68hc11_reloc_map[] = { {BFD_RELOC_M68HC11_RL_JUMP, R_M68HC11_RL_JUMP}, {BFD_RELOC_M68HC11_RL_GROUP, R_M68HC11_RL_GROUP}, + + {BFD_RELOC_M68HC12_16B, R_M68HC12_16B}, + + {BFD_RELOC_M68HC12_9_PCREL, R_M68HC12_PCREL_9}, + {BFD_RELOC_M68HC12_10_PCREL, R_M68HC12_PCREL_10}, + {BFD_RELOC_M68HC12_HI8XG, R_M68HC12_HI8XG}, + {BFD_RELOC_M68HC12_LO8XG, R_M68HC12_LO8XG}, }; static reloc_howto_type * diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c index f5762a481aa..70bf09e3d33 100644 --- a/bfd/elf32-m68hc1x.c +++ b/bfd/elf32-m68hc1x.c @@ -949,6 +949,7 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, bfd_vma insn_page; bfd_boolean is_far = FALSE; struct elf_link_hash_entry *h; + bfd_vma val; r_symndx = ELF32_R_SYM (rel->r_info); r_type = ELF32_R_TYPE (rel->r_info); @@ -1029,6 +1030,50 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, phys_page = m68hc11_phys_page (pinfo, relocation + rel->r_addend); switch (r_type) { + case R_M68HC12_LO8XG: + /* This relocation is specific to XGATE IMM16 calls and will precede + a HI8. tc-m68hc11 only generates them in pairs. + Leave the relocation to the HI8XG step. */ + r = bfd_reloc_ok; + r_type = R_M68HC11_NONE; + break; + + case R_M68HC12_HI8XG: + /* This relocation is specific to XGATE IMM16 calls and must follow + a LO8XG. Does not actually check that it was a LO8XG. + Adjusts high and low bytes. */ + relocation = phys_addr; + if ((elf_elfheader (input_bfd)->e_flags & E_M68HC11_XGATE_RAMOFFSET) + && (relocation >= 0x2000)) + relocation += 0xc000; /* HARDCODED RAM offset for XGATE. */ + + /* Fetch 16 bit value including low byte in previous insn. */ + val = (bfd_get_8 (input_bfd, (bfd_byte*) contents + rel->r_offset) << 8) + | bfd_get_8 (input_bfd, (bfd_byte*) contents + rel->r_offset - 2); + + /* Add on value to preserve carry, then write zero to high byte. */ + relocation += val; + + /* Write out top byte. */ + bfd_put_8 (input_bfd, (relocation >> 8) & 0xff, + (bfd_byte*) contents + rel->r_offset); + + /* Write out low byte to previous instruction. */ + bfd_put_8 (input_bfd, relocation & 0xff, + (bfd_byte*) contents + rel->r_offset - 2); + + /* Mark as relocation completed. */ + r = bfd_reloc_ok; + r_type = R_M68HC11_NONE; + break; + + /* The HI8 and LO8 relocs are generated by %hi(expr) %lo(expr) + assembler directives. %hi does not support carry. */ + case R_M68HC11_HI8: + case R_M68HC11_LO8: + relocation = phys_addr; + break; + case R_M68HC11_24: /* Reloc used by 68HC12 call instruction. */ bfd_put_16 (input_bfd, phys_addr, @@ -1123,10 +1168,18 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, relocation = phys_addr; break; } + if (r_type != R_M68HC11_NONE) - r = _bfd_final_link_relocate (howto, input_bfd, input_section, + { + if ((r_type == R_M68HC12_PCREL_9) || (r_type == R_M68HC12_PCREL_10)) + r = _bfd_final_link_relocate (howto, input_bfd, input_section, contents, rel->r_offset, - relocation, rel->r_addend); + relocation - 2, rel->r_addend); + else + r = _bfd_final_link_relocate (howto, input_bfd, input_section, + contents, rel->r_offset, + relocation, rel->r_addend); + } if (r != bfd_reloc_ok) { @@ -1317,6 +1370,9 @@ _bfd_m68hc11_elf_print_private_bfd_data (bfd *abfd, void *ptr) else fprintf (file, _(" [memory=flat]")); + if (elf_elfheader (abfd)->e_flags & E_M68HC11_XGATE_RAMOFFSET) + fprintf (file, _(" [XGATE RAM offsetting]")); + fputc ('\n', file); return TRUE; diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 94fb0a11dc6..173c009c919 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -2125,6 +2125,12 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_XGATE_IMM3", "BFD_RELOC_XGATE_IMM4", "BFD_RELOC_XGATE_IMM5", + "BFD_RELOC_M68HC12_9B", + "BFD_RELOC_M68HC12_16B", + "BFD_RELOC_M68HC12_9_PCREL", + "BFD_RELOC_M68HC12_10_PCREL", + "BFD_RELOC_M68HC12_LO8XG", + "BFD_RELOC_M68HC12_HI8XG", "BFD_RELOC_16C_NUM08", "BFD_RELOC_16C_NUM08_C", "BFD_RELOC_16C_NUM16", diff --git a/bfd/reloc.c b/bfd/reloc.c index a9fd397b7dd..978fe8da219 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -5091,6 +5091,38 @@ ENUM ENUMDOC Freescale XGATE reloc. This is a 5-bit pc-relative reloc. +ENUM + BFD_RELOC_M68HC12_9B +ENUMDOC + Motorola 68HC12 reloc. + This is the 9 bits of a value. +ENUM + BFD_RELOC_M68HC12_16B +ENUMDOC + Motorola 68HC12 reloc. + This is the 16 bits of a value. +ENUM + BFD_RELOC_M68HC12_9_PCREL +ENUMDOC + Motorola 68HC12/XGATE reloc. + This is a PCREL9 branch. +ENUM + BFD_RELOC_M68HC12_10_PCREL +ENUMDOC + Motorola 68HC12/XGATE reloc. + This is a PCREL10 branch. +ENUM + BFD_RELOC_M68HC12_LO8XG +ENUMDOC + Motorola 68HC12/XGATE reloc. + This is the 8 bit low part of an absolute address and immediately precedes + a matching HI8XG part. +ENUM + BFD_RELOC_M68HC12_HI8XG +ENUMDOC + Motorola 68HC12/XGATE reloc. + This is the 8 bit high part of an absolute address and immediately follows + a matching LO8XG part. ENUM BFD_RELOC_16C_NUM08 ENUMX diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 7072d1ec4ea..fc8420cc2d8 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,7 @@ +2012-05-15 James Murray + + * readelf.c (get_machine_name): Update m68hc12 entry. + 2012-05-13 H.J. Lu * objdump.c (disassemble_bytes): Print addend as signed. diff --git a/binutils/readelf.c b/binutils/readelf.c index a2884b2ce7e..212f70e6c20 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -1868,7 +1868,6 @@ get_machine_name (unsigned e_machine) case EM_IA_64: return "Intel IA-64"; case EM_MIPS_X: return "Stanford MIPS-X"; case EM_COLDFIRE: return "Motorola Coldfire"; - case EM_68HC12: return "Motorola M68HC12"; case EM_ALPHA: return "Alpha"; case EM_CYGNUS_D10V: case EM_D10V: return "d10v"; @@ -1903,6 +1902,7 @@ get_machine_name (unsigned e_machine) case EM_ST9PLUS: return "STMicroelectronics ST9+ 8/16 bit microcontroller"; case EM_ST7: return "STMicroelectronics ST7 8-bit microcontroller"; case EM_68HC16: return "Motorola MC68HC16 Microcontroller"; + case EM_68HC12: return "Motorola MC68HC12 Microcontroller"; case EM_68HC11: return "Motorola MC68HC11 Microcontroller"; case EM_68HC08: return "Motorola MC68HC08 Microcontroller"; case EM_68HC05: return "Motorola MC68HC05 Microcontroller"; diff --git a/gas/ChangeLog b/gas/ChangeLog index 680a659b36f..80e1518b098 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2012-05-15 James Murray + + * config/tc-m68hc11.c: Add S12X and XGATE co-processor support. + Add option to offset S12 addresses into XGATE memory space. + Tweak target flags to match other tools. (i.e. -m m68hc11). + * doc/as.texinfo: Mention new options. + * doc/c-m68hc11.texi: Document new options. + * NEWS: Mention new support. + 2012-05-14 DJ Delorie * config/rx-parse.y (rx_range): declare. @@ -50,7 +59,7 @@ (md_show_usage): Document -mvle. (ppc_arch): Recognize VLE. (ppc_mach): Recognize bfd_mach_ppc_vle. - (ppc_setup_opcodes): Print the opcode table if + (ppc_setup_opcodes): Print the opcode table if * config/tc-ppc.h (ppc_frag_check): Declare. * doc/c-ppc.texi: Document -mvle. * NEWS: Mention PowerPC VLE port. @@ -61,7 +70,7 @@ (DWARF2_LINE_MIN_INSN_LENGTH): Redefine. * config/tc-ppc.c (ppc_dw2_line_min_insn_length): New. * dwarf2dbg.c (scale_addr_delta): Handle values of 1 - for DWARF2_LINE_MIN_INSN_LENGTH. + for DWARF2_LINE_MIN_INSN_LENGTH. 2012-05-12 H.J. Lu diff --git a/gas/NEWS b/gas/NEWS index 08e6384bcc5..6b6dbba827d 100644 --- a/gas/NEWS +++ b/gas/NEWS @@ -1,5 +1,7 @@ -*- text -*- +* Add support for S12X processor. + * Add support for the VLE extension to the PowerPC architecture. * Add support for the Freescale XGATE architecture. diff --git a/gas/config/tc-m68hc11.c b/gas/config/tc-m68hc11.c index 2e328ea77b0..6211f9dcab2 100644 --- a/gas/config/tc-m68hc11.c +++ b/gas/config/tc-m68hc11.c @@ -1,7 +1,9 @@ /* tc-m68hc11.c -- Assembler code for the Motorola 68HC11 & 68HC12. - Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 + Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, + 2011, 2012 Free Software Foundation, Inc. Written by Stephane Carrez (stcarrez@nerim.fr) + XGATE and S12X added by James Murray (jsm@jsm-net.demon.co.uk) This file is part of GAS, the GNU Assembler. @@ -65,7 +67,8 @@ const char FLT_CHARS[] = "dD"; How many bytes this mode will add to the size of the frag. Which mode to go to if the offset won't fit in this one. */ -relax_typeS md_relax_table[] = { +relax_typeS md_relax_table[] = +{ {1, 1, 0, 0}, /* First entries aren't used. */ {1, 1, 0, 0}, /* For no good reason except. */ {1, 1, 0, 0}, /* that the VAX doesn't either. */ @@ -116,7 +119,8 @@ relax_typeS md_relax_table[] = { }; /* 68HC11 and 68HC12 registers. They are numbered according to the 68HC12. */ -typedef enum register_id { +typedef enum register_id +{ REG_NONE = -1, REG_A = 0, REG_B = 1, @@ -125,17 +129,30 @@ typedef enum register_id { REG_X = 5, REG_Y = 6, REG_SP = 7, - REG_PC = 8 + REG_PC = 8, + REG_R0 = 0, + REG_R1 = 1, + REG_R2 = 2, + REG_R3 = 3, + REG_R4 = 4, + REG_R5 = 5, + REG_R6 = 6, + REG_R7 = 7, + REG_SP_XG = 8, + REG_PC_XG = 9, + REG_CCR_XG = 10 } register_id; -typedef struct operand { +typedef struct operand +{ expressionS exp; register_id reg1; register_id reg2; int mode; } operand; -struct m68hc11_opcode_def { +struct m68hc11_opcode_def +{ long format; int min_operands; int max_operands; @@ -147,18 +164,30 @@ struct m68hc11_opcode_def { static struct m68hc11_opcode_def *m68hc11_opcode_defs = 0; static int m68hc11_nb_opcode_defs = 0; -typedef struct alias { +typedef struct alias +{ const char *name; const char *alias; } alias; -static alias alias_opcodes[] = { +static alias alias_opcodes[] = +{ {"cpd", "cmpd"}, {"cpx", "cmpx"}, {"cpy", "cmpy"}, {0, 0} }; +struct m9s12xg_opcode_def +{ + long format; + int min_operands; + int max_operands; + int nb_modes; + int used; + struct m9s12xg_opcode *opcode; +}; + /* Local functions. */ static register_id reg_name_search (char *); static register_id register_name (void); @@ -173,6 +202,7 @@ static int get_operand (operand *, int, long); static void fixup8 (expressionS *, int, int); static void fixup16 (expressionS *, int, int); static void fixup24 (expressionS *, int, int); +static void fixup8_xg (expressionS *, int, int); static unsigned char convert_branch (unsigned char); static char *m68hc11_new_insn (int); static void build_dbranch_insn (struct m68hc11_opcode *, @@ -185,6 +215,7 @@ static struct m68hc11_opcode *find (struct m68hc11_opcode_def *, static struct m68hc11_opcode *find_opcode (struct m68hc11_opcode_def *, operand *, int *); static void build_jump_insn (struct m68hc11_opcode *, operand *, int, int); +static void build_insn_xg (struct m68hc11_opcode *, operand *, int); static void build_insn (struct m68hc11_opcode *, operand *, int); static int relaxable_symbol (symbolS *); @@ -259,10 +290,12 @@ static int elf_flags = E_M68HC11_F64; pseudo-op name without dot function to call to execute this pseudo-op Integer arg to pass to the function. */ -const pseudo_typeS md_pseudo_table[] = { +const pseudo_typeS md_pseudo_table[] = +{ /* The following pseudo-ops are supported for MRI compatibility. */ {"fcb", cons, 1}, {"fdb", cons, 2}, + {"fqb", cons, 4}, {"fcc", stringer, 8 + 1}, {"rmb", s_space, 0}, @@ -288,7 +321,8 @@ const pseudo_typeS md_pseudo_table[] = { const char *md_shortopts = "Sm:"; -struct option md_longopts[] = { +struct option md_longopts[] = +{ #define OPTION_FORCE_LONG_BRANCH (OPTION_MD_BASE) {"force-long-branches", no_argument, NULL, OPTION_FORCE_LONG_BRANCH}, {"force-long-branchs", no_argument, NULL, OPTION_FORCE_LONG_BRANCH}, /* Misspelt version kept for backwards compatibility. */ @@ -321,6 +355,9 @@ struct option md_longopts[] = { #define OPTION_MLONG_DOUBLE (OPTION_MD_BASE + 9) {"mlong-double", no_argument, NULL, OPTION_MLONG_DOUBLE}, +#define OPTION_XGATE_RAMOFFSET (OPTION_MD_BASE + 10) + {"xgate-ramoffset", no_argument, NULL, OPTION_XGATE_RAMOFFSET}, + {NULL, no_argument, NULL, 0} }; size_t md_longopts_size = sizeof (md_longopts); @@ -360,6 +397,10 @@ m68hc11_listing_header (void) { if (current_architecture & cpu6811) return "M68HC11 GAS "; + else if (current_architecture & cpuxgate) + return "XGATE GAS "; + else if (current_architecture & cpu9s12x) + return "S12X GAS "; else return "M68HC12 GAS "; } @@ -371,7 +412,8 @@ md_show_usage (FILE *stream) fprintf (stream, _("\ Motorola 68HC11/68HC12/68HCS12 options:\n\ -m68hc11 | -m68hc12 |\n\ - -m68hcs12 specify the processor [default %s]\n\ + -m68hcs12 | -mm9s12x |\n\ + -mm9s12xg specify the processor [default %s]\n\ -mshort use 16-bit int ABI (default)\n\ -mlong use 32-bit int ABI\n\ -mshort-double use 32-bit double ABI\n\ @@ -383,6 +425,7 @@ Motorola 68HC11/68HC12/68HCS12 options:\n\ when the instruction does not support direct mode\n\ --print-insn-syntax print the syntax of instruction in case of error\n\ --print-opcodes print the list of instructions with syntax\n\ + --xgate-ramoffset offset ram addresses by 0xc000\n\ --generate-example generate an example of each instruction\n\ (used for testing)\n"), default_cpu); @@ -490,13 +533,26 @@ md_parse_option (int c, char *arg) elf_flags |= E_M68HC11_F64; break; + case OPTION_XGATE_RAMOFFSET: + elf_flags |= E_M68HC11_XGATE_RAMOFFSET; + break; + case 'm': - if (strcasecmp (arg, "68hc11") == 0) + if ((strcasecmp (arg, "68hc11") == 0) + || (strcasecmp (arg, "m68hc11") == 0)) current_architecture = cpu6811; - else if (strcasecmp (arg, "68hc12") == 0) + else if ((strcasecmp (arg, "68hc12") == 0) + || (strcasecmp (arg, "m68hc12") == 0)) current_architecture = cpu6812; - else if (strcasecmp (arg, "68hcs12") == 0) + else if ((strcasecmp (arg, "68hcs12") == 0) + || (strcasecmp (arg, "m68hcs12") == 0)) current_architecture = cpu6812 | cpu6812s; + else if (strcasecmp (arg, "m9s12x") == 0) + current_architecture = cpu6812 | cpu6812s | cpu9s12x; + else if ((strcasecmp (arg, "m9s12xg") == 0) + || (strcasecmp (arg, "xgate") == 0)) + /* xgate for backwards compatability */ + current_architecture = cpuxgate; else as_bad (_("Option `%s' is not recognized."), arg); break; @@ -614,23 +670,39 @@ md_begin (void) /* See how many operands this opcode needs. */ expect = 0; - if (opcodes->format & M6811_OP_MASK) - expect++; - if (opcodes->format & M6811_OP_BITMASK) - expect++; - if (opcodes->format & (M6811_OP_JUMP_REL | M6812_OP_JUMP_REL16)) - expect++; - if (opcodes->format & (M6812_OP_IND16_P2 | M6812_OP_IDX_P2)) - expect++; - /* Special case for call instruction. */ - if ((opcodes->format & M6812_OP_PAGE) - && !(opcodes->format & M6811_OP_IND16)) - expect++; + if (opcodes->arch == cpuxgate) + { + if (opcodes->format & (M68XG_OP_IMM3 | M68XG_OP_R | M68XG_OP_REL9 + | M68XG_OP_REL10 )) + expect = 1; + else if (opcodes->format & (M68XG_OP_R_R | M68XG_OP_R_IMM4 + | M68XG_OP_R_IMM8 | M68XG_OP_R_IMM8)) + expect = 2; + else if (opcodes->format & (M68XG_OP_R_R_R | M68XG_OP_R_R_OFFS5 + | M68XG_OP_RD_RB_RI | M68XG_OP_RD_RB_RIp + | M68XG_OP_RD_RB_mRI)) + expect = 3; + } + else + { + if (opcodes->format & M6811_OP_MASK) + expect++; + if (opcodes->format & M6811_OP_BITMASK) + expect++; + if (opcodes->format & (M6811_OP_JUMP_REL | M6812_OP_JUMP_REL16)) + expect++; + if (opcodes->format & (M6812_OP_IND16_P2 | M6812_OP_IDX_P2)) + expect++; + /* Special case for call instruction. */ + if ((opcodes->format & M6812_OP_PAGE) + && !(opcodes->format & M6811_OP_IND16)) + expect++; + } if (expect < opc->min_operands) opc->min_operands = expect; if (IS_CALL_SYMBOL (opcodes->format)) - expect++; + expect++; if (expect > opc->max_operands) opc->max_operands = expect; } @@ -654,6 +726,7 @@ m68hc11_init_after_args (void) /* Return a string that represents the operand format for the instruction. When example is true, this generates an example of operand. This is used to give an example and also to generate a test. */ + static char * print_opcode_format (struct m68hc11_opcode *opcode, int example) { @@ -663,111 +736,222 @@ print_opcode_format (struct m68hc11_opcode *opcode, int example) p = buf; buf[0] = 0; - if (format & M6811_OP_IMM8) - { - if (example) - sprintf (p, "#%d", rand () & 0x0FF); - else - strcpy (p, _("#")); - p = &p[strlen (p)]; - } - if (format & M6811_OP_IMM16) + if (current_architecture == cpuxgate) { - if (example) - sprintf (p, "#%d", rand () & 0x0FFFF); - else - strcpy (p, _("#")); - p = &p[strlen (p)]; + if (format & M68XG_OP_IMM3) + { + if (example) + sprintf (p, "#%d", rand () & 0x007); + else + strcpy (p, _("imm3")); + p = &p[strlen (p)]; + } + else if (format & M68XG_OP_R) + { + if (example) + sprintf (p, "R%d", rand () & 0x07); + else + strcpy (p, _("RD")); + p = &p[strlen (p)]; + } + else if (format & M68XG_OP_R_R) + { + if (example) + sprintf (p, "R%d,R%d", rand () & 0x07, rand () & 0x07); + else + strcpy (p, _("RD,RS")); + p = &p[strlen (p)]; + } + else if (format & M68XG_OP_R_IMM4) + { + if (example) + sprintf (p, "R%d,#%d", rand () & 0x07, rand () & 0x0f); + else + strcpy (p, _("RI, #imm4")); + p = &p[strlen (p)]; + } + else if (format & M68XG_OP_R_R_R) + { + if (example) + sprintf (p, "R%d,R%d,R%d", rand () & 0x07, rand () & 0x07, rand () & 0x07); + else + strcpy (p, "RD,RS1,RS2"); + p = &p[strlen (p)]; + } + else if (format & M68XG_OP_REL9) + { + if (example) + sprintf (p, "%d", rand () & 0x1FF); + else + strcpy (p, ""); + p = &p[strlen (p)]; + } + else if (format & M68XG_OP_REL10) + { + if (example) + sprintf (p, "%d", rand () & 0x3FF); + else + strcpy (p, ""); + p = &p[strlen (p)]; + } + else if (format & M68XG_OP_R_R_OFFS5) + { + if (example) + sprintf (p, "R%d, (R%d, #0x%x)", rand () & 0x07, rand () & 0x07, rand () & 0x1f); + else + strcpy (p, _("RD, (RI,#offs5)")); + p = &p[strlen (p)]; + } + else if (format & M68XG_OP_RD_RB_RI) + { + if (example) + sprintf (p, "R%d, (R%d, R%d)", rand () & 0x07, rand () & 0x07, rand () & 0x07); + else + strcpy (p, "RD, (RB, RI)"); + p = &p[strlen (p)]; + } + else if (format & M68XG_OP_RD_RB_RIp) + { + if (example) + sprintf (p, "R%d, (R%d, R%d+)", rand () & 0x07, rand () & 0x07, rand () & 0x07); + else + strcpy (p, "RD, (RB, RI+)"); + p = &p[strlen (p)]; + } + else if (format & M68XG_OP_RD_RB_mRI) + { + if (example) + sprintf (p, "R%d, (R%d, -R%d)", rand () & 0x07, rand () & 0x07, rand () & 0x07); + else + strcpy (p, "RD, (RB, -RI)"); + p = &p[strlen (p)]; + } + else if (format & M68XG_OP_R_IMM8) + { + if (example) + sprintf (p, "R%d, #0x%x", rand () & 0x07, rand () & 0xff); + else + strcpy (p, "RD, #imm8"); + p = &p[strlen (p)]; + } + else if (format & M68XG_OP_R_IMM16) + { + if (example) + sprintf (p, "R%d, #0x%x", rand () & 0x07, rand () & 0xffff); + else + strcpy (p, "RD, #imm16"); + p = &p[strlen (p)]; + } } - - if (format & M6811_OP_IX) + else { - if (example) - sprintf (p, "%d,X", rand () & 0x0FF); - else - strcpy (p, _(",X")); - p = &p[strlen (p)]; - } - if (format & M6811_OP_IY) - { - if (example) - sprintf (p, "%d,X", rand () & 0x0FF); - else - strcpy (p, _(",X")); - p = &p[strlen (p)]; - } + if (format & M6811_OP_IMM8) + { + if (example) + sprintf (p, "#%d", rand () & 0x0FF); + else + strcpy (p, _("#")); + p = &p[strlen (p)]; + } - if (format & M6812_OP_IDX) - { - if (example) - sprintf (p, "%d,X", rand () & 0x0FF); - else - strcpy (p, "n,r"); - p = &p[strlen (p)]; - } + if (format & M6811_OP_IMM16) + { + if (example) + sprintf (p, "#%d", rand () & 0x0FFFF); + else + strcpy (p, _("#")); + p = &p[strlen (p)]; + } - if (format & M6812_OP_PAGE) - { - if (example) - sprintf (p, ", %d", rand () & 0x0FF); - else - strcpy (p, ", "); - p = &p[strlen (p)]; - } + if (format & M6811_OP_IX) + { + if (example) + sprintf (p, "%d,X", rand () & 0x0FF); + else + strcpy (p, _(",X")); + p = &p[strlen (p)]; + } - if (format & M6811_OP_DIRECT) - { - if (example) - sprintf (p, "*Z%d", rand () & 0x0FF); - else - strcpy (p, _("*")); - p = &p[strlen (p)]; - } + if (format & M6811_OP_IY) + { + if (example) + sprintf (p, "%d,X", rand () & 0x0FF); + else + strcpy (p, _(",X")); + p = &p[strlen (p)]; + } - if (format & M6811_OP_BITMASK) - { - if (buf[0]) - *p++ = ' '; + if (format & M6812_OP_IDX) + { + if (example) + sprintf (p, "%d,X", rand () & 0x0FF); + else + strcpy (p, "n,r"); + p = &p[strlen (p)]; + } - if (example) - sprintf (p, "#$%02x", rand () & 0x0FF); - else - strcpy (p, _("#")); + if (format & M6812_OP_PAGE) + { + if (example) + sprintf (p, ", %d", rand () & 0x0FF); + else + strcpy (p, ", "); + p = &p[strlen (p)]; + } - p = &p[strlen (p)]; - if (format & M6811_OP_JUMP_REL) - *p++ = ' '; - } + if (format & M6811_OP_DIRECT) + { + if (example) + sprintf (p, "*Z%d", rand () & 0x0FF); + else + strcpy (p, _("*")); + p = &p[strlen (p)]; + } - if (format & M6811_OP_IND16) - { - if (example) - sprintf (p, _("symbol%d"), rand () & 0x0FF); - else - strcpy (p, _("")); + if (format & M6811_OP_BITMASK) + { + if (buf[0]) + *p++ = ' '; - p = &p[strlen (p)]; - } + if (example) + sprintf (p, "#$%02x", rand () & 0x0FF); + else + strcpy (p, _("#")); - if (format & (M6811_OP_JUMP_REL | M6812_OP_JUMP_REL16)) - { - if (example) + p = &p[strlen (p)]; + if (format & M6811_OP_JUMP_REL) + *p++ = ' '; + } + + if (format & M6811_OP_IND16) { - if (format & M6811_OP_BITMASK) - { - sprintf (p, ".+%d", rand () & 0x7F); - } + if (example) + sprintf (p, _("symbol%d"), rand () & 0x0FF); else + strcpy (p, _("")); + + p = &p[strlen (p)]; + } + + if (format & (M6811_OP_JUMP_REL | M6812_OP_JUMP_REL16)) + { + if (example) { - sprintf (p, "L%d", rand () & 0x0FF); + if (format & M6811_OP_BITMASK) + { + sprintf (p, ".+%d", rand () & 0x7F); + } + else + { + sprintf (p, "L%d", rand () & 0x0FF); + } } + else + strcpy (p, _("