Commit | Line | Data |
---|---|---|
57115f09 ILT |
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 | ||
a434bccf ILT |
18 | /* Mips magic numbers used in filehdr. MIPS_MAGIC_LITTLE is used on |
19 | little endian machines. MIPS_MAGIC_BIG is used on big endian | |
20 | machines. Where is MIPS_MAGIC_1 from? */ | |
57115f09 | 21 | #define MIPS_MAGIC_1 0x0180 |
a434bccf ILT |
22 | #define MIPS_MAGIC_LITTLE 0x0162 |
23 | #define MIPS_MAGIC_BIG 0x0160 | |
57115f09 ILT |
24 | |
25 | #define ECOFFBADMAG(x) (((x).f_magic!=MIPS_MAGIC_1) && \ | |
a434bccf ILT |
26 | ((x).f_magic!=MIPS_MAGIC_LITTLE) &&\ |
27 | ((x).f_magic!=MIPS_MAGIC_BIG)) | |
57115f09 ILT |
28 | |
29 | ||
30 | #define FILHDR struct external_filehdr | |
31 | #define FILHSZ 20 | |
32 | ||
33 | /********************** AOUT "OPTIONAL HEADER" **********************/ | |
34 | ||
35 | ||
36 | typedef struct external_aouthdr | |
37 | { | |
38 | unsigned char magic[2]; /* type of file */ | |
39 | unsigned char vstamp[2]; /* version stamp */ | |
40 | unsigned char tsize[4]; /* text size in bytes, padded to FW bdry*/ | |
41 | unsigned char dsize[4]; /* initialized data " " */ | |
42 | unsigned char bsize[4]; /* uninitialized data " " */ | |
43 | unsigned char entry[4]; /* entry pt. */ | |
44 | unsigned char text_start[4]; /* base of text used for this file */ | |
45 | unsigned char data_start[4]; /* base of data used for this file */ | |
a434bccf ILT |
46 | unsigned char bss_start[4]; /* base of bss used for this file */ |
47 | unsigned char gprmask[4]; /* ?? */ | |
48 | unsigned char cprmask[4][4]; /* ?? */ | |
49 | unsigned char gp_value[4]; /* value for gp register */ | |
57115f09 ILT |
50 | } AOUTHDR; |
51 | ||
52 | /* compute size of a header */ | |
53 | ||
54 | #define AOUTSZ (sizeof(AOUTHDR)) | |
55 | ||
a434bccf | 56 | #define OMAGIC 0407 /* not demand paged (ld -N). */ |
9dcfbb67 | 57 | #define ZMAGIC 0413 /* demand load format, eg normal ld output */ |
57115f09 ILT |
58 | |
59 | /********************** SECTION HEADER **********************/ | |
60 | ||
61 | struct external_scnhdr { | |
62 | unsigned char s_name[8]; /* section name */ | |
63 | unsigned char s_paddr[4]; /* physical address, aliased s_nlib */ | |
64 | unsigned char s_vaddr[4]; /* virtual address */ | |
65 | unsigned char s_size[4]; /* section size */ | |
66 | unsigned char s_scnptr[4]; /* file ptr to raw data for section */ | |
67 | unsigned char s_relptr[4]; /* file ptr to relocation */ | |
68 | unsigned char s_lnnoptr[4]; /* file ptr to line numbers */ | |
69 | unsigned char s_nreloc[2]; /* number of relocation entries */ | |
70 | unsigned char s_nlnno[2]; /* number of line number entries*/ | |
71 | unsigned char s_flags[4]; /* flags */ | |
72 | }; | |
73 | ||
74 | #define SCNHDR struct external_scnhdr | |
75 | #define SCNHSZ sizeof(SCNHDR) | |
76 | ||
77 | /* | |
78 | * names of "special" sections | |
79 | */ | |
80 | #define _TEXT ".text" | |
81 | #define _DATA ".data" | |
82 | #define _BSS ".bss" | |
83 | #define _RDATA ".rdata" | |
84 | #define _SDATA ".sdata" | |
85 | #define _SBSS ".sbss" | |
86 | #define _LIT4 ".lit4" | |
87 | #define _LIT8 ".lit8" | |
9dcfbb67 | 88 | #define _LIB ".lib" |
57115f09 ILT |
89 | |
90 | #define DEFAULT_DATA_SECTION_ALIGNMENT 4 | |
91 | #define DEFAULT_BSS_SECTION_ALIGNMENT 4 | |
92 | #define DEFAULT_TEXT_SECTION_ALIGNMENT 16 | |
93 | /* For new sections we havn't heard of before */ | |
94 | #define DEFAULT_SECTION_ALIGNMENT 4 | |
95 | ||
96 | /* MIPS ECOFF uses some additional section types. */ | |
97 | #define STYP_RDATA 0x100 | |
98 | #define STYP_SDATA 0x200 | |
99 | #define STYP_SBSS 0x400 | |
100 | #define STYP_LIT8 0x8000000 | |
101 | #define STYP_LIT4 0x10000000 | |
102 | ||
103 | /* I don't know when this is used. */ | |
104 | #define STYP_OTHER_LOAD 0x80000000 | |
105 | ||
106 | /********************** RELOCATION DIRECTIVES **********************/ | |
107 | ||
108 | struct external_reloc { | |
109 | unsigned char r_vaddr[4]; | |
9dcfbb67 | 110 | unsigned char r_bits[4]; |
57115f09 ILT |
111 | }; |
112 | ||
a434bccf ILT |
113 | #define RELOC struct external_reloc |
114 | #define RELSZ 8 | |
115 | ||
9dcfbb67 | 116 | /* MIPS ECOFF uses a packed 8 byte format for relocs. These constants |
a434bccf | 117 | are used to unpack the r_bits field. */ |
9dcfbb67 ILT |
118 | |
119 | #define RELOC_BITS0_SYMNDX_SH_LEFT_BIG 16 | |
120 | #define RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE 0 | |
121 | ||
122 | #define RELOC_BITS1_SYMNDX_SH_LEFT_BIG 8 | |
123 | #define RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE 8 | |
124 | ||
125 | #define RELOC_BITS2_SYMNDX_SH_LEFT_BIG 0 | |
126 | #define RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE 16 | |
127 | ||
a434bccf ILT |
128 | #define RELOC_BITS3_TYPE_BIG 0x1E |
129 | #define RELOC_BITS3_TYPE_SH_BIG 1 | |
9dcfbb67 ILT |
130 | #define RELOC_BITS3_TYPE_LITTLE 0x78 |
131 | #define RELOC_BITS3_TYPE_SH_LITTLE 3 | |
132 | ||
133 | #define RELOC_BITS3_EXTERN_BIG 0x01 | |
134 | #define RELOC_BITS3_EXTERN_LITTLE 0x80 | |
135 | ||
136 | /* We store the extern field in the r_offset field of a struct | |
137 | internal_reloc. FIXME: Do this more sensibly. */ | |
138 | #define r_extern r_offset | |
57115f09 | 139 | |
a434bccf ILT |
140 | /* If the extern bit is 1, then r_symndx is an index into the external |
141 | symbol table. If the extern bit is 0, then r_symndx indicates a | |
142 | section, and is one of the following values. */ | |
143 | #define RELOC_SECTION_TEXT 1 | |
144 | #define RELOC_SECTION_RDATA 2 | |
145 | #define RELOC_SECTION_DATA 3 | |
146 | #define RELOC_SECTION_SDATA 4 | |
147 | #define RELOC_SECTION_SBSS 5 | |
148 | #define RELOC_SECTION_BSS 6 | |
149 | #define RELOC_SECTION_INIT 7 | |
150 | #define RELOC_SECTION_LIT8 8 | |
151 | #define RELOC_SECTION_LIT4 9 | |
152 | ||
153 | /* The r_type field is one of the following values. I don't know if | |
154 | any other values can appear. These seem to be all that occur in | |
155 | the Ultrix 4.2 libraries. */ | |
156 | #define ECOFF_R_IGNORE 0 | |
157 | #define ECOFF_R_REFHALF 1 | |
158 | #define ECOFF_R_REFWORD 2 | |
159 | #define ECOFF_R_JMPADDR 3 | |
160 | #define ECOFF_R_REFHI 4 | |
161 | #define ECOFF_R_REFLO 5 | |
162 | #define ECOFF_R_GPREL 6 | |
163 | #define ECOFF_R_LITERAL 7 | |
164 | ||
165 | /********************** STABS **********************/ | |
57115f09 ILT |
166 | |
167 | /* gcc uses mips-tfile to output type information in special stabs | |
168 | entries. These must match the corresponding definition in | |
169 | gcc/config/mips.h. At some point, these should probably go into a | |
170 | shared include file, but currently gcc and gdb do not share any | |
171 | directories. */ | |
172 | #define CODE_MASK 0x8F300 | |
173 | #define MIPS_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK) | |
174 | #define MIPS_MARK_STAB(code) ((code)+CODE_MASK) | |
175 | #define MIPS_UNMARK_STAB(code) ((code)-CODE_MASK) | |
176 | #define STABS_SYMBOL "@stabs" | |
a434bccf ILT |
177 | |
178 | /********************** COFF **********************/ | |
179 | ||
180 | /* gcc also uses mips-tfile to output COFF debugging information. | |
181 | These are the values it uses when outputting the .type directive. | |
182 | These should also be in a shared include file. */ | |
183 | #define N_BTMASK (017) | |
184 | #define N_TMASK (060) | |
185 | #define N_BTSHFT (4) | |
186 | #define N_TSHIFT (2) |