From 3c9b82baee30a1d3cfeb419643c6363dc9267208 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Tue, 25 Oct 2005 17:40:19 +0000 Subject: Add support for the Z80 processor family --- ld/ChangeLog | 10 +++++ ld/Makefile.am | 5 +++ ld/Makefile.in | 5 +++ ld/NEWS | 2 + ld/configure.tgt | 2 + ld/emulparams/z80.sh | 6 +++ ld/emultempl/z80.em | 85 +++++++++++++++++++++++++++++++++++++++ ld/scripttempl/z80.sc | 35 ++++++++++++++++ ld/testsuite/ld-checks/checks.exp | 1 + ld/testsuite/ld-scripts/align.exp | 4 ++ 10 files changed, 155 insertions(+) create mode 100644 ld/emulparams/z80.sh create mode 100644 ld/emultempl/z80.em create mode 100644 ld/scripttempl/z80.sc (limited to 'ld') diff --git a/ld/ChangeLog b/ld/ChangeLog index 24ed370..6a395b6 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,13 @@ +2005-10-25 Arnold Metselaar + + * Makefile.am: Add support for Z80 + * Makefile.in: Regenerated + * configure.tgt: Add z80-*-coff + * emulparams/z80.sh: New file. + * emultempl/z80.em: New file. + * scripttempl/z80.sc New file. + * NEWS: Mention this new support. + 2005-10-25 Alan Modra * po/ld.pot: Regenerate. diff --git a/ld/Makefile.am b/ld/Makefile.am index bada2c3..85d04bf 100644 --- a/ld/Makefile.am +++ b/ld/Makefile.am @@ -372,6 +372,7 @@ ALL_EMULATIONS = \ ew65.o \ ez8001.o \ eelf32frvfd.o \ + ez80.o \ ez8002.o ALL_64_EMULATIONS = \ @@ -1537,6 +1538,10 @@ ev850.c: $(srcdir)/emulparams/v850.sh \ ew65.c: $(srcdir)/emulparams/w65.sh \ $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/w65.sc ${GEN_DEPENDS} ${GENSCRIPTS} w65 "$(tdir_w65)" +ez80.c: $(srcdir)/emulparams/z80.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/emultempl/z80.em \ + $(srcdir)/scripttempl/z80.sc ${GEN_DEPENDS} + ${GENSCRIPTS} z80 "$(tdir_z80)" ez8001.c: $(srcdir)/emulparams/z8001.sh \ $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/z8000.sc ${GEN_DEPENDS} ${GENSCRIPTS} z8001 "$(tdir_z8001)" diff --git a/ld/Makefile.in b/ld/Makefile.in index 0acc191..8cda161 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -595,6 +595,7 @@ ALL_EMULATIONS = \ ew65.o \ ez8001.o \ eelf32frvfd.o \ + ez80.o \ ez8002.o ALL_64_EMULATIONS = \ @@ -2341,6 +2342,10 @@ ev850.c: $(srcdir)/emulparams/v850.sh \ ew65.c: $(srcdir)/emulparams/w65.sh \ $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/w65.sc ${GEN_DEPENDS} ${GENSCRIPTS} w65 "$(tdir_w65)" +ez80.c: $(srcdir)/emulparams/z80.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/emultempl/z80.em \ + $(srcdir)/scripttempl/z80.sc ${GEN_DEPENDS} + ${GENSCRIPTS} z80 "$(tdir_z80)" ez8001.c: $(srcdir)/emulparams/z8001.sh \ $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/z8000.sc ${GEN_DEPENDS} ${GENSCRIPTS} z8001 "$(tdir_z8001)" diff --git a/ld/NEWS b/ld/NEWS index bd4e14d..f38fb18 100644 --- a/ld/NEWS +++ b/ld/NEWS @@ -1,5 +1,7 @@ -*- text -*- +* Support for the Z80 processor family has been added. + * Add support for the "@" syntax to the command line, so that extra switches can be read from . diff --git a/ld/configure.tgt b/ld/configure.tgt index 23c7b2d..9f1dc8e 100644 --- a/ld/configure.tgt +++ b/ld/configure.tgt @@ -555,6 +555,8 @@ xstormy16-*-*) targ_emul=elf32xstormy16 ;; xtensa-*-*) targ_emul=elf32xtensa ;; +z80-*-coff) targ_emul=z80 + ;; z8k-*-coff) targ_emul=z8002; targ_extra_emuls=z8001 ;; *-*-ieee*) targ_emul=vanilla diff --git a/ld/emulparams/z80.sh b/ld/emulparams/z80.sh new file mode 100644 index 0000000..a4fdbd5 --- /dev/null +++ b/ld/emulparams/z80.sh @@ -0,0 +1,6 @@ +SCRIPT_NAME=z80 +OUTPUT_FORMAT="coff-z80" +OUTPUT_ARCH="z80" +TEXT_START_ADDR=0x100 +EXTRA_EM_FILE=z80 +ARCH=z80 diff --git a/ld/emultempl/z80.em b/ld/emultempl/z80.em new file mode 100644 index 0000000..d36c943 --- /dev/null +++ b/ld/emultempl/z80.em @@ -0,0 +1,85 @@ +# This shell script emits C code -*- C -*- +# to keep track of the machine type of Z80 object files +# It does some substitutions. + +LDEMUL_BEFORE_PARSE=gldz80_before_parse +LDEMUL_RECOGNIZED_FILE=gldz80_recognized_file +LDEMUL_AFTER_OPEN=gldz80_after_open + +cat >>e${EMULATION_NAME}.c <the_bfd); + switch (mach_type) + { + case bfd_mach_z80strict: + result_mach_type |= M_Z80STRICT; + break; + case bfd_mach_z80: + result_mach_type |= M_Z80; + break; + case bfd_mach_z80full: + result_mach_type |= M_Z80FULL; + break; + case bfd_mach_r800: + result_mach_type |= M_R800; + break; + default: + result_mach_type |= M_Z80ANY; + } + return FALSE; +} + +/* Set the machine type of the output file based on result_mach_type. */ +static void +gldz80_after_open (void) +{ + unsigned long mach_type; + + switch (result_mach_type) + { + case M_Z80STRICT: + mach_type = bfd_mach_z80strict; + break; + case M_Z80: + mach_type = bfd_mach_z80; + break; + case M_Z80FULL: + mach_type = bfd_mach_z80full; + break; + case M_R800: + mach_type = bfd_mach_r800; + break; + default: + mach_type = 0; + } + bfd_set_arch_mach (output_bfd, bfd_arch_z80, mach_type); +} +/* --- \end{z80.em} */ +EOF diff --git a/ld/scripttempl/z80.sc b/ld/scripttempl/z80.sc new file mode 100644 index 0000000..8c004da --- /dev/null +++ b/ld/scripttempl/z80.sc @@ -0,0 +1,35 @@ +if [ x${LD_FLAG} = x ] +then +cat << EOF +/* Create a cp/m executable; load and execute at 0x100. */ +OUTPUT_FORMAT("binary") +. = 0x100; +__Ltext = .; +ENTRY (__Ltext) +EOF +else + echo "OUTPUT_FORMAT(\"${OUTPUT_FORMAT}\")" +fi +cat <