From 6655dba246bd164d953fe220a0e3d4eed85bb268 Mon Sep 17 00:00:00 2001 From: Sergey Belyashov Date: Thu, 2 Jan 2020 14:10:40 +0000 Subject: Add support for the GBZ80, Z180, and eZ80 variants of the Z80 architecure. Add an ELF based target for these as well. PR 25224 bfd * Makefile.am: Add z80-elf target support. * configure.ac: Likewise. * targets.c: Likewise. * config.bfd: Add z80-elf target support and new arches: ez80 and z180. * elf32-z80.c: New file. * archures.c: Add new z80 architectures: eZ80 and Z180. * coffcode.h: Likewise. * cpu-z80.c: Likewise. * bfd-in2.h: Likewise plus additional Z80 relocations. * coff-z80.c: Add new relocations for Z80 target and local label check. gas * config/tc-z80.c: Add new architectures: Z180 and eZ80. Add support for assembler code generated by SDCC. Add new relocation types. Add z80-elf target support. * config/tc-z80.h: Add z80-elf target support. Enable dollar local labels. Local labels starts from ".L". * testsuite/gas/all/fwdexp.d: Fix failure due to symbol conflict. * testsuite/gas/all/fwdexp.s: Likewise. * testsuite/gas/z80/suffix.d: Fix failure on ELF target. * testsuite/gas/z80/z80.exp: Add new tests * testsuite/gas/z80/dollar.d: New file. * testsuite/gas/z80/dollar.s: New file. * testsuite/gas/z80/ez80_adl_all.d: New file. * testsuite/gas/z80/ez80_adl_all.s: New file. * testsuite/gas/z80/ez80_adl_suf.d: New file. * testsuite/gas/z80/ez80_isuf.s: New file. * testsuite/gas/z80/ez80_z80_all.d: New file. * testsuite/gas/z80/ez80_z80_all.s: New file. * testsuite/gas/z80/ez80_z80_suf.d: New file. * testsuite/gas/z80/r800_extra.d: New file. * testsuite/gas/z80/r800_extra.s: New file. * testsuite/gas/z80/r800_ii8.d: New file. * testsuite/gas/z80/r800_z80_doc.d: New file. * testsuite/gas/z80/z180.d: New file. * testsuite/gas/z80/z180.s: New file. * testsuite/gas/z80/z180_z80_doc.d: New file. * testsuite/gas/z80/z80_doc.d: New file. * testsuite/gas/z80/z80_doc.s: New file. * testsuite/gas/z80/z80_ii8.d: New file. * testsuite/gas/z80/z80_ii8.s: New file. * testsuite/gas/z80/z80_in_f_c.d: New file. * testsuite/gas/z80/z80_in_f_c.s: New file. * testsuite/gas/z80/z80_op_ii_ld.d: New file. * testsuite/gas/z80/z80_op_ii_ld.s: New file. * testsuite/gas/z80/z80_out_c_0.d: New file. * testsuite/gas/z80/z80_out_c_0.s: New file. * testsuite/gas/z80/z80_reloc.d: New file. * testsuite/gas/z80/z80_reloc.s: New file. * testsuite/gas/z80/z80_sli.d: New file. * testsuite/gas/z80/z80_sli.s: New file. ld * Makefile.am: Add new target z80-elf * configure.tgt: Likewise. * emultempl/z80.em: Add support for eZ80 and Z180 architectures. * emulparams/elf32z80.sh: New file. * emultempl/z80elf.em: Likewise. * testsuite/ld-z80/arch_ez80_adl.d: Likewise. * testsuite/ld-z80/arch_ez80_z80.d: Likewise. * testsuite/ld-z80/arch_r800.d: Likewise. * testsuite/ld-z80/arch_z180.d: Likewise. * testsuite/ld-z80/arch_z80.d: Likewise. * testsuite/ld-z80/comb_arch_ez80_z80.d: Likewise. * testsuite/ld-z80/comb_arch_z180.d: Likewise. * testsuite/ld-z80/labels.s: Likewise. * testsuite/ld-z80/relocs.s: Likewise. * testsuite/ld-z80/relocs_b_ez80.d: Likewise. * testsuite/ld-z80/relocs_b_z80.d: Likewise. * testsuite/ld-z80/relocs_f_z80.d: Likewise. * testsuite/ld-z80/z80.exp: Likewise. opcodes * z80-dis.c: Add support for eZ80 and Z80 instructions. --- include/ChangeLog | 4 ++++ include/coff/internal.h | 6 ++++++ include/elf/z80.h | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 include/elf/z80.h (limited to 'include') diff --git a/include/ChangeLog b/include/ChangeLog index bc66851..e28c168 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2020-01-02 Sergey Belyashov + + * coff/internal.h: Add defintions of Z80 reloc names. + 2020-01-02 Christian Biesinger * opcode/s12z.h: Undef REG_Y. diff --git a/include/coff/internal.h b/include/coff/internal.h index f7ff2cd..24ac1dc 100644 --- a/include/coff/internal.h +++ b/include/coff/internal.h @@ -808,5 +808,11 @@ struct internal_reloc #define R_OFF8 0x32 /* 8 bit signed abs, for (i[xy]+d) */ #define R_IMM24 0x33 /* 24 bit abs */ /* R_JR, R_IMM8, R_IMM16, R_IMM32 - as for Z8k */ +#define R_BYTE0 0x34 /* first (lowest) 8 bits of multibyte value */ +#define R_BYTE1 0x35 /* second 8 bits of multibyte value */ +#define R_BYTE2 0x36 /* third 8 bits of multibyte value */ +#define R_BYTE3 0x37 /* fourth (highest) 8 bits of multibyte value */ +#define R_WORD0 0x38 /* lowest 16 bits of 32 or 24 bit value */ +#define R_WORD1 0x39 /* highest 16 bits of 32 or 24 bit value */ #endif /* GNU_COFF_INTERNAL_H */ diff --git a/include/elf/z80.h b/include/elf/z80.h new file mode 100644 index 0000000..a7f72c9 --- /dev/null +++ b/include/elf/z80.h @@ -0,0 +1,52 @@ +/* Z80 ELF support for BFD. + Copyright (C) 1999-2019 Free Software Foundation, Inc. + Contributed by Sergey Belyashov + + 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. */ + +#ifndef _ELF_Z80_H +#define _ELF_Z80_H + +#include "elf/reloc-macros.h" + +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_Z80_MACH_Z80 0x01 +#define EF_Z80_MACH_Z180 0x02 +#define EF_Z80_MACH_R800 0x03 +#define EF_Z80_MACH_EZ80_Z80 0x04 +#define EF_Z80_MACH_EZ80_ADL 0x84 +#define EF_Z80_MACH_GBZ80 0x05 +#define EF_Z80_MACH_MSK 0xff + +/* Relocations. */ +START_RELOC_NUMBERS (elf_z80_reloc_type) + RELOC_NUMBER (R_Z80_NONE, 0) + RELOC_NUMBER (R_Z80_8, 1) + RELOC_NUMBER (R_Z80_8_DIS, 2) + RELOC_NUMBER (R_Z80_8_PCREL, 3) + RELOC_NUMBER (R_Z80_16, 4) + RELOC_NUMBER (R_Z80_24, 5) + RELOC_NUMBER (R_Z80_32, 6) + RELOC_NUMBER (R_Z80_BYTE0, 7) + RELOC_NUMBER (R_Z80_BYTE1, 8) + RELOC_NUMBER (R_Z80_BYTE2, 9) + RELOC_NUMBER (R_Z80_BYTE3, 10) + RELOC_NUMBER (R_Z80_WORD0, 11) + RELOC_NUMBER (R_Z80_WORD1, 12) +END_RELOC_NUMBERS (R_Z80_max) + +#endif /* _ELF_Z80_H */ -- cgit v1.1