1 /*** coff information for Hitachi SH */
3 /********************** FILE HEADER **********************/
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 */
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 */
23 (((x).f_magic!=SH_ARCH_MAGIC_BIG) && \
24 ((x).f_magic!=SH_ARCH_MAGIC_WINCE) && \
25 ((x).f_magic!=SH_ARCH_MAGIC_LITTLE))
27 #define FILHDR struct external_filehdr
31 /********************** AOUT "OPTIONAL HEADER" **********************/
36 char magic[2]; /* type of file */
37 char vstamp[2]; /* version stamp */
38 char tsize[4]; /* text size in bytes, padded to FW bdry*/
39 char dsize[4]; /* initialized data " " */
40 char bsize[4]; /* uninitialized data " " */
41 char entry[4]; /* entry pt. */
42 char text_start[4]; /* base of text used for this file */
43 char data_start[4]; /* base of data used for this file */
53 /* Define some NT default values. */
54 /* #define NT_IMAGE_BASE 0x400000 moved to internal.h */
55 #define NT_SECTION_ALIGNMENT 0x1000
56 #define NT_FILE_ALIGNMENT 0x200
57 #define NT_DEF_RESERVE 0x100000
58 #define NT_DEF_COMMIT 0x1000
60 /********************** SECTION HEADER **********************/
63 struct external_scnhdr {
64 char s_name[8]; /* section name */
65 char s_paddr[4]; /* physical address, aliased s_nlib */
66 char s_vaddr[4]; /* virtual address */
67 char s_size[4]; /* section size */
68 char s_scnptr[4]; /* file ptr to raw data for section */
69 char s_relptr[4]; /* file ptr to relocation */
70 char s_lnnoptr[4]; /* file ptr to line numbers */
71 char s_nreloc[2]; /* number of relocation entries */
72 char s_nlnno[2]; /* number of line number entries*/
73 char s_flags[4]; /* flags */
77 * names of "special" sections
84 #define SCNHDR struct external_scnhdr
88 /********************** LINE NUMBERS **********************/
90 /* 1 line number entry for every "breakpointable" source line in a section.
91 * Line numbers are grouped on a per function basis; first entry in a function
92 * grouping will have l_lnno = 0 and in place of physical address will be the
93 * symbol table index of the function name.
95 struct external_lineno {
97 char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/
98 char l_paddr[4]; /* (physical) address of line number */
101 char l_lnno[2]; /* line number */
103 char l_lnno[4]; /* line number */
107 #define GET_LINENO_LNNO(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) (ext->l_lnno));
108 #define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_32(abfd,val, (bfd_byte *) (ext->l_lnno));
110 #define LINENO struct external_lineno
113 #undef GET_LINENO_LNNO
114 #define GET_LINENO_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) (ext->l_lnno));
115 #undef PUT_LINENO_LNNO
116 #define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_16(abfd,val, (bfd_byte *) (ext->l_lnno));
122 /********************** SYMBOLS **********************/
124 #define E_SYMNMLEN 8 /* # characters in a symbol name */
125 #define E_FILNMLEN 14 /* # characters in a file name */
126 #define E_DIMNUM 4 /* # array dimensions in auxiliary entry */
128 struct external_syment
131 char e_name[E_SYMNMLEN];
146 #define N_BTMASK (017)
147 #define N_TMASK (060)
152 union external_auxent {
154 char x_tagndx[4]; /* str, un, or enum tag indx */
157 char x_lnno[2]; /* declaration line number */
158 char x_size[2]; /* str/union/array size */
160 char x_fsize[4]; /* size of function */
163 struct { /* if ISFCN, tag, or .bb */
164 char x_lnnoptr[4]; /* ptr to fcn line # */
165 char x_endndx[4]; /* entry ndx past block end */
167 struct { /* if ISARY, up to 4 dimen. */
168 char x_dimen[E_DIMNUM][2];
171 char x_tvndx[2]; /* tv index */
175 char x_fname[E_FILNMLEN];
183 char x_scnlen[4]; /* section length */
184 char x_nreloc[2]; /* # relocation entries */
185 char x_nlinno[2]; /* # line numbers */
186 char x_checksum[4]; /* section COMDAT checksum */
187 char x_associated[2]; /* COMDAT associated section index */
188 char x_comdat[1]; /* COMDAT selection number */
192 char x_tvfill[4]; /* tv fill value */
193 char x_tvlen[2]; /* length of .tv */
194 char x_tvran[2][2]; /* tv range */
195 } x_tv; /* info about .tv section (in auxent of symbol .tv)) */
200 #define SYMENT struct external_syment
202 #define AUXENT union external_auxent
207 /********************** RELOCATION DIRECTIVES **********************/
209 /* The external reloc has an offset field, because some of the reloc
210 types on the h8 don't have room in the instruction for the entire
211 offset - eg the strange jump and high page addressing modes */
214 struct external_reloc {
222 struct external_reloc {
230 #define RELOC struct external_reloc
237 /* SH relocation types. Not all of these are actually used. */
239 #define R_SH_UNUSED 0 /* only used internally */
240 #define R_SH_IMM32CE 2 /* 32 bit immediate for WinCE */
241 #define R_SH_PCREL8 3 /* 8 bit pcrel */
242 #define R_SH_PCREL16 4 /* 16 bit pcrel */
243 #define R_SH_HIGH8 5 /* high 8 bits of 24 bit address */
244 #define R_SH_LOW16 7 /* low 16 bits of 24 bit immediate */
245 #define R_SH_IMM24 6 /* 24 bit immediate */
246 #define R_SH_PCDISP8BY4 9 /* PC rel 8 bits *4 +ve */
247 #define R_SH_PCDISP8BY2 10 /* PC rel 8 bits *2 +ve */
248 #define R_SH_PCDISP8 11 /* 8 bit branch */
249 #define R_SH_PCDISP 12 /* 12 bit branch */
250 #define R_SH_IMM32 14 /* 32 bit immediate */
251 #define R_SH_IMM8 16 /* 8 bit immediate */
252 #define R_SH_IMAGEBASE 16 /* Windows CE */
253 #define R_SH_IMM8BY2 17 /* 8 bit immediate *2 */
254 #define R_SH_IMM8BY4 18 /* 8 bit immediate *4 */
255 #define R_SH_IMM4 19 /* 4 bit immediate */
256 #define R_SH_IMM4BY2 20 /* 4 bit immediate *2 */
257 #define R_SH_IMM4BY4 21 /* 4 bit immediate *4 */
258 #define R_SH_PCRELIMM8BY2 22 /* PC rel 8 bits *2 unsigned */
259 #define R_SH_PCRELIMM8BY4 23 /* PC rel 8 bits *4 unsigned */
260 #define R_SH_IMM16 24 /* 16 bit immediate */
262 /* The switch table reloc types are used for relaxing. They are
263 generated for expressions such as
265 The r_offset field holds the difference between the reloc address
267 #define R_SH_SWITCH8 33 /* 8 bit switch table entry */
268 #define R_SH_SWITCH16 25 /* 16 bit switch table entry */
269 #define R_SH_SWITCH32 26 /* 32 bit switch table entry */
271 /* The USES reloc type is used for relaxing. The compiler will
272 generate .uses pseudo-ops when it finds a function call which it
273 can relax. The r_offset field of the USES reloc holds the PC
274 relative offset to the instruction which loads the register used in
275 the function call. */
276 #define R_SH_USES 27 /* .uses pseudo-op */
278 /* The COUNT reloc type is used for relaxing. The assembler will
279 generate COUNT relocs for addresses referred to by the register
280 loads associated with USES relocs. The r_offset field of the COUNT
281 reloc holds the number of times the address is referenced in the
283 #define R_SH_COUNT 28 /* Count of constant pool uses */
285 /* The ALIGN reloc type is used for relaxing. The r_offset field is
286 the power of two to which subsequent portions of the object file
288 #define R_SH_ALIGN 29 /* .align pseudo-op */
290 /* The CODE and DATA reloc types are used for aligning load and store
291 instructions. The assembler will generate a CODE reloc before a
292 block of instructions. It will generate a DATA reloc before data.
293 A section should be processed assuming it contains data, unless a
294 CODE reloc is seen. The only relevant pieces of information in the
295 CODE and DATA relocs are the section and the address. The symbol
296 and offset are meaningless. */
297 #define R_SH_CODE 30 /* start of code */
298 #define R_SH_DATA 31 /* start of data */
300 /* The LABEL reloc type is used for aligning load and store
301 instructions. The assembler will generate a LABEL reloc for each
302 label within a block of instructions. This permits the linker to
303 avoid swapping instructions which are the targets of branches. */
304 #define R_SH_LABEL 32 /* label */
306 /* NB: R_SH_SWITCH8 is 33 */