| 1 |
106 |
markom |
/*** coff information for Hitachi SH */
|
| 2 |
|
|
|
| 3 |
|
|
/********************** FILE HEADER **********************/
|
| 4 |
|
|
|
| 5 |
|
|
struct external_filehdr {
|
| 6 |
|
|
char f_magic[2]; /* magic number */
|
| 7 |
|
|
char f_nscns[2]; /* number of sections */
|
| 8 |
|
|
char f_timdat[4]; /* time & date stamp */
|
| 9 |
|
|
char f_symptr[4]; /* file pointer to symtab */
|
| 10 |
|
|
char f_nsyms[4]; /* number of symtab entries */
|
| 11 |
|
|
char f_opthdr[2]; /* sizeof(optional hdr) */
|
| 12 |
|
|
char f_flags[2]; /* flags */
|
| 13 |
|
|
};
|
| 14 |
|
|
|
| 15 |
|
|
|
| 16 |
|
|
|
| 17 |
|
|
#define SH_ARCH_MAGIC_BIG 0x0500
|
| 18 |
|
|
#define SH_ARCH_MAGIC_LITTLE 0x0550 /* Little endian SH */
|
| 19 |
|
|
#define SH_ARCH_MAGIC_WINCE 0x01a2 /* Windows CE - little endian */
|
| 20 |
|
|
#define SH_PE_MAGIC 0x010b
|
| 21 |
|
|
|
| 22 |
|
|
|
| 23 |
|
|
#define SHBADMAG(x) \
|
| 24 |
|
|
(((x).f_magic!=SH_ARCH_MAGIC_BIG) && \
|
| 25 |
|
|
((x).f_magic!=SH_ARCH_MAGIC_WINCE) && \
|
| 26 |
|
|
((x).f_magic!=SH_ARCH_MAGIC_LITTLE))
|
| 27 |
|
|
|
| 28 |
|
|
#define FILHDR struct external_filehdr
|
| 29 |
|
|
#define FILHSZ 20
|
| 30 |
|
|
|
| 31 |
|
|
|
| 32 |
|
|
/********************** AOUT "OPTIONAL HEADER" **********************/
|
| 33 |
|
|
|
| 34 |
|
|
|
| 35 |
|
|
typedef struct
|
| 36 |
|
|
{
|
| 37 |
|
|
char magic[2]; /* type of file */
|
| 38 |
|
|
char vstamp[2]; /* version stamp */
|
| 39 |
|
|
char tsize[4]; /* text size in bytes, padded to FW bdry*/
|
| 40 |
|
|
char dsize[4]; /* initialized data " " */
|
| 41 |
|
|
char bsize[4]; /* uninitialized data " " */
|
| 42 |
|
|
char entry[4]; /* entry pt. */
|
| 43 |
|
|
char text_start[4]; /* base of text used for this file */
|
| 44 |
|
|
char data_start[4]; /* base of data used for this file */
|
| 45 |
|
|
}
|
| 46 |
|
|
AOUTHDR;
|
| 47 |
|
|
|
| 48 |
|
|
|
| 49 |
|
|
#define AOUTHDRSZ 28
|
| 50 |
|
|
#define AOUTSZ 28
|
| 51 |
|
|
|
| 52 |
|
|
|
| 53 |
|
|
|
| 54 |
|
|
/* Define some NT default values. */
|
| 55 |
|
|
/* #define NT_IMAGE_BASE 0x400000 moved to internal.h */
|
| 56 |
|
|
#define NT_SECTION_ALIGNMENT 0x1000
|
| 57 |
|
|
#define NT_FILE_ALIGNMENT 0x200
|
| 58 |
|
|
#define NT_DEF_RESERVE 0x100000
|
| 59 |
|
|
#define NT_DEF_COMMIT 0x1000
|
| 60 |
|
|
|
| 61 |
|
|
/********************** SECTION HEADER **********************/
|
| 62 |
|
|
|
| 63 |
|
|
|
| 64 |
|
|
struct external_scnhdr {
|
| 65 |
|
|
char s_name[8]; /* section name */
|
| 66 |
|
|
char s_paddr[4]; /* physical address, aliased s_nlib */
|
| 67 |
|
|
char s_vaddr[4]; /* virtual address */
|
| 68 |
|
|
char s_size[4]; /* section size */
|
| 69 |
|
|
char s_scnptr[4]; /* file ptr to raw data for section */
|
| 70 |
|
|
char s_relptr[4]; /* file ptr to relocation */
|
| 71 |
|
|
char s_lnnoptr[4]; /* file ptr to line numbers */
|
| 72 |
|
|
char s_nreloc[2]; /* number of relocation entries */
|
| 73 |
|
|
char s_nlnno[2]; /* number of line number entries*/
|
| 74 |
|
|
char s_flags[4]; /* flags */
|
| 75 |
|
|
};
|
| 76 |
|
|
|
| 77 |
|
|
/*
|
| 78 |
|
|
* names of "special" sections
|
| 79 |
|
|
*/
|
| 80 |
|
|
#define _TEXT ".text"
|
| 81 |
|
|
#define _DATA ".data"
|
| 82 |
|
|
#define _BSS ".bss"
|
| 83 |
|
|
|
| 84 |
|
|
|
| 85 |
|
|
#define SCNHDR struct external_scnhdr
|
| 86 |
|
|
#define SCNHSZ 40
|
| 87 |
|
|
|
| 88 |
|
|
|
| 89 |
|
|
/********************** LINE NUMBERS **********************/
|
| 90 |
|
|
|
| 91 |
|
|
/* 1 line number entry for every "breakpointable" source line in a section.
|
| 92 |
|
|
* Line numbers are grouped on a per function basis; first entry in a function
|
| 93 |
|
|
* grouping will have l_lnno = 0 and in place of physical address will be the
|
| 94 |
|
|
* symbol table index of the function name.
|
| 95 |
|
|
*/
|
| 96 |
|
|
struct external_lineno {
|
| 97 |
|
|
union {
|
| 98 |
|
|
char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
|
| 99 |
|
|
char l_paddr[4]; /* (physical) address of line number */
|
| 100 |
|
|
} l_addr;
|
| 101 |
|
|
#ifdef COFF_WITH_PE
|
| 102 |
|
|
char l_lnno[2]; /* line number */
|
| 103 |
|
|
#else
|
| 104 |
|
|
char l_lnno[4]; /* line number */
|
| 105 |
|
|
#endif
|
| 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 |
|
|
#ifdef COFF_WITH_PE
|
| 113 |
|
|
#define LINESZ 6
|
| 114 |
|
|
#undef GET_LINENO_LNNO
|
| 115 |
|
|
#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) (ext->l_lnno));
|
| 116 |
|
|
#undef PUT_LINENO_LNNO
|
| 117 |
|
|
#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_16(abfd,val, (bfd_byte *) (ext->l_lnno));
|
| 118 |
|
|
#else
|
| 119 |
|
|
#define LINESZ 8
|
| 120 |
|
|
#endif
|
| 121 |
|
|
|
| 122 |
|
|
|
| 123 |
|
|
/********************** SYMBOLS **********************/
|
| 124 |
|
|
|
| 125 |
|
|
#define E_SYMNMLEN 8 /* # characters in a symbol name */
|
| 126 |
|
|
#define E_FILNMLEN 14 /* # characters in a file name */
|
| 127 |
|
|
#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
|
| 128 |
|
|
|
| 129 |
|
|
struct external_syment
|
| 130 |
|
|
{
|
| 131 |
|
|
union {
|
| 132 |
|
|
char e_name[E_SYMNMLEN];
|
| 133 |
|
|
struct {
|
| 134 |
|
|
char e_zeroes[4];
|
| 135 |
|
|
char e_offset[4];
|
| 136 |
|
|
} e;
|
| 137 |
|
|
} e;
|
| 138 |
|
|
char e_value[4];
|
| 139 |
|
|
char e_scnum[2];
|
| 140 |
|
|
char e_type[2];
|
| 141 |
|
|
char e_sclass[1];
|
| 142 |
|
|
char e_numaux[1];
|
| 143 |
|
|
};
|
| 144 |
|
|
|
| 145 |
|
|
|
| 146 |
|
|
|
| 147 |
|
|
#define N_BTMASK (017)
|
| 148 |
|
|
#define N_TMASK (060)
|
| 149 |
|
|
#define N_BTSHFT (4)
|
| 150 |
|
|
#define N_TSHIFT (2)
|
| 151 |
|
|
|
| 152 |
|
|
|
| 153 |
|
|
union external_auxent {
|
| 154 |
|
|
struct {
|
| 155 |
|
|
char x_tagndx[4]; /* str, un, or enum tag indx */
|
| 156 |
|
|
union {
|
| 157 |
|
|
struct {
|
| 158 |
|
|
char x_lnno[2]; /* declaration line number */
|
| 159 |
|
|
char x_size[2]; /* str/union/array size */
|
| 160 |
|
|
} x_lnsz;
|
| 161 |
|
|
char x_fsize[4]; /* size of function */
|
| 162 |
|
|
} x_misc;
|
| 163 |
|
|
union {
|
| 164 |
|
|
struct { /* if ISFCN, tag, or .bb */
|
| 165 |
|
|
char x_lnnoptr[4]; /* ptr to fcn line # */
|
| 166 |
|
|
char x_endndx[4]; /* entry ndx past block end */
|
| 167 |
|
|
} x_fcn;
|
| 168 |
|
|
struct { /* if ISARY, up to 4 dimen. */
|
| 169 |
|
|
char x_dimen[E_DIMNUM][2];
|
| 170 |
|
|
} x_ary;
|
| 171 |
|
|
} x_fcnary;
|
| 172 |
|
|
char x_tvndx[2]; /* tv index */
|
| 173 |
|
|
} x_sym;
|
| 174 |
|
|
|
| 175 |
|
|
union {
|
| 176 |
|
|
char x_fname[E_FILNMLEN];
|
| 177 |
|
|
struct {
|
| 178 |
|
|
char x_zeroes[4];
|
| 179 |
|
|
char x_offset[4];
|
| 180 |
|
|
} x_n;
|
| 181 |
|
|
} x_file;
|
| 182 |
|
|
|
| 183 |
|
|
struct {
|
| 184 |
|
|
char x_scnlen[4]; /* section length */
|
| 185 |
|
|
char x_nreloc[2]; /* # relocation entries */
|
| 186 |
|
|
char x_nlinno[2]; /* # line numbers */
|
| 187 |
|
|
char x_checksum[4]; /* section COMDAT checksum */
|
| 188 |
|
|
char x_associated[2]; /* COMDAT associated section index */
|
| 189 |
|
|
char x_comdat[1]; /* COMDAT selection number */
|
| 190 |
|
|
} x_scn;
|
| 191 |
|
|
|
| 192 |
|
|
struct {
|
| 193 |
|
|
char x_tvfill[4]; /* tv fill value */
|
| 194 |
|
|
char x_tvlen[2]; /* length of .tv */
|
| 195 |
|
|
char x_tvran[2][2]; /* tv range */
|
| 196 |
|
|
} x_tv; /* info about .tv section (in auxent of symbol .tv)) */
|
| 197 |
|
|
|
| 198 |
|
|
|
| 199 |
|
|
};
|
| 200 |
|
|
|
| 201 |
|
|
#define SYMENT struct external_syment
|
| 202 |
|
|
#define SYMESZ 18
|
| 203 |
|
|
#define AUXENT union external_auxent
|
| 204 |
|
|
#define AUXESZ 18
|
| 205 |
|
|
|
| 206 |
|
|
|
| 207 |
|
|
|
| 208 |
|
|
/********************** RELOCATION DIRECTIVES **********************/
|
| 209 |
|
|
|
| 210 |
|
|
/* The external reloc has an offset field, because some of the reloc
|
| 211 |
|
|
types on the h8 don't have room in the instruction for the entire
|
| 212 |
|
|
offset - eg the strange jump and high page addressing modes */
|
| 213 |
|
|
|
| 214 |
|
|
#ifndef COFF_WITH_PE
|
| 215 |
|
|
struct external_reloc {
|
| 216 |
|
|
char r_vaddr[4];
|
| 217 |
|
|
char r_symndx[4];
|
| 218 |
|
|
char r_offset[4];
|
| 219 |
|
|
char r_type[2];
|
| 220 |
|
|
char r_stuff[2];
|
| 221 |
|
|
};
|
| 222 |
|
|
#else
|
| 223 |
|
|
struct external_reloc {
|
| 224 |
|
|
char r_vaddr[4];
|
| 225 |
|
|
char r_symndx[4];
|
| 226 |
|
|
char r_type[2];
|
| 227 |
|
|
};
|
| 228 |
|
|
#endif
|
| 229 |
|
|
|
| 230 |
|
|
|
| 231 |
|
|
#define RELOC struct external_reloc
|
| 232 |
|
|
#ifdef COFF_WITH_PE
|
| 233 |
|
|
#define RELSZ 10
|
| 234 |
|
|
#else
|
| 235 |
|
|
#define RELSZ 16
|
| 236 |
|
|
#endif
|
| 237 |
|
|
|
| 238 |
|
|
/* SH relocation types. Not all of these are actually used. */
|
| 239 |
|
|
|
| 240 |
|
|
#define R_SH_UNUSED 0 /* only used internally */
|
| 241 |
|
|
#define R_SH_IMM32CE 2 /* 32 bit immediate for WinCE */
|
| 242 |
|
|
#define R_SH_PCREL8 3 /* 8 bit pcrel */
|
| 243 |
|
|
#define R_SH_PCREL16 4 /* 16 bit pcrel */
|
| 244 |
|
|
#define R_SH_HIGH8 5 /* high 8 bits of 24 bit address */
|
| 245 |
|
|
#define R_SH_LOW16 7 /* low 16 bits of 24 bit immediate */
|
| 246 |
|
|
#define R_SH_IMM24 6 /* 24 bit immediate */
|
| 247 |
|
|
#define R_SH_PCDISP8BY4 9 /* PC rel 8 bits *4 +ve */
|
| 248 |
|
|
#define R_SH_PCDISP8BY2 10 /* PC rel 8 bits *2 +ve */
|
| 249 |
|
|
#define R_SH_PCDISP8 11 /* 8 bit branch */
|
| 250 |
|
|
#define R_SH_PCDISP 12 /* 12 bit branch */
|
| 251 |
|
|
#define R_SH_IMM32 14 /* 32 bit immediate */
|
| 252 |
|
|
#define R_SH_IMM8 16 /* 8 bit immediate */
|
| 253 |
|
|
#define R_SH_IMAGEBASE 16 /* Windows CE */
|
| 254 |
|
|
#define R_SH_IMM8BY2 17 /* 8 bit immediate *2 */
|
| 255 |
|
|
#define R_SH_IMM8BY4 18 /* 8 bit immediate *4 */
|
| 256 |
|
|
#define R_SH_IMM4 19 /* 4 bit immediate */
|
| 257 |
|
|
#define R_SH_IMM4BY2 20 /* 4 bit immediate *2 */
|
| 258 |
|
|
#define R_SH_IMM4BY4 21 /* 4 bit immediate *4 */
|
| 259 |
|
|
#define R_SH_PCRELIMM8BY2 22 /* PC rel 8 bits *2 unsigned */
|
| 260 |
|
|
#define R_SH_PCRELIMM8BY4 23 /* PC rel 8 bits *4 unsigned */
|
| 261 |
|
|
#define R_SH_IMM16 24 /* 16 bit immediate */
|
| 262 |
|
|
|
| 263 |
|
|
/* The switch table reloc types are used for relaxing. They are
|
| 264 |
|
|
generated for expressions such as
|
| 265 |
|
|
.word L1 - L2
|
| 266 |
|
|
The r_offset field holds the difference between the reloc address
|
| 267 |
|
|
and L2. */
|
| 268 |
|
|
#define R_SH_SWITCH8 33 /* 8 bit switch table entry */
|
| 269 |
|
|
#define R_SH_SWITCH16 25 /* 16 bit switch table entry */
|
| 270 |
|
|
#define R_SH_SWITCH32 26 /* 32 bit switch table entry */
|
| 271 |
|
|
|
| 272 |
|
|
/* The USES reloc type is used for relaxing. The compiler will
|
| 273 |
|
|
generate .uses pseudo-ops when it finds a function call which it
|
| 274 |
|
|
can relax. The r_offset field of the USES reloc holds the PC
|
| 275 |
|
|
relative offset to the instruction which loads the register used in
|
| 276 |
|
|
the function call. */
|
| 277 |
|
|
#define R_SH_USES 27 /* .uses pseudo-op */
|
| 278 |
|
|
|
| 279 |
|
|
/* The COUNT reloc type is used for relaxing. The assembler will
|
| 280 |
|
|
generate COUNT relocs for addresses referred to by the register
|
| 281 |
|
|
loads associated with USES relocs. The r_offset field of the COUNT
|
| 282 |
|
|
reloc holds the number of times the address is referenced in the
|
| 283 |
|
|
object file. */
|
| 284 |
|
|
#define R_SH_COUNT 28 /* Count of constant pool uses */
|
| 285 |
|
|
|
| 286 |
|
|
/* The ALIGN reloc type is used for relaxing. The r_offset field is
|
| 287 |
|
|
the power of two to which subsequent portions of the object file
|
| 288 |
|
|
must be aligned. */
|
| 289 |
|
|
#define R_SH_ALIGN 29 /* .align pseudo-op */
|
| 290 |
|
|
|
| 291 |
|
|
/* The CODE and DATA reloc types are used for aligning load and store
|
| 292 |
|
|
instructions. The assembler will generate a CODE reloc before a
|
| 293 |
|
|
block of instructions. It will generate a DATA reloc before data.
|
| 294 |
|
|
A section should be processed assuming it contains data, unless a
|
| 295 |
|
|
CODE reloc is seen. The only relevant pieces of information in the
|
| 296 |
|
|
CODE and DATA relocs are the section and the address. The symbol
|
| 297 |
|
|
and offset are meaningless. */
|
| 298 |
|
|
#define R_SH_CODE 30 /* start of code */
|
| 299 |
|
|
#define R_SH_DATA 31 /* start of data */
|
| 300 |
|
|
|
| 301 |
|
|
/* The LABEL reloc type is used for aligning load and store
|
| 302 |
|
|
instructions. The assembler will generate a LABEL reloc for each
|
| 303 |
|
|
label within a block of instructions. This permits the linker to
|
| 304 |
|
|
avoid swapping instructions which are the targets of branches. */
|
| 305 |
|
|
#define R_SH_LABEL 32 /* label */
|
| 306 |
|
|
|
| 307 |
|
|
/* NB: R_SH_SWITCH8 is 33 */
|
| 308 |
|
|
|
| 309 |
|
|
#define R_SH_LOOP_START 34
|
| 310 |
|
|
#define R_SH_LOOP_END 35
|