Fri Jan 8 16:19:26 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
[binutils-gdb.git] / include / coff / mips.h
1 /* Rudimentary ECOFF support on MIPS machines.
2 This lacks symbol information, normally provided on MIPS Unix systems
3 in the files <sym.h> and <symconst.h>. */
4
5 /********************** FILE HEADER **********************/
6
7 struct external_filehdr {
8 unsigned char f_magic[2]; /* magic number */
9 unsigned char f_nscns[2]; /* number of sections */
10 unsigned char f_timdat[4]; /* time & date stamp */
11 unsigned char f_symptr[4]; /* file pointer to symtab */
12 unsigned char f_nsyms[4]; /* number of symtab entries */
13 unsigned char f_opthdr[2]; /* sizeof(optional hdr) */
14 unsigned char f_flags[2]; /* flags */
15 };
16
17
18 /* Mips magics */
19 #define MIPS_MAGIC_1 0x0180
20 #define MIPS_MAGIC_2 0x0162
21 #define MIPS_MAGIC_3 0x0160
22
23 #define ECOFFBADMAG(x) (((x).f_magic!=MIPS_MAGIC_1) && \
24 ((x).f_magic!=MIPS_MAGIC_2) &&\
25 ((x).f_magic!=MIPS_MAGIC_3))
26
27
28 #define FILHDR struct external_filehdr
29 #define FILHSZ 20
30
31 /********************** AOUT "OPTIONAL HEADER" **********************/
32
33
34 typedef struct external_aouthdr
35 {
36 unsigned char magic[2]; /* type of file */
37 unsigned char vstamp[2]; /* version stamp */
38 unsigned char tsize[4]; /* text size in bytes, padded to FW bdry*/
39 unsigned char dsize[4]; /* initialized data " " */
40 unsigned char bsize[4]; /* uninitialized data " " */
41 unsigned char entry[4]; /* entry pt. */
42 unsigned char text_start[4]; /* base of text used for this file */
43 unsigned char data_start[4]; /* base of data used for this file */
44 } AOUTHDR;
45
46 /* compute size of a header */
47
48 #define AOUTSZ (sizeof(AOUTHDR))
49
50
51 /********************** SECTION HEADER **********************/
52
53 struct external_scnhdr {
54 unsigned char s_name[8]; /* section name */
55 unsigned char s_paddr[4]; /* physical address, aliased s_nlib */
56 unsigned char s_vaddr[4]; /* virtual address */
57 unsigned char s_size[4]; /* section size */
58 unsigned char s_scnptr[4]; /* file ptr to raw data for section */
59 unsigned char s_relptr[4]; /* file ptr to relocation */
60 unsigned char s_lnnoptr[4]; /* file ptr to line numbers */
61 unsigned char s_nreloc[2]; /* number of relocation entries */
62 unsigned char s_nlnno[2]; /* number of line number entries*/
63 unsigned char s_flags[4]; /* flags */
64 };
65
66 #define SCNHDR struct external_scnhdr
67 #define SCNHSZ sizeof(SCNHDR)
68
69 /*
70 * names of "special" sections
71 */
72 #define _TEXT ".text"
73 #define _DATA ".data"
74 #define _BSS ".bss"
75 #define _RDATA ".rdata"
76 #define _SDATA ".sdata"
77 #define _SBSS ".sbss"
78 #define _LIT4 ".lit4"
79 #define _LIT8 ".lit8"
80
81 #define DEFAULT_DATA_SECTION_ALIGNMENT 4
82 #define DEFAULT_BSS_SECTION_ALIGNMENT 4
83 #define DEFAULT_TEXT_SECTION_ALIGNMENT 16
84 /* For new sections we havn't heard of before */
85 #define DEFAULT_SECTION_ALIGNMENT 4
86
87 /* MIPS ECOFF uses some additional section types. */
88 #define STYP_RDATA 0x100
89 #define STYP_SDATA 0x200
90 #define STYP_SBSS 0x400
91 #define STYP_LIT8 0x8000000
92 #define STYP_LIT4 0x10000000
93
94 /* I don't know when this is used. */
95 #define STYP_OTHER_LOAD 0x80000000
96
97 /********************** RELOCATION DIRECTIVES **********************/
98
99 struct external_reloc {
100 unsigned char r_vaddr[4];
101 unsigned char r_symndx[4];
102 unsigned char r_type[2];
103 unsigned char pad[2];
104 };
105
106
107 /* Relevent values for r_type and ecoff. Would someone please document them */
108
109 #define RELOC struct external_reloc
110 #define RELSZ 12
111
112 /* gcc uses mips-tfile to output type information in special stabs
113 entries. These must match the corresponding definition in
114 gcc/config/mips.h. At some point, these should probably go into a
115 shared include file, but currently gcc and gdb do not share any
116 directories. */
117 #define CODE_MASK 0x8F300
118 #define MIPS_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK)
119 #define MIPS_MARK_STAB(code) ((code)+CODE_MASK)
120 #define MIPS_UNMARK_STAB(code) ((code)-CODE_MASK)
121 #define STABS_SYMBOL "@stabs"