| 1 | /* coff information for Hitachi H8/500
|
|---|
| 2 |
|
|---|
| 3 | Copyright 2001 Free Software Foundation, Inc.
|
|---|
| 4 |
|
|---|
| 5 | This program is free software; you can redistribute it and/or modify
|
|---|
| 6 | it under the terms of the GNU General Public License as published by
|
|---|
| 7 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 8 | (at your option) any later version.
|
|---|
| 9 |
|
|---|
| 10 | This program is distributed in the hope that it will be useful,
|
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 13 | GNU General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU General Public License
|
|---|
| 16 | along with this program; if not, write to the Free Software
|
|---|
| 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|---|
| 18 |
|
|---|
| 19 | /********************** FILE HEADER **********************/
|
|---|
| 20 |
|
|---|
| 21 | struct external_filehdr {
|
|---|
| 22 | char f_magic[2]; /* magic number */
|
|---|
| 23 | char f_nscns[2]; /* number of sections */
|
|---|
| 24 | char f_timdat[4]; /* time & date stamp */
|
|---|
| 25 | char f_symptr[4]; /* file pointer to symtab */
|
|---|
| 26 | char f_nsyms[4]; /* number of symtab entries */
|
|---|
| 27 | char f_opthdr[2]; /* sizeof(optional hdr) */
|
|---|
| 28 | char f_flags[2]; /* flags */
|
|---|
| 29 | };
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 | #define H8500MAGIC 0x8500
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 | #define H8500BADMAG(x) ((0xffff && ((x).f_magic)!=H8500MAGIC))
|
|---|
| 37 |
|
|---|
| 38 | #define FILHDR struct external_filehdr
|
|---|
| 39 | #define FILHSZ 20
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 | /********************** AOUT "OPTIONAL HEADER" **********************/
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 | typedef struct
|
|---|
| 46 | {
|
|---|
| 47 | char magic[2]; /* type of file */
|
|---|
| 48 | char vstamp[2]; /* version stamp */
|
|---|
| 49 | char tsize[4]; /* text size in bytes, padded to FW bdry*/
|
|---|
| 50 | char dsize[4]; /* initialized data " " */
|
|---|
| 51 | char bsize[4]; /* uninitialized data " " */
|
|---|
| 52 | char entry[4]; /* entry pt. */
|
|---|
| 53 | char text_start[4]; /* base of text used for this file */
|
|---|
| 54 | char data_start[4]; /* base of data used for this file */
|
|---|
| 55 | }
|
|---|
| 56 | AOUTHDR;
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 | #define AOUTHDRSZ 28
|
|---|
| 60 | #define AOUTSZ 28
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 | /********************** SECTION HEADER **********************/
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 | struct external_scnhdr {
|
|---|
| 69 | char s_name[8]; /* section name */
|
|---|
| 70 | char s_paddr[4]; /* physical address, aliased s_nlib */
|
|---|
| 71 | char s_vaddr[4]; /* virtual address */
|
|---|
| 72 | char s_size[4]; /* section size */
|
|---|
| 73 | char s_scnptr[4]; /* file ptr to raw data for section */
|
|---|
| 74 | char s_relptr[4]; /* file ptr to relocation */
|
|---|
| 75 | char s_lnnoptr[4]; /* file ptr to line numbers */
|
|---|
| 76 | char s_nreloc[2]; /* number of relocation entries */
|
|---|
| 77 | char s_nlnno[2]; /* number of line number entries*/
|
|---|
| 78 | char s_flags[4]; /* flags */
|
|---|
| 79 | };
|
|---|
| 80 |
|
|---|
| 81 | /*
|
|---|
| 82 | * names of "special" sections
|
|---|
| 83 | */
|
|---|
| 84 | #define _TEXT ".text"
|
|---|
| 85 | #define _DATA ".data"
|
|---|
| 86 | #define _BSS ".bss"
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 | #define SCNHDR struct external_scnhdr
|
|---|
| 90 | #define SCNHSZ 40
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 | /********************** LINE NUMBERS **********************/
|
|---|
| 94 |
|
|---|
| 95 | /* 1 line number entry for every "breakpointable" source line in a section.
|
|---|
| 96 | * Line numbers are grouped on a per function basis; first entry in a function
|
|---|
| 97 | * grouping will have l_lnno = 0 and in place of physical address will be the
|
|---|
| 98 | * symbol table index of the function name.
|
|---|
| 99 | */
|
|---|
| 100 | struct external_lineno {
|
|---|
| 101 | union {
|
|---|
| 102 | char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
|
|---|
| 103 | char l_paddr[4]; /* (physical) address of line number */
|
|---|
| 104 | } l_addr;
|
|---|
| 105 | char l_lnno[4]; /* line number */
|
|---|
| 106 | };
|
|---|
| 107 |
|
|---|
| 108 | #define GET_LINENO_LNNO(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) (ext->l_lnno));
|
|---|
| 109 | #define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_32(abfd,val, (bfd_byte *) (ext->l_lnno));
|
|---|
| 110 |
|
|---|
| 111 | #define LINENO struct external_lineno
|
|---|
| 112 | #define LINESZ 8
|
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 | /********************** SYMBOLS **********************/
|
|---|
| 116 |
|
|---|
| 117 | #define E_SYMNMLEN 8 /* # characters in a symbol name */
|
|---|
| 118 | #define E_FILNMLEN 14 /* # characters in a file name */
|
|---|
| 119 | #define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
|
|---|
| 120 |
|
|---|
| 121 | struct external_syment
|
|---|
| 122 | {
|
|---|
| 123 | union {
|
|---|
| 124 | char e_name[E_SYMNMLEN];
|
|---|
| 125 | struct {
|
|---|
| 126 | char e_zeroes[4];
|
|---|
| 127 | char e_offset[4];
|
|---|
| 128 | } e;
|
|---|
| 129 | } e;
|
|---|
| 130 | char e_value[4];
|
|---|
| 131 | char e_scnum[2];
|
|---|
| 132 | char e_type[2];
|
|---|
| 133 | char e_sclass[1];
|
|---|
| 134 | char e_numaux[1];
|
|---|
| 135 | };
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 | #define N_BTMASK (017)
|
|---|
| 140 | #define N_TMASK (060)
|
|---|
| 141 | #define N_BTSHFT (4)
|
|---|
| 142 | #define N_TSHIFT (2)
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 | union external_auxent {
|
|---|
| 146 | struct {
|
|---|
| 147 | char x_tagndx[4]; /* str, un, or enum tag indx */
|
|---|
| 148 | union {
|
|---|
| 149 | struct {
|
|---|
| 150 | char x_lnno[2]; /* declaration line number */
|
|---|
| 151 | char x_size[2]; /* str/union/array size */
|
|---|
| 152 | } x_lnsz;
|
|---|
| 153 | char x_fsize[4]; /* size of function */
|
|---|
| 154 | } x_misc;
|
|---|
| 155 | union {
|
|---|
| 156 | struct { /* if ISFCN, tag, or .bb */
|
|---|
| 157 | char x_lnnoptr[4]; /* ptr to fcn line # */
|
|---|
| 158 | char x_endndx[4]; /* entry ndx past block end */
|
|---|
| 159 | } x_fcn;
|
|---|
| 160 | struct { /* if ISARY, up to 4 dimen. */
|
|---|
| 161 | char x_dimen[E_DIMNUM][2];
|
|---|
| 162 | } x_ary;
|
|---|
| 163 | } x_fcnary;
|
|---|
| 164 | char x_tvndx[2]; /* tv index */
|
|---|
| 165 | } x_sym;
|
|---|
| 166 |
|
|---|
| 167 | union {
|
|---|
| 168 | char x_fname[E_FILNMLEN];
|
|---|
| 169 | struct {
|
|---|
| 170 | char x_zeroes[4];
|
|---|
| 171 | char x_offset[4];
|
|---|
| 172 | } x_n;
|
|---|
| 173 | } x_file;
|
|---|
| 174 |
|
|---|
| 175 | struct {
|
|---|
| 176 | char x_scnlen[4]; /* section length */
|
|---|
| 177 | char x_nreloc[2]; /* # relocation entries */
|
|---|
| 178 | char x_nlinno[2]; /* # line numbers */
|
|---|
| 179 | } x_scn;
|
|---|
| 180 |
|
|---|
| 181 | struct {
|
|---|
| 182 | char x_tvfill[4]; /* tv fill value */
|
|---|
| 183 | char x_tvlen[2]; /* length of .tv */
|
|---|
| 184 | char x_tvran[2][2]; /* tv range */
|
|---|
| 185 | } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 | };
|
|---|
| 189 |
|
|---|
| 190 | #define SYMENT struct external_syment
|
|---|
| 191 | #define SYMESZ 18
|
|---|
| 192 | #define AUXENT union external_auxent
|
|---|
| 193 | #define AUXESZ 18
|
|---|
| 194 |
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 | /********************** RELOCATION DIRECTIVES **********************/
|
|---|
| 198 |
|
|---|
| 199 | /* The external reloc has an offset field, because some of the reloc
|
|---|
| 200 | types on the h8 don't have room in the instruction for the entire
|
|---|
| 201 | offset - eg the strange jump and high page addressing modes */
|
|---|
| 202 |
|
|---|
| 203 | struct external_reloc {
|
|---|
| 204 | char r_vaddr[4];
|
|---|
| 205 | char r_symndx[4];
|
|---|
| 206 | char r_offset[4];
|
|---|
| 207 | char r_type[2];
|
|---|
| 208 | char r_stuff[2];
|
|---|
| 209 | };
|
|---|
| 210 |
|
|---|
| 211 |
|
|---|
| 212 | #define RELOC struct external_reloc
|
|---|
| 213 | #define RELSZ 16
|
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 |
|
|---|
| 217 |
|
|---|