Commit | Line | Data |
---|---|---|
2cdeb832 KK |
1 | /*** coff information for the powerpc. */ |
2 | ||
3 | ||
4 | /********************** FILE HEADER **********************/ | |
5 | ||
6 | struct external_filehdr { | |
7 | char f_magic[2]; /* magic number */ | |
8 | char f_nscns[2]; /* number of sections */ | |
9 | char f_timdat[4]; /* time & date stamp */ | |
10 | char f_symptr[4]; /* file pointer to symtab */ | |
11 | char f_nsyms[4]; /* number of symtab entries */ | |
12 | char f_opthdr[2]; /* sizeof(optional hdr) */ | |
13 | char f_flags[2]; /* flags */ | |
14 | }; | |
15 | ||
16 | /* Bits for f_flags: | |
17 | * F_RELFLG relocation info stripped from file | |
18 | * F_EXEC file is executable (no unresolved external references) | |
19 | * F_LNNO line numbers stripped from file | |
20 | * F_LSYMS local symbols stripped from file | |
21 | * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) | |
22 | */ | |
23 | ||
24 | #define F_RELFLG (0x0001) | |
25 | #define F_EXEC (0x0002) | |
26 | #define F_LNNO (0x0004) | |
27 | #define F_LSYMS (0x0008) | |
28 | ||
29 | /* made this one up by looking at the .o on the ppc nt box */ | |
30 | #define PPCMAGIC 0760 | |
31 | ||
32 | /* extra NT defines */ | |
33 | #define DOSMAGIC 0x5a4d | |
34 | #define NT_SIGNATURE 0x00004550 | |
35 | ||
36 | #define PPCBADMAG(x) ((x).f_magic != PPCMAGIC) | |
37 | ||
38 | #define FILHDR struct external_filehdr | |
39 | #define FILHSZ sizeof(FILHDR) | |
40 | ||
41 | ||
42 | /********************** AOUT "OPTIONAL HEADER" **********************/ | |
43 | ||
44 | ||
45 | typedef struct | |
46 | { | |
47 | char magic[2]; /* type of file */ | |
48 | char vstamp[2]; /* version stamp */ | |
49 | char tsize[4]; /* text size in bytes, padded to FW bdry*/ | |
50 | char dsize[4]; /* initialized data " " */ | |
51 | char bsize[4]; /* uninitialized data " " */ | |
52 | char entry[4]; /* entry pt. */ | |
53 | char text_start[4]; /* base of text used for this file */ | |
54 | char data_start[4]; /* base of data used for this file */ | |
55 | ||
56 | ||
57 | } | |
58 | AOUTHDR; | |
59 | ||
60 | ||
61 | /* Blindly imported from coff-i386.h (krk) */ | |
62 | ||
63 | #define AOUTSZ (sizeof(AOUTHDR)) | |
64 | ||
65 | #define OMAGIC 0404 /* object files, eg as output */ | |
66 | #define ZMAGIC 0413 /* demand load format, eg normal ld output */ | |
67 | #define STMAGIC 0401 /* target shlib */ | |
68 | #define SHMAGIC 0443 /* host shlib */ | |
69 | ||
70 | ||
71 | /* define some NT default values */ | |
72 | /* #define NT_IMAGE_BASE 0x400000 moved to internal.h */ | |
73 | #define NT_SECTION_ALIGNMENT 0x1000 | |
74 | #define NT_FILE_ALIGNMENT 0x200 /* 0x1000 */ /* 0x200 */ | |
75 | #define NT_DEF_RESERVE 0x100000 | |
76 | #define NT_DEF_COMMIT 0x1000 | |
77 | ||
78 | /********************** SECTION HEADER **********************/ | |
79 | ||
80 | ||
81 | struct external_scnhdr { | |
82 | char s_name[8]; /* section name */ | |
83 | char s_paddr[4]; /* physical address, aliased s_nlib */ | |
84 | char s_vaddr[4]; /* virtual address */ | |
85 | char s_size[4]; /* section size */ | |
86 | char s_scnptr[4]; /* file ptr to raw data for section */ | |
87 | char s_relptr[4]; /* file ptr to relocation */ | |
88 | char s_lnnoptr[4]; /* file ptr to line numbers */ | |
89 | char s_nreloc[2]; /* number of relocation entries */ | |
90 | char s_nlnno[2]; /* number of line number entries*/ | |
91 | char s_flags[4]; /* flags */ | |
92 | }; | |
93 | ||
94 | #define SCNHDR struct external_scnhdr | |
95 | #define SCNHSZ sizeof(SCNHDR) | |
96 | ||
97 | /* | |
98 | * names of "special" sections | |
99 | */ | |
100 | #define _TEXT ".text" | |
101 | #define _DATA ".data" | |
102 | #define _BSS ".bss" | |
103 | #define _COMMENT ".comment" | |
104 | #define _LIB ".lib" | |
105 | ||
106 | /********************** LINE NUMBERS **********************/ | |
107 | ||
108 | /* 1 line number entry for every "breakpointable" source line in a section. | |
109 | * Line numbers are grouped on a per function basis; first entry in a function | |
110 | * grouping will have l_lnno = 0 and in place of physical address will be the | |
111 | * symbol table index of the function name. | |
112 | */ | |
113 | struct external_lineno { | |
114 | union { | |
115 | char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/ | |
116 | char l_paddr[4]; /* (physical) address of line number */ | |
117 | } l_addr; | |
118 | char l_lnno[2]; /* line number */ | |
119 | }; | |
120 | ||
121 | ||
122 | #define LINENO struct external_lineno | |
123 | #define LINESZ 6 | |
124 | ||
125 | ||
126 | /********************** SYMBOLS **********************/ | |
127 | ||
128 | #define E_SYMNMLEN 8 /* # characters in a symbol name */ | |
129 | ||
130 | ||
131 | /* Allow the file name length to be overridden */ | |
132 | #ifndef E_FILNMLEN | |
133 | #define E_FILNMLEN 14 /* # characters in a file name */ | |
134 | #endif | |
135 | ||
136 | #define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ | |
137 | ||
138 | struct external_syment | |
139 | { | |
140 | union { | |
141 | char e_name[E_SYMNMLEN]; | |
142 | struct { | |
143 | char e_zeroes[4]; | |
144 | char e_offset[4]; | |
145 | } e; | |
146 | } e; | |
147 | char e_value[4]; | |
148 | char e_scnum[2]; | |
149 | char e_type[2]; | |
150 | char e_sclass[1]; | |
151 | char e_numaux[1]; | |
152 | }; | |
153 | ||
154 | #define N_BTMASK (0xf) | |
155 | #define N_TMASK (0x30) | |
156 | #define N_BTSHFT (4) | |
157 | #define N_TSHIFT (2) | |
158 | ||
159 | union external_auxent { | |
160 | struct { | |
161 | char x_tagndx[4]; /* str, un, or enum tag indx */ | |
162 | union { | |
163 | struct { | |
164 | char x_lnno[2]; /* declaration line number */ | |
165 | char x_size[2]; /* str/union/array size */ | |
166 | } x_lnsz; | |
167 | char x_fsize[4]; /* size of function */ | |
168 | } x_misc; | |
169 | union { | |
170 | struct { /* if ISFCN, tag, or .bb */ | |
171 | char x_lnnoptr[4]; /* ptr to fcn line # */ | |
172 | char x_endndx[4]; /* entry ndx past block end */ | |
173 | } x_fcn; | |
174 | struct { /* if ISARY, up to 4 dimen. */ | |
175 | char x_dimen[E_DIMNUM][2]; | |
176 | } x_ary; | |
177 | } x_fcnary; | |
178 | char x_tvndx[2]; /* tv index */ | |
179 | } x_sym; | |
180 | ||
181 | union { | |
182 | char x_fname[E_FILNMLEN]; | |
183 | struct { | |
184 | char x_zeroes[4]; | |
185 | char x_offset[4]; | |
186 | } x_n; | |
187 | } x_file; | |
188 | ||
189 | struct { | |
190 | char x_scnlen[4]; /* section length */ | |
191 | char x_nreloc[2]; /* # relocation entries */ | |
192 | char x_nlinno[2]; /* # line numbers */ | |
193 | } x_scn; | |
194 | }; | |
195 | ||
196 | #define SYMENT struct external_syment | |
197 | #define SYMESZ 18 | |
198 | #define AUXENT union external_auxent | |
199 | #define AUXESZ 18 | |
200 | ||
201 | ||
202 | # define _ETEXT "etext" | |
203 | ||
204 | ||
205 | /********************** RELOCATION DIRECTIVES **********************/ | |
206 | ||
207 | ||
208 | ||
209 | struct external_reloc { | |
210 | char r_vaddr[4]; | |
211 | char r_symndx[4]; | |
212 | char r_type[2]; | |
213 | }; | |
214 | ||
215 | ||
216 | #define RELOC struct external_reloc | |
217 | #define RELSZ 10 | |
218 | ||
219 | #define DEFAULT_DATA_SECTION_ALIGNMENT 4 | |
220 | #define DEFAULT_BSS_SECTION_ALIGNMENT 4 | |
221 | #define DEFAULT_TEXT_SECTION_ALIGNMENT 4 | |
222 | /* For new sections we havn't heard of before */ | |
223 | #define DEFAULT_SECTION_ALIGNMENT 4 |