Skip to content

Commit 9fc0b50

Browse files
b-s-anickclifton
authored andcommitted
Add support for the GBZ80 and Z80N variants of the Z80 architecture, and add DWARF debug info support to the Z80 assembler.
PR 25469 bfd * archures.c: Add GBZ80 and Z80N machine values. * reloc.c: Add BFD_RELOC_Z80_16_BE. * coff-z80.c: Add support for new reloc. * coffcode.h: Add support for new machine values. * cpu-z80.c: Add support for new machine names. * elf32-z80.c: Add support for new reloc. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. binutils* readelf.c (get_machine_flags): Add support for Z80N machine number. gas * config/tc-z80.c: Add -gbz80 command line option to generate code for the GameBoy Z80. Add support for generating DWARF. * config/tc-z80.h: Add support for DWARF debug information generation. * doc/c-z80.texi: Document new command line option. * testsuite/gas/z80/gbz80_all.d: New file. * testsuite/gas/z80/gbz80_all.s: New file. * testsuite/gas/z80/z80.exp: Run the new tests. * testsuite/gas/z80/z80n_all.d: New file. * testsuite/gas/z80/z80n_all.s: New file. * testsuite/gas/z80/z80n_reloc.d: New file. include * coff/internal.h (R_IMM16BE): Define. * elf/z80.h (EF_Z80_MACH_Z80N): Define. (R_Z80_16_BE): New reloc. ld * emulparams/elf32z80.sh: Use z80 emulation. * emultempl/z80.em: Make generic to both COFF and ELF Z80 emulations. * emultempl/z80elf.em: Delete. * testsuite/ld-elf/pr22450.d: Expect to fail for the Z80. * testsuite/ld-elf/sec64k.exp: Fix Z80 assembly. * testsuite/ld-unique/pr21529.s: Avoid register name conflict. * testsuite/ld-unique/unique.s: Likewise. * testsuite/ld-unique/unique_empty.s: Likewise. * testsuite/ld-unique/unique_shared.s: Likewise. * testsuite/ld-unique/unique.d: Updated expected output. * testsuite/ld-z80/arch_z80n.d: New file. * testsuite/ld-z80/comb_arch_z80_z80n.d: New file. * testsuite/ld-z80/labels.s: Add more labels. * testsuite/ld-z80/relocs.s: Add more reloc tests. * testsuite/ld-z80/relocs_f_z80n.d: New file opcodes * z80-dis.c: Add support for GBZ80 opcodes.
1 parent adb8754 commit 9fc0b50

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+4860
-464
lines changed

bfd/ChangeLog

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2020-02-07 Sergey Belyashov <[email protected]>
2+
3+
PR 25469
4+
* archures.c: Add GBZ80 and Z80N machine values.
5+
* reloc.c: Add BFD_RELOC_Z80_16_BE.
6+
* coff-z80.c: Add support for new reloc.
7+
* coffcode.h: Add support for new machine values.
8+
* cpu-z80.c: Add support for new machine names.
9+
* elf32-z80.c: Add support for new reloc.
10+
* bfd-in2.h: Regenerate.
11+
* libbfd.h: Regenerate.
12+
113
2020-02-07 Nick Clifton <[email protected]>
214

315
PR 23932

bfd/archures.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -504,14 +504,15 @@ DESCRIPTION
504504
. bfd_arch_xtensa, {* Tensilica's Xtensa cores. *}
505505
.#define bfd_mach_xtensa 1
506506
. bfd_arch_z80,
507-
.#define bfd_mach_gbz80 0 {* GameBoy Z80 (reduced instruction set) *}
508-
.#define bfd_mach_z80strict 1 {* Z80 without undocumented opcodes. *}
509-
.#define bfd_mach_z180 2 {* Z180: successor with additional instructions, but without halves of ix and iy *}
510-
.#define bfd_mach_z80 3 {* Z80 with ixl, ixh, iyl, and iyh. *}
511-
.#define bfd_mach_ez80_z80 4 {* eZ80 (successor of Z80 & Z180) in Z80 (16-bit address) mode *}
512-
.#define bfd_mach_ez80_adl 5 {* eZ80 (successor of Z80 & Z180) in ADL (24-bit address) mode *}
513-
.#define bfd_mach_z80full 7 {* Z80 with all undocumented instructions. *}
514-
.#define bfd_mach_r800 11 {* R800: successor with multiplication. *}
507+
.#define bfd_mach_z80strict 1 {* Zilog Z80 without undocumented opcodes. *}
508+
.#define bfd_mach_z180 2 {* Zilog Z180: successor with additional instructions, but without halves of ix and iy *}
509+
.#define bfd_mach_z80 3 {* Zilog Z80 with ixl, ixh, iyl, and iyh. *}
510+
.#define bfd_mach_ez80_z80 4 {* Zilog eZ80 (successor of Z80 & Z180) in Z80 (16-bit address) mode *}
511+
.#define bfd_mach_ez80_adl 5 {* Zilog eZ80 (successor of Z80 & Z180) in ADL (24-bit address) mode *}
512+
.#define bfd_mach_z80n 6 {* Z80N *}
513+
.#define bfd_mach_z80full 7 {* Zilog Z80 with all undocumented instructions. *}
514+
.#define bfd_mach_gbz80 8 {* GameBoy Z80 (reduced instruction set) *}
515+
.#define bfd_mach_r800 11 {* Ascii R800: successor with multiplication. *}
515516
. bfd_arch_lm32, {* Lattice Mico32. *}
516517
.#define bfd_mach_lm32 1
517518
. bfd_arch_microblaze,{* Xilinx MicroBlaze. *}

bfd/bfd-in2.h

+12-8
Original file line numberDiff line numberDiff line change
@@ -1897,14 +1897,15 @@ enum bfd_architecture
18971897
bfd_arch_xtensa, /* Tensilica's Xtensa cores. */
18981898
#define bfd_mach_xtensa 1
18991899
bfd_arch_z80,
1900-
#define bfd_mach_gbz80 0 /* GameBoy Z80 (reduced instruction set) */
1901-
#define bfd_mach_z80strict 1 /* Z80 without undocumented opcodes. */
1902-
#define bfd_mach_z180 2 /* Z180: successor with additional instructions, but without halves of ix and iy */
1903-
#define bfd_mach_z80 3 /* Z80 with ixl, ixh, iyl, and iyh. */
1904-
#define bfd_mach_ez80_z80 4 /* eZ80 (successor of Z80 & Z180) in Z80 (16-bit address) mode */
1905-
#define bfd_mach_ez80_adl 5 /* eZ80 (successor of Z80 & Z180) in ADL (24-bit address) mode */
1906-
#define bfd_mach_z80full 7 /* Z80 with all undocumented instructions. */
1907-
#define bfd_mach_r800 11 /* R800: successor with multiplication. */
1900+
#define bfd_mach_z80strict 1 /* Zilog Z80 without undocumented opcodes. */
1901+
#define bfd_mach_z180 2 /* Zilog Z180: successor with additional instructions, but without halves of ix and iy */
1902+
#define bfd_mach_z80 3 /* Zilog Z80 with ixl, ixh, iyl, and iyh. */
1903+
#define bfd_mach_ez80_z80 4 /* Zilog eZ80 (successor of Z80 & Z180) in Z80 (16-bit address) mode */
1904+
#define bfd_mach_ez80_adl 5 /* Zilog eZ80 (successor of Z80 & Z180) in ADL (24-bit address) mode */
1905+
#define bfd_mach_z80n 6 /* Z80N */
1906+
#define bfd_mach_z80full 7 /* Zilog Z80 with all undocumented instructions. */
1907+
#define bfd_mach_gbz80 8 /* GameBoy Z80 (reduced instruction set) */
1908+
#define bfd_mach_r800 11 /*Ascii R800: Z80 successor with multiplication. */
19081909
bfd_arch_lm32, /* Lattice Mico32. */
19091910
#define bfd_mach_lm32 1
19101911
bfd_arch_microblaze,/* Xilinx MicroBlaze. */
@@ -5301,6 +5302,9 @@ BFD_RELOC_XTENSA_ASM_EXPAND. */
53015302
/* Highest 16 bits of multibyte (32 or 24 bit) value. */
53025303
BFD_RELOC_Z80_WORD1,
53035304

5305+
/* 16 bit word big endian */
5306+
BFD_RELOC_Z80_16_BE,
5307+
53045308
/* DJNZ offset. */
53055309
BFD_RELOC_Z8K_DISP7,
53065310

bfd/coff-z80.c

+26
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,21 @@ static bfd_howto_type howto_table[] =
221221
0, /* src_mask */
222222
0xffff, /* dst_mask */
223223
FALSE), /* pcrel_offset */
224+
225+
BFD_HOWTO (BFD_RELOC_Z80_16_BE,
226+
R_IMM16BE, /* type */
227+
0, /* rightshift */
228+
1, /* size (0 = byte, 1 = short, 2 = long) */
229+
16, /* bitsize */
230+
FALSE, /* pc_relative */
231+
0, /* bitpos */
232+
complain_overflow_bitfield, /* complain_on_overflow */
233+
0, /* special_function */
234+
"r_imm16be", /* name */
235+
FALSE, /* partial_inplace */
236+
0x0000ffff, /* src_mask */
237+
0x0000ffff, /* dst_mask */
238+
FALSE), /* pcrel_offset */
224239
};
225240

226241
#define NUM_HOWTOS ARRAY_SIZE (howto_table)
@@ -421,6 +436,17 @@ extra_case (bfd *in_abfd,
421436
break;
422437
}
423438

439+
case R_IMM16BE:
440+
if (reloc->howto->partial_inplace)
441+
val += (bfd_get_8 ( in_abfd, data+*src_ptr+0) * 0x100 +
442+
bfd_get_8 ( in_abfd, data+*src_ptr+1)) & reloc->howto->src_mask;
443+
444+
bfd_put_8 (in_abfd, val >> 8, data + *dst_ptr+0);
445+
bfd_put_8 (in_abfd, val, data + *dst_ptr+1);
446+
(*dst_ptr) += 2;
447+
(*src_ptr) += 2;
448+
break;
449+
424450
default:
425451
abort ();
426452
}

bfd/coffcode.h

+2
Original file line numberDiff line numberDiff line change
@@ -2163,6 +2163,7 @@ coff_set_arch_mach_hook (bfd *abfd, void * filehdr)
21632163
{
21642164
case bfd_mach_z80strict << 12:
21652165
case bfd_mach_z80 << 12:
2166+
case bfd_mach_z80n << 12:
21662167
case bfd_mach_z80full << 12:
21672168
case bfd_mach_r800 << 12:
21682169
case bfd_mach_gbz80 << 12:
@@ -2655,6 +2656,7 @@ coff_set_flags (bfd * abfd,
26552656
{
26562657
case bfd_mach_z80strict:
26572658
case bfd_mach_z80:
2659+
case bfd_mach_z80n:
26582660
case bfd_mach_z80full:
26592661
case bfd_mach_r800:
26602662
case bfd_mach_gbz80:

bfd/cpu-z80.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ static const bfd_arch_info_type arch_info_struct[] =
5454
N (bfd_mach_r800, "r800", 16, FALSE, M(4)),
5555
N (bfd_mach_gbz80, "gbz80", 16, FALSE, M(5)),
5656
N (bfd_mach_z180, "z180", 16, FALSE, M(6)),
57-
N (bfd_mach_ez80_z80, "ez80-z80", 16, FALSE, M(7)),
57+
N (bfd_mach_z80n, "z80n", 16, FALSE, M(7)),
58+
N (bfd_mach_ez80_z80, "ez80-z80", 16, FALSE, M(8)),
5859
N (bfd_mach_ez80_adl, "ez80-adl", 24, FALSE, NULL)
5960
};
6061

0 commit comments

Comments
 (0)