]>
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 | ||
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 | ||
9dcfbb67 | 50 | #define ZMAGIC 0413 /* demand load format, eg normal ld output */ |
57115f09 ILT |
51 | |
52 | /********************** SECTION HEADER **********************/ | |
53 | ||
54 | struct external_scnhdr { | |
55 | unsigned char s_name[8]; /* section name */ | |
56 | unsigned char s_paddr[4]; /* physical address, aliased s_nlib */ | |
57 | unsigned char s_vaddr[4]; /* virtual address */ | |
58 | unsigned char s_size[4]; /* section size */ | |
59 | unsigned char s_scnptr[4]; /* file ptr to raw data for section */ | |
60 | unsigned char s_relptr[4]; /* file ptr to relocation */ | |
61 | unsigned char s_lnnoptr[4]; /* file ptr to line numbers */ | |
62 | unsigned char s_nreloc[2]; /* number of relocation entries */ | |
63 | unsigned char s_nlnno[2]; /* number of line number entries*/ | |
64 | unsigned char s_flags[4]; /* flags */ | |
65 | }; | |
66 | ||
67 | #define SCNHDR struct external_scnhdr | |
68 | #define SCNHSZ sizeof(SCNHDR) | |
69 | ||
70 | /* | |
71 | * names of "special" sections | |
72 | */ | |
73 | #define _TEXT ".text" | |
74 | #define _DATA ".data" | |
75 | #define _BSS ".bss" | |
76 | #define _RDATA ".rdata" | |
77 | #define _SDATA ".sdata" | |
78 | #define _SBSS ".sbss" | |
79 | #define _LIT4 ".lit4" | |
80 | #define _LIT8 ".lit8" | |
9dcfbb67 | 81 | #define _LIB ".lib" |
57115f09 ILT |
82 | |
83 | #define DEFAULT_DATA_SECTION_ALIGNMENT 4 | |
84 | #define DEFAULT_BSS_SECTION_ALIGNMENT 4 | |
85 | #define DEFAULT_TEXT_SECTION_ALIGNMENT 16 | |
86 | /* For new sections we havn't heard of before */ | |
87 | #define DEFAULT_SECTION_ALIGNMENT 4 | |
88 | ||
89 | /* MIPS ECOFF uses some additional section types. */ | |
90 | #define STYP_RDATA 0x100 | |
91 | #define STYP_SDATA 0x200 | |
92 | #define STYP_SBSS 0x400 | |
93 | #define STYP_LIT8 0x8000000 | |
94 | #define STYP_LIT4 0x10000000 | |
95 | ||
96 | /* I don't know when this is used. */ | |
97 | #define STYP_OTHER_LOAD 0x80000000 | |
98 | ||
99 | /********************** RELOCATION DIRECTIVES **********************/ | |
100 | ||
101 | struct external_reloc { | |
102 | unsigned char r_vaddr[4]; | |
9dcfbb67 | 103 | unsigned char r_bits[4]; |
57115f09 ILT |
104 | }; |
105 | ||
9dcfbb67 ILT |
106 | /* MIPS ECOFF uses a packed 8 byte format for relocs. These constants |
107 | are used to unpack the r_bits field. FIXME: Check these on a big | |
108 | endian machine. */ | |
109 | ||
110 | #define RELOC_BITS0_SYMNDX_SH_LEFT_BIG 16 | |
111 | #define RELOC_BITS0_SYMNDX_SH_LEFT_LITTLE 0 | |
112 | ||
113 | #define RELOC_BITS1_SYMNDX_SH_LEFT_BIG 8 | |
114 | #define RELOC_BITS1_SYMNDX_SH_LEFT_LITTLE 8 | |
115 | ||
116 | #define RELOC_BITS2_SYMNDX_SH_LEFT_BIG 0 | |
117 | #define RELOC_BITS2_SYMNDX_SH_LEFT_LITTLE 16 | |
118 | ||
119 | #define RELOC_BITS3_TYPE_BIG 0x3C | |
120 | #define RELOC_BITS3_TYPE_SH_BIG 2 | |
121 | #define RELOC_BITS3_TYPE_LITTLE 0x78 | |
122 | #define RELOC_BITS3_TYPE_SH_LITTLE 3 | |
123 | ||
124 | #define RELOC_BITS3_EXTERN_BIG 0x01 | |
125 | #define RELOC_BITS3_EXTERN_LITTLE 0x80 | |
126 | ||
127 | /* We store the extern field in the r_offset field of a struct | |
128 | internal_reloc. FIXME: Do this more sensibly. */ | |
129 | #define r_extern r_offset | |
57115f09 ILT |
130 | |
131 | /* Relevent values for r_type and ecoff. Would someone please document them */ | |
132 | ||
133 | #define RELOC struct external_reloc | |
9dcfbb67 | 134 | #define RELSZ 8 |
57115f09 ILT |
135 | |
136 | /* gcc uses mips-tfile to output type information in special stabs | |
137 | entries. These must match the corresponding definition in | |
138 | gcc/config/mips.h. At some point, these should probably go into a | |
139 | shared include file, but currently gcc and gdb do not share any | |
140 | directories. */ | |
141 | #define CODE_MASK 0x8F300 | |
142 | #define MIPS_IS_STAB(sym) (((sym)->index & 0xFFF00) == CODE_MASK) | |
143 | #define MIPS_MARK_STAB(code) ((code)+CODE_MASK) | |
144 | #define MIPS_UNMARK_STAB(code) ((code)-CODE_MASK) | |
145 | #define STABS_SYMBOL "@stabs" |