175fd0b74Schristos /* coff information for Zilog Z80 2*e992f068Schristos Copyright (C) 2005-2022 Free Software Foundation, Inc. 375fd0b74Schristos Contributed by Arnold Metselaar <arnold_m@operamail.com> 475fd0b74Schristos 575fd0b74Schristos This program is free software; you can redistribute it and/or modify 675fd0b74Schristos it under the terms of the GNU General Public License as published by 775fd0b74Schristos the Free Software Foundation; either version 3 of the License, or 875fd0b74Schristos (at your option) any later version. 975fd0b74Schristos 1075fd0b74Schristos This program is distributed in the hope that it will be useful, 1175fd0b74Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 1275fd0b74Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1375fd0b74Schristos GNU General Public License for more details. 1475fd0b74Schristos 1575fd0b74Schristos You should have received a copy of the GNU General Public License 1675fd0b74Schristos along with this program; if not, write to the Free Software 1775fd0b74Schristos Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 1875fd0b74Schristos 1975fd0b74Schristos #define L_LNNO_SIZE 4 2075fd0b74Schristos #include "coff/external.h" 2175fd0b74Schristos 2275fd0b74Schristos /* z80 backend does not use dots in section names. */ 2375fd0b74Schristos #undef _TEXT 2475fd0b74Schristos #define _TEXT "text" 2575fd0b74Schristos #undef _DATA 2675fd0b74Schristos #define _DATA "data" 2775fd0b74Schristos #undef _BSS 2875fd0b74Schristos #define _BSS "bss" 2975fd0b74Schristos 3075fd0b74Schristos /* Type of cpu is stored in flags. */ 3175fd0b74Schristos #define F_MACHMASK 0xF000 3275fd0b74Schristos 3375fd0b74Schristos /* Z80 COFF encodes the section alignment in the section header flags */ 3475fd0b74Schristos #define COFF_ALIGN_IN_SECTION_HEADER 1 3575fd0b74Schristos #define COFF_ALIGN_IN_S_FLAGS 1 3675fd0b74Schristos #define F_ALGNMASK 0x0F00 3775fd0b74Schristos /* requires a power-of-two argument */ 38*e992f068Schristos #define COFF_ENCODE_ALIGNMENT(B,S,X) \ 39*e992f068Schristos ((S).s_flags |= (((unsigned) (X) & 0xF) << 8), true) 4075fd0b74Schristos /* result is a power of two */ 4175fd0b74Schristos #define COFF_DECODE_ALIGNMENT(X) (((X) >> 8) & 0xF) 4275fd0b74Schristos 4375fd0b74Schristos #define Z80MAGIC 0x805A 4475fd0b74Schristos 4575fd0b74Schristos #define Z80BADMAG(x) (((x).f_magic != Z80MAGIC)) 4675fd0b74Schristos 4775fd0b74Schristos /* Relocation directives. */ 4875fd0b74Schristos 4975fd0b74Schristos /* This format actually has more bits than we need. */ 5075fd0b74Schristos 5175fd0b74Schristos struct external_reloc 5275fd0b74Schristos { 5375fd0b74Schristos char r_vaddr[4]; 5475fd0b74Schristos char r_symndx[4]; 5575fd0b74Schristos char r_offset[4]; 5675fd0b74Schristos char r_type[2]; 5775fd0b74Schristos char r_stuff[2]; 5875fd0b74Schristos }; 5975fd0b74Schristos 6075fd0b74Schristos #define RELOC struct external_reloc 6175fd0b74Schristos #define RELSZ 16 62*e992f068Schristos 63*e992f068Schristos /* Z80 relocations. */ 64*e992f068Schristos #define R_IMM16 0x01 /* 16 bit abs */ 65*e992f068Schristos #define R_JR 0x02 /* jr 8 bit disp */ 66*e992f068Schristos #define R_IMM32 0x11 /* 32 bit abs */ 67*e992f068Schristos #define R_IMM8 0x22 /* 8 bit abs */ 68*e992f068Schristos 69*e992f068Schristos #define R_OFF8 0x32 /* 8 bit signed abs, for (i[xy]+d) */ 70*e992f068Schristos #define R_IMM24 0x33 /* 24 bit abs */ 71*e992f068Schristos #define R_IMM16BE 0x3A /* 16 bit abs, big endian */ 72*e992f068Schristos #define R_BYTE0 0x34 /* first (lowest) 8 bits of multibyte value */ 73*e992f068Schristos #define R_BYTE1 0x35 /* second 8 bits of multibyte value */ 74*e992f068Schristos #define R_BYTE2 0x36 /* third 8 bits of multibyte value */ 75*e992f068Schristos #define R_BYTE3 0x37 /* fourth (highest) 8 bits of multibyte value */ 76*e992f068Schristos #define R_WORD0 0x38 /* lowest 16 bits of 32 or 24 bit value */ 77*e992f068Schristos #define R_WORD1 0x39 /* highest 16 bits of 32 or 24 bit value */ 78