Commit | Line | Data |
---|---|---|
db40ba14 | 1 | /* coff object file format |
01170860 | 2 | Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. |
a39116f1 RP |
3 | |
4 | This file is part of GAS. | |
5 | ||
6 | GAS is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | GAS is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with GAS; see the file COPYING. If not, write to | |
18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
db40ba14 | 19 | |
01170860 RP |
20 | #ifndef OBJ_FORMAT_H |
21 | #define OBJ_FORMAT_H | |
22 | ||
db40ba14 SC |
23 | #define OBJ_COFF 1 |
24 | ||
25 | #include "targ-cpu.h" | |
26 | ||
27 | #include "bfd.h" | |
28 | ||
29 | /*extern bfd *stdoutput;*/ | |
30 | /* This internal_lineno crap is to stop namespace pollution from the | |
31 | bfd internal coff headerfile. */ | |
32 | ||
33 | #define internal_lineno bfd_internal_lineno | |
34 | #include "coff/internal.h" | |
35 | #undef internal_lineno | |
36 | ||
37 | #if defined(TC_H8300) | |
38 | #include "coff/h8300.h" | |
39 | #define TARGET_FORMAT "coff-h8300" | |
40 | #elif defined(TC_A29K) | |
41 | #include "coff/a29k.h" | |
42 | #define TARGET_FORMAT "coff-a29k-big" | |
c593cf41 SC |
43 | |
44 | /* Allow translate from aout relocs to coff relocs */ | |
45 | #define NO_RELOC 20 | |
46 | #define RELOC_32 1 | |
47 | #define RELOC_8 2 | |
48 | #define RELOC_CONST 3 | |
49 | #define RELOC_CONSTH 4 | |
50 | #define RELOC_JUMPTARG 5 | |
51 | #define RELOC_BASE22 6 | |
52 | #define RELOC_HI22 7 | |
53 | #define RELOC_LO10 8 | |
54 | #define RELOC_BASE13 9 | |
55 | #define RELOC_WDISP22 10 | |
56 | #define RELOC_WDISP30 11 | |
db40ba14 SC |
57 | #else |
58 | help me | |
59 | #endif | |
a39116f1 | 60 | |
db40ba14 | 61 | #if 0 |
a39116f1 RP |
62 | /* Define some processor dependent values according to the processor we are |
63 | on. */ | |
db40ba14 SC |
64 | #if defined(TC_H8300) |
65 | #define BYTE_ORDERING 0 | |
66 | #define FILE_HEADER_MAGIC H8300MAGIC | |
67 | #elif defined(TC_M68K) | |
68 | ||
69 | #define BYTE_ORDERING F_AR32W /* See filehdr.h for more info. */ | |
70 | #ifndef FILE_HEADER_MAGIC | |
71 | #define FILE_HEADER_MAGIC MC68MAGIC /* ... */ | |
72 | #endif /* FILE_HEADER_MAGIC */ | |
73 | ||
74 | #elif defined(TC_I386) | |
75 | ||
76 | #define BYTE_ORDERING F_AR32WR /* See filehdr.h for more info. */ | |
77 | #ifndef FILE_HEADER_MAGIC | |
78 | #define FILE_HEADER_MAGIC I386MAGIC /* ... */ | |
79 | #endif /* FILE_HEADER_MAGIC */ | |
80 | ||
81 | #elif defined(TC_I960) | |
82 | ||
83 | #define BYTE_ORDERING F_AR32WR /* See filehdr.h for more info. */ | |
84 | #ifndef FILE_HEADER_MAGIC | |
85 | #define FILE_HEADER_MAGIC I960ROMAGIC /* ... */ | |
86 | #endif /* FILE_HEADER_MAGIC */ | |
87 | ||
88 | #elif defined(TC_A29K) | |
89 | ||
90 | #define BYTE_ORDERING F_AR32W /* big endian. */ | |
91 | #ifndef FILE_HEADER_MAGIC | |
92 | #define FILE_HEADER_MAGIC SIPFBOMAGIC | |
93 | #endif /* FILE_HEADER_MAGIC */ | |
94 | ||
95 | #else | |
96 | you lose | |
97 | #endif | |
a39116f1 | 98 | |
db40ba14 | 99 | #endif |
a39116f1 | 100 | |
db40ba14 SC |
101 | #ifndef OBJ_COFF_MAX_AUXENTRIES |
102 | #define OBJ_COFF_MAX_AUXENTRIES 1 | |
103 | #endif /* OBJ_COFF_MAX_AUXENTRIES */ | |
a39116f1 RP |
104 | |
105 | ||
106 | extern const segT N_TYPE_seg[]; | |
db40ba14 SC |
107 | |
108 | /* Magic number of paged executable. */ | |
109 | #define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE 0x8300 | |
110 | ||
111 | ||
112 | /* SYMBOL TABLE */ | |
113 | ||
a39116f1 | 114 | /* targets may also set this */ |
db40ba14 SC |
115 | #ifndef SYMBOLS_NEED_BACKPOINTERS |
116 | #define SYMBOLS_NEED_BACKPOINTERS 1 | |
117 | #endif /* SYMBOLS_NEED_BACKPOINTERS */ | |
118 | ||
119 | /* Symbol table entry data type */ | |
120 | ||
121 | typedef struct | |
122 | { | |
a39116f1 RP |
123 | struct internal_syment ost_entry; /* Basic symbol */ |
124 | union internal_auxent ost_auxent[OBJ_COFF_MAX_AUXENTRIES]; /* Auxiliary entry. */ | |
125 | ||
126 | unsigned int ost_flags; /* obj_coff internal use only flags */ | |
db40ba14 SC |
127 | } obj_symbol_type; |
128 | ||
410e67eb | 129 | #ifndef DO_NOT_STRIP |
db40ba14 SC |
130 | #define DO_NOT_STRIP 0 |
131 | #define DO_STRIP 1 | |
410e67eb | 132 | #endif |
db40ba14 SC |
133 | /* Symbol table macros and constants */ |
134 | ||
135 | /* Possible and usefull section number in symbol table | |
136 | * The values of TEXT, DATA and BSS may not be portable. | |
137 | */ | |
138 | ||
139 | #define C_ABS_SECTION N_ABS | |
140 | #define C_UNDEF_SECTION N_UNDEF | |
141 | #define C_DEBUG_SECTION N_DEBUG | |
142 | #define C_NTV_SECTION N_TV | |
143 | #define C_PTV_SECTION P_TV | |
144 | #define C_REGISTER_SECTION 20 | |
145 | ||
146 | /* | |
147 | * Macros to extract information from a symbol table entry. | |
148 | * This syntaxic indirection allows independence regarding a.out or coff. | |
149 | * The argument (s) of all these macros is a pointer to a symbol table entry. | |
150 | */ | |
151 | ||
152 | /* Predicates */ | |
153 | /* True if the symbol is external */ | |
154 | #define S_IS_EXTERNAL(s) ((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION) | |
155 | /* True if symbol has been defined, ie : | |
a39116f1 RP |
156 | section > 0 (DATA, TEXT or BSS) |
157 | section == 0 and value > 0 (external bss symbol) */ | |
db40ba14 SC |
158 | #define S_IS_DEFINED(s) ((s)->sy_symbol.ost_entry.n_scnum > C_UNDEF_SECTION || \ |
159 | ((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION && \ | |
160 | (s)->sy_symbol.ost_entry.n_value > 0)) | |
161 | /* True if a debug special symbol entry */ | |
162 | #define S_IS_DEBUG(s) ((s)->sy_symbol.ost_entry.n_scnum == C_DEBUG_SECTION) | |
163 | /* True if a symbol is local symbol name */ | |
164 | /* A symbol name whose name begin with ^A is a gas internal pseudo symbol */ | |
165 | #define S_IS_LOCAL(s) (S_GET_NAME(s)[0] == '\001' || \ | |
166 | (s)->sy_symbol.ost_entry.n_scnum == C_REGISTER_SECTION || \ | |
167 | (S_LOCAL_NAME(s) && !flagseen['L'])) | |
168 | /* True if a symbol is not defined in this file */ | |
169 | #define S_IS_EXTERN(s) ((s)->sy_symbol.ost_entry.n_scnum == 0 && (s)->sy_symbol.ost_entry.n_value == 0) | |
170 | /* | |
171 | * True if a symbol can be multiply defined (bss symbols have this def | |
172 | * though it is bad practice) | |
173 | */ | |
174 | #define S_IS_COMMON(s) ((s)->sy_symbol.ost_entry.n_scnum == 0 && (s)->sy_symbol.ost_entry.n_value != 0) | |
175 | /* True if a symbol name is in the string table, i.e. its length is > 8. */ | |
176 | #define S_IS_STRING(s) (strlen(S_GET_NAME(s)) > 8 ? 1 : 0) | |
177 | ||
178 | /* Accessors */ | |
179 | /* The name of the symbol */ | |
180 | #define S_GET_NAME(s) ((char*)(s)->sy_symbol.ost_entry.n_offset) | |
181 | /* The pointer to the string table */ | |
182 | #define S_GET_OFFSET(s) ((s)->sy_symbol.ost_entry.n_offset) | |
183 | /* The zeroes if symbol name is longer than 8 chars */ | |
184 | #define S_GET_ZEROES(s) ((s)->sy_symbol.ost_entry.n_zeroes) | |
185 | /* The value of the symbol */ | |
186 | #define S_GET_VALUE(s) ((unsigned) ((s)->sy_symbol.ost_entry.n_value)) | |
187 | /* The numeric value of the segment */ | |
188 | #define S_GET_SEGMENT(s) s_get_segment(s) | |
189 | /* The data type */ | |
190 | #define S_GET_DATA_TYPE(s) ((s)->sy_symbol.ost_entry.n_type) | |
191 | /* The storage class */ | |
192 | #define S_GET_STORAGE_CLASS(s) ((s)->sy_symbol.ost_entry.n_sclass) | |
193 | /* The number of auxiliary entries */ | |
194 | #define S_GET_NUMBER_AUXILIARY(s) ((s)->sy_symbol.ost_entry.n_numaux) | |
195 | ||
196 | /* Modifiers */ | |
197 | /* Set the name of the symbol */ | |
198 | #define S_SET_NAME(s,v) ((s)->sy_symbol.ost_entry.n_offset = (unsigned long)(v)) | |
199 | /* Set the offset of the symbol */ | |
200 | #define S_SET_OFFSET(s,v) ((s)->sy_symbol.ost_entry.n_offset = (v)) | |
201 | /* The zeroes if symbol name is longer than 8 chars */ | |
202 | #define S_SET_ZEROES(s,v) ((s)->sy_symbol.ost_entry.n_zeroes = (v)) | |
203 | /* Set the value of the symbol */ | |
204 | #define S_SET_VALUE(s,v) ((s)->sy_symbol.ost_entry.n_value = (v)) | |
205 | /* The numeric value of the segment */ | |
206 | #define S_SET_SEGMENT(s,v) ((s)->sy_symbol.ost_entry.n_scnum = SEGMENT_TO_SYMBOL_TYPE(v)) | |
207 | /* The data type */ | |
208 | #define S_SET_DATA_TYPE(s,v) ((s)->sy_symbol.ost_entry.n_type = (v)) | |
209 | /* The storage class */ | |
210 | #define S_SET_STORAGE_CLASS(s,v) ((s)->sy_symbol.ost_entry.n_sclass = (v)) | |
211 | /* The number of auxiliary entries */ | |
212 | #define S_SET_NUMBER_AUXILIARY(s,v) ((s)->sy_symbol.ost_entry.n_numaux = (v)) | |
213 | ||
214 | /* Additional modifiers */ | |
215 | /* The symbol is external (does not mean undefined) */ | |
216 | #define S_SET_EXTERNAL(s) { S_SET_STORAGE_CLASS(s, C_EXT) ; SF_CLEAR_LOCAL(s); } | |
217 | ||
218 | /* Auxiliary entry macros. SA_ stands for symbol auxiliary */ | |
219 | /* Omit the tv related fields */ | |
220 | /* Accessors */ | |
221 | #ifdef BFD_HEADERS | |
222 | #define SA_GET_SYM_TAGNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx.l) | |
223 | #else | |
224 | #define SA_GET_SYM_TAGNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx) | |
225 | #endif | |
226 | #define SA_GET_SYM_LNNO(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_lnno) | |
227 | #define SA_GET_SYM_SIZE(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_size) | |
228 | #define SA_GET_SYM_FSIZE(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_fsize) | |
229 | #define SA_GET_SYM_LNNOPTR(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_lnnoptr) | |
230 | #ifdef BFD_HEADERS | |
231 | #define SA_GET_SYM_ENDNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx.l) | |
232 | #else | |
233 | #define SA_GET_SYM_ENDNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx) | |
234 | #endif | |
235 | #define SA_GET_SYM_DIMEN(s,i) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen[(i)]) | |
236 | #define SA_GET_FILE_FNAME(s) ((s)->sy_symbol.ost_auxent[0].x_file.x_fname) | |
237 | #define SA_GET_SCN_SCNLEN(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_scnlen) | |
238 | #define SA_GET_SCN_NRELOC(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nreloc) | |
239 | #define SA_GET_SCN_NLINNO(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nlinno) | |
240 | ||
241 | /* Modifiers */ | |
242 | #ifdef BFD_HEADERS | |
243 | #define SA_SET_SYM_TAGNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx.l=(v)) | |
244 | #else | |
245 | #define SA_SET_SYM_TAGNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx=(v)) | |
246 | #endif | |
247 | #define SA_SET_SYM_LNNO(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_lnno=(v)) | |
248 | #define SA_SET_SYM_SIZE(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_size=(v)) | |
249 | #define SA_SET_SYM_FSIZE(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_fsize=(v)) | |
250 | #define SA_SET_SYM_LNNOPTR(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_lnnoptr=(v)) | |
251 | #ifdef BFD_HEADERS | |
252 | #define SA_SET_SYM_ENDNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx.l=(v)) | |
253 | #else | |
254 | #define SA_SET_SYM_ENDNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx=(v)) | |
255 | #endif | |
256 | #define SA_SET_SYM_DIMEN(s,i,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen[(i)]=(v)) | |
257 | #define SA_SET_FILE_FNAME(s,v) strncpy((s)->sy_symbol.ost_auxent[0].x_file.x_fname,(v),FILNMLEN) | |
258 | #define SA_SET_SCN_SCNLEN(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_scnlen=(v)) | |
259 | #define SA_SET_SCN_NRELOC(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nreloc=(v)) | |
260 | #define SA_SET_SCN_NLINNO(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nlinno=(v)) | |
261 | ||
262 | /* | |
263 | * Internal use only definitions. SF_ stands for symbol flags. | |
264 | * | |
265 | * These values can be assigned to sy_symbol.ost_flags field of a symbolS. | |
266 | * | |
267 | * You'll break i960 if you shift the SYSPROC bits anywhere else. for | |
268 | * more on the balname/callname hack, see tc-i960.h. b.out is done | |
269 | * differently. | |
270 | */ | |
271 | ||
272 | #define SF_I960_MASK (0x000001ff) /* Bits 0-8 are used by the i960 port. */ | |
273 | #define SF_SYSPROC (0x0000003f) /* bits 0-5 are used to store the sysproc number */ | |
274 | #define SF_IS_SYSPROC (0x00000040) /* bit 6 marks symbols that are sysprocs */ | |
275 | #define SF_BALNAME (0x00000080) /* bit 7 marks BALNAME symbols */ | |
276 | #define SF_CALLNAME (0x00000100) /* bit 8 marks CALLNAME symbols */ | |
277 | ||
278 | #define SF_NORMAL_MASK (0x0000ffff) /* bits 12-15 are general purpose. */ | |
279 | ||
280 | #define SF_STATICS (0x00001000) /* Mark the .text & all symbols */ | |
281 | #define SF_DEFINED (0x00002000) /* Symbol is defined in this file */ | |
282 | #define SF_STRING (0x00004000) /* Symbol name length > 8 */ | |
283 | #define SF_LOCAL (0x00008000) /* Symbol must not be emitted */ | |
284 | ||
285 | #define SF_DEBUG_MASK (0xffff0000) /* bits 16-31 are debug info */ | |
286 | ||
287 | #define SF_FUNCTION (0x00010000) /* The symbol is a function */ | |
288 | #define SF_PROCESS (0x00020000) /* Process symbol before write */ | |
289 | #define SF_TAGGED (0x00040000) /* Is associated with a tag */ | |
290 | #define SF_TAG (0x00080000) /* Is a tag */ | |
291 | #define SF_DEBUG (0x00100000) /* Is in debug or abs section */ | |
292 | #define SF_GET_SEGMENT (0x00200000) /* Get the section of the forward symbol. */ | |
a39116f1 | 293 | /* All other bits are unused. */ |
db40ba14 SC |
294 | |
295 | /* Accessors */ | |
296 | #define SF_GET(s) ((s)->sy_symbol.ost_flags) | |
297 | #define SF_GET_NORMAL_FIELD(s) ((s)->sy_symbol.ost_flags & SF_NORMAL_MASK) | |
298 | #define SF_GET_DEBUG_FIELD(s) ((s)->sy_symbol.ost_flags & SF_DEBUG_MASK) | |
299 | #define SF_GET_FILE(s) ((s)->sy_symbol.ost_flags & SF_FILE) | |
300 | #define SF_GET_STATICS(s) ((s)->sy_symbol.ost_flags & SF_STATICS) | |
301 | #define SF_GET_DEFINED(s) ((s)->sy_symbol.ost_flags & SF_DEFINED) | |
302 | #define SF_GET_STRING(s) ((s)->sy_symbol.ost_flags & SF_STRING) | |
303 | #define SF_GET_LOCAL(s) ((s)->sy_symbol.ost_flags & SF_LOCAL) | |
304 | #define SF_GET_FUNCTION(s) ((s)->sy_symbol.ost_flags & SF_FUNCTION) | |
305 | #define SF_GET_PROCESS(s) ((s)->sy_symbol.ost_flags & SF_PROCESS) | |
306 | #define SF_GET_DEBUG(s) ((s)->sy_symbol.ost_flags & SF_DEBUG) | |
307 | #define SF_GET_TAGGED(s) ((s)->sy_symbol.ost_flags & SF_TAGGED) | |
308 | #define SF_GET_TAG(s) ((s)->sy_symbol.ost_flags & SF_TAG) | |
309 | #define SF_GET_GET_SEGMENT(s) ((s)->sy_symbol.ost_flags & SF_GET_SEGMENT) | |
310 | #define SF_GET_I960(s) ((s)->sy_symbol.ost_flags & SF_I960_MASK) /* used by i960 */ | |
311 | #define SF_GET_BALNAME(s) ((s)->sy_symbol.ost_flags & SF_BALNAME) /* used by i960 */ | |
312 | #define SF_GET_CALLNAME(s) ((s)->sy_symbol.ost_flags & SF_CALLNAME) /* used by i960 */ | |
313 | #define SF_GET_IS_SYSPROC(s) ((s)->sy_symbol.ost_flags & SF_IS_SYSPROC) /* used by i960 */ | |
314 | #define SF_GET_SYSPROC(s) ((s)->sy_symbol.ost_flags & SF_SYSPROC) /* used by i960 */ | |
315 | ||
316 | /* Modifiers */ | |
317 | #define SF_SET(s,v) ((s)->sy_symbol.ost_flags = (v)) | |
318 | #define SF_SET_NORMAL_FIELD(s,v)((s)->sy_symbol.ost_flags |= ((v) & SF_NORMAL_MASK)) | |
319 | #define SF_SET_DEBUG_FIELD(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_DEBUG_MASK)) | |
320 | #define SF_SET_FILE(s) ((s)->sy_symbol.ost_flags |= SF_FILE) | |
321 | #define SF_SET_STATICS(s) ((s)->sy_symbol.ost_flags |= SF_STATICS) | |
322 | #define SF_SET_DEFINED(s) ((s)->sy_symbol.ost_flags |= SF_DEFINED) | |
323 | #define SF_SET_STRING(s) ((s)->sy_symbol.ost_flags |= SF_STRING) | |
324 | #define SF_SET_LOCAL(s) ((s)->sy_symbol.ost_flags |= SF_LOCAL) | |
325 | #define SF_CLEAR_LOCAL(s) ((s)->sy_symbol.ost_flags &= ~SF_LOCAL) | |
326 | #define SF_SET_FUNCTION(s) ((s)->sy_symbol.ost_flags |= SF_FUNCTION) | |
327 | #define SF_SET_PROCESS(s) ((s)->sy_symbol.ost_flags |= SF_PROCESS) | |
328 | #define SF_SET_DEBUG(s) ((s)->sy_symbol.ost_flags |= SF_DEBUG) | |
329 | #define SF_SET_TAGGED(s) ((s)->sy_symbol.ost_flags |= SF_TAGGED) | |
330 | #define SF_SET_TAG(s) ((s)->sy_symbol.ost_flags |= SF_TAG) | |
331 | #define SF_SET_GET_SEGMENT(s) ((s)->sy_symbol.ost_flags |= SF_GET_SEGMENT) | |
332 | #define SF_SET_I960(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_I960_MASK)) /* used by i960 */ | |
333 | #define SF_SET_BALNAME(s) ((s)->sy_symbol.ost_flags |= SF_BALNAME) /* used by i960 */ | |
334 | #define SF_SET_CALLNAME(s) ((s)->sy_symbol.ost_flags |= SF_CALLNAME) /* used by i960 */ | |
335 | #define SF_SET_IS_SYSPROC(s) ((s)->sy_symbol.ost_flags |= SF_IS_SYSPROC) /* used by i960 */ | |
336 | #define SF_SET_SYSPROC(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_SYSPROC)) /* used by i960 */ | |
337 | ||
338 | /* File header macro and type definition */ | |
339 | ||
340 | /* | |
341 | * File position calculators. Beware to use them when all the | |
342 | * appropriate fields are set in the header. | |
343 | */ | |
344 | ||
345 | #ifdef OBJ_COFF_OMIT_OPTIONAL_HEADER | |
346 | #define OBJ_COFF_AOUTHDRSZ (0) | |
347 | #else | |
348 | #define OBJ_COFF_AOUTHDRSZ (AOUTHDRSZ) | |
349 | #endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */ | |
350 | ||
351 | #define H_GET_FILE_SIZE(h) \ | |
352 | (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \ | |
353 | H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \ | |
354 | H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \ | |
355 | H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h) + \ | |
356 | H_GET_SYMBOL_TABLE_SIZE(h) + \ | |
357 | (h)->string_table_size) | |
358 | #define H_GET_TEXT_FILE_OFFSET(h) \ | |
359 | (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \ | |
360 | H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ) | |
361 | #define H_GET_DATA_FILE_OFFSET(h) \ | |
362 | (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \ | |
363 | H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \ | |
364 | H_GET_TEXT_SIZE(h)) | |
365 | #define H_GET_BSS_FILE_OFFSET(h) 0 | |
366 | #define H_GET_RELOCATION_FILE_OFFSET(h) \ | |
367 | (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \ | |
368 | H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \ | |
369 | H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h)) | |
370 | #define H_GET_LINENO_FILE_OFFSET(h) \ | |
371 | (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \ | |
372 | H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \ | |
373 | H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \ | |
374 | H_GET_RELOCATION_SIZE(h)) | |
375 | #define H_GET_SYMBOL_TABLE_FILE_OFFSET(h) \ | |
376 | (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \ | |
377 | H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \ | |
378 | H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \ | |
379 | H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h)) | |
380 | ||
381 | /* Accessors */ | |
382 | /* aouthdr */ | |
383 | #define H_GET_MAGIC_NUMBER(h) ((h)->aouthdr.magic) | |
384 | #define H_GET_VERSION_STAMP(h) ((h)->aouthdr.vstamp) | |
385 | #define H_GET_TEXT_SIZE(h) ((h)->aouthdr.tsize) | |
386 | #define H_GET_DATA_SIZE(h) ((h)->aouthdr.dsize) | |
387 | #define H_GET_BSS_SIZE(h) ((h)->aouthdr.bsize) | |
388 | #define H_GET_ENTRY_POINT(h) ((h)->aouthdr.entry) | |
389 | #define H_GET_TEXT_START(h) ((h)->aouthdr.text_start) | |
390 | #define H_GET_DATA_START(h) ((h)->aouthdr.data_start) | |
391 | /* filehdr */ | |
392 | #define H_GET_FILE_MAGIC_NUMBER(h) ((h)->filehdr.f_magic) | |
393 | #define H_GET_NUMBER_OF_SECTIONS(h) ((h)->filehdr.f_nscns) | |
394 | #define H_GET_TIME_STAMP(h) ((h)->filehdr.f_timdat) | |
395 | #define H_GET_SYMBOL_TABLE_POINTER(h) ((h)->filehdr.f_symptr) | |
396 | #define H_GET_SYMBOL_COUNT(h) ((h)->filehdr.f_nsyms) | |
397 | #define H_GET_SYMBOL_TABLE_SIZE(h) (H_GET_SYMBOL_COUNT(h) * SYMESZ) | |
398 | #define H_GET_SIZEOF_OPTIONAL_HEADER(h) ((h)->filehdr.f_opthdr) | |
399 | #define H_GET_FLAGS(h) ((h)->filehdr.f_flags) | |
400 | /* Extra fields to achieve bsd a.out compatibility and for convenience */ | |
401 | #define H_GET_RELOCATION_SIZE(h) ((h)->relocation_size) | |
402 | #define H_GET_STRING_SIZE(h) ((h)->string_table_size) | |
403 | #define H_GET_LINENO_SIZE(h) ((h)->lineno_size) | |
404 | ||
405 | #ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER | |
406 | #define H_GET_HEADER_SIZE(h) (sizeof(FILHDR) \ | |
407 | + sizeof(AOUTHDR)\ | |
408 | + (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ)) | |
409 | #else /* OBJ_COFF_OMIT_OPTIONAL_HEADER */ | |
410 | #define H_GET_HEADER_SIZE(h) (sizeof(FILHDR) \ | |
411 | + (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ)) | |
412 | #endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */ | |
413 | ||
414 | #define H_GET_TEXT_RELOCATION_SIZE(h) (text_section_header.s_nreloc * RELSZ) | |
415 | #define H_GET_DATA_RELOCATION_SIZE(h) (data_section_header.s_nreloc * RELSZ) | |
416 | ||
417 | /* Modifiers */ | |
418 | /* aouthdr */ | |
419 | #define H_SET_MAGIC_NUMBER(h,v) ((h)->aouthdr.magic = (v)) | |
420 | #define H_SET_VERSION_STAMP(h,v) ((h)->aouthdr.vstamp = (v)) | |
421 | #define H_SET_TEXT_SIZE(h,v) ((h)->aouthdr.tsize = (v)) | |
422 | #define H_SET_DATA_SIZE(h,v) ((h)->aouthdr.dsize = (v)) | |
423 | #define H_SET_BSS_SIZE(h,v) ((h)->aouthdr.bsize = (v)) | |
424 | #define H_SET_ENTRY_POINT(h,v) ((h)->aouthdr.entry = (v)) | |
425 | #define H_SET_TEXT_START(h,v) ((h)->aouthdr.text_start = (v)) | |
426 | #define H_SET_DATA_START(h,v) ((h)->aouthdr.data_start = (v)) | |
427 | /* filehdr */ | |
428 | #define H_SET_FILE_MAGIC_NUMBER(h,v) ((h)->filehdr.f_magic = (v)) | |
429 | #define H_SET_NUMBER_OF_SECTIONS(h,v) ((h)->filehdr.f_nscns = (v)) | |
430 | #define H_SET_TIME_STAMP(h,v) ((h)->filehdr.f_timdat = (v)) | |
431 | #define H_SET_SYMBOL_TABLE_POINTER(h,v) ((h)->filehdr.f_symptr = (v)) | |
432 | #define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->filehdr.f_nsyms = (v)) | |
433 | #define H_SET_SIZEOF_OPTIONAL_HEADER(h,v) ((h)->filehdr.f_opthdr = (v)) | |
434 | #define H_SET_FLAGS(h,v) ((h)->filehdr.f_flags = (v)) | |
435 | /* Extra fields to achieve bsd a.out compatibility and for convinience */ | |
436 | #define H_SET_RELOCATION_SIZE(h,t,d) ((h)->relocation_size = (t)+(d)) | |
437 | #define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v)) | |
438 | #define H_SET_LINENO_SIZE(h,v) ((h)->lineno_size = (v)) | |
439 | ||
a39116f1 | 440 | /* Segment flipping */ |
db40ba14 SC |
441 | #define segment_name(v) (seg_name[(int) (v)]) |
442 | ||
443 | typedef struct { | |
444 | #ifdef BFD_HEADERS | |
a39116f1 RP |
445 | struct internal_aouthdr aouthdr; /* a.out header */ |
446 | struct internal_filehdr filehdr; /* File header, not machine dep. */ | |
db40ba14 | 447 | #else |
a39116f1 RP |
448 | AOUTHDR aouthdr; /* a.out header */ |
449 | FILHDR filehdr; /* File header, not machine dep. */ | |
db40ba14 | 450 | #endif |
a39116f1 RP |
451 | long string_table_size; /* names + '\0' + sizeof(int) */ |
452 | long relocation_size; /* Cumulated size of relocation | |
db40ba14 SC |
453 | information for all sections in |
454 | bytes. */ | |
a39116f1 | 455 | long lineno_size; /* Size of the line number information |
db40ba14 SC |
456 | table in bytes */ |
457 | } object_headers; | |
458 | ||
459 | ||
460 | ||
461 | struct lineno_list | |
462 | { | |
a39116f1 RP |
463 | |
464 | struct bfd_internal_lineno line; | |
465 | char* frag; /* Frag to which the line number is related */ | |
466 | struct lineno_list* next; /* Forward chain pointer */ | |
db40ba14 SC |
467 | } ; |
468 | ||
469 | ||
470 | ||
471 | ||
a39116f1 | 472 | /* stack stuff */ |
db40ba14 | 473 | typedef struct { |
a39116f1 RP |
474 | unsigned long chunk_size; |
475 | unsigned long element_size; | |
476 | unsigned long size; | |
477 | char* data; | |
478 | unsigned long pointer; | |
db40ba14 SC |
479 | } stack; |
480 | ||
481 | ||
482 | ||
483 | char *EXFUN(stack_pop,(stack *st)); | |
484 | char *EXFUN(stack_push,(stack *st, char *element)); | |
485 | char *EXFUN(stack_top,(stack *st)); | |
486 | stack *EXFUN(stack_init,(unsigned long chunk_size, unsigned long element_size)); | |
487 | void EXFUN(c_dot_file_symbol,(char *filename)); | |
488 | void EXFUN(obj_extra_stuff,(object_headers *headers)); | |
489 | void EXFUN(stack_delete,(stack *st)); | |
490 | ||
491 | ||
492 | ||
493 | void EXFUN(c_section_header,( | |
a39116f1 RP |
494 | |
495 | struct internal_scnhdr *header, | |
496 | char *name, | |
497 | long core_address, | |
498 | long size, | |
499 | long data_ptr, | |
500 | long reloc_ptr, | |
501 | long lineno_ptr, | |
502 | long reloc_number, | |
503 | long lineno_number, | |
504 | long alignment)); | |
db40ba14 SC |
505 | |
506 | ||
a39116f1 | 507 | /* sanity check */ |
db40ba14 SC |
508 | |
509 | #ifdef TC_I960 | |
510 | #ifndef C_LEAFSTAT | |
511 | hey! Where is the C_LEAFSTAT definition? i960-coff support is depending on it. | |
512 | #endif /* no C_LEAFSTAT */ | |
513 | #endif /* TC_I960 */ | |
514 | #ifdef BFD_HEADERS | |
a39116f1 | 515 | extern struct internal_scnhdr data_section_header; |
db40ba14 SC |
516 | extern struct internal_scnhdr text_section_header; |
517 | #else | |
518 | extern SCNHDR data_section_header; | |
519 | extern SCNHDR text_section_header; | |
520 | #endif | |
a39116f1 RP |
521 | #endif |
522 | ||
db40ba14 SC |
523 | /* |
524 | * Local Variables: | |
525 | * comment-column: 0 | |
526 | * fill-column: 131 | |
527 | * End: | |
528 | */ | |
529 | ||
8b228fe9 | 530 | /* end of obj-coffbfd.h */ |