26244bf06c842ac36179254b41236deaf34a0e31
[deliverable/binutils-gdb.git] / gas / config / obj-coff.h
1 /* coff object file format
2 Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
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. */
19
20 #define OBJ_COFF 1
21
22 #include "targ-cpu.h"
23
24 #if defined (BFD_HEADERS) || defined (BFD_ASSEMBLER)
25
26 /* This internal_lineno crap is to stop namespace pollution from the
27 bfd internal coff headerfile. */
28
29 #include "bfd.h"
30 #define internal_lineno bfd_internal_lineno
31 #include "coff/internal.h"
32 #undef internal_lineno
33
34 #ifdef BFD_ASSEMBLER
35 #include "../bfd/libcoff.h"
36 #endif
37
38 #ifdef TC_A29K
39 #include "coff/a29k.h"
40 #define TARGET_FORMAT "coff-a29k-big"
41 extern bfd *stdoutput;
42
43 #endif /* TC_A29K */
44
45 #ifdef TC_I960
46 #include "coff/i960.h"
47 #define TARGET_FORMAT "coff-i960-big"
48 #endif
49
50 #ifdef TC_I386
51 # include "coff/i386.h"
52 # define TARGET_FORMAT "coff-i386"
53 extern bfd *stdoutput;
54
55 #endif /* TC_I386 */
56
57 #ifdef TC_M68K
58 # include "coff/m68k.h"
59 # define TARGET_FORMAT "coff-m68k"
60 #endif /* TC_M68K */
61
62 #ifdef TC_PPC
63 #include "coff/rs6000.h"
64 #endif
65
66 #ifdef TC_SPARC
67 #include "coff/sparc.h"
68 #ifdef TE_LYNX
69 #define TARGET_FORMAT "coff-sparc-lynx"
70 #else
71 #define TARGET_FORMAT "coff-sparc"
72 #endif
73 #endif
74
75 #else /* not BFD_HEADERS */
76
77 #include "coff_gnu.h"
78
79 #endif /* not BFD_HEADERS */
80
81 #ifndef BFD_ASSEMBLER
82 /* Define some processor dependent values according to the processor
83 we are on. */
84 #ifdef TC_M68K
85
86 #define BYTE_ORDERING F_AR32W /* See filehdr.h for more info. */
87 #ifndef FILE_HEADER_MAGIC
88 #define FILE_HEADER_MAGIC MC68MAGIC /* ... */
89 #endif /* FILE_HEADER_MAGIC */
90
91 #endif /* TC_M68K */
92
93 #if defined(TC_I386)
94
95 #define BYTE_ORDERING F_AR32WR /* See filehdr.h for more info. */
96 #ifndef FILE_HEADER_MAGIC
97 #define FILE_HEADER_MAGIC I386MAGIC /* ... */
98 #endif /* FILE_HEADER_MAGIC */
99
100 #endif /* TC_I386 */
101
102 #if defined(TC_I960)
103
104 #define BYTE_ORDERING F_AR32WR /* See filehdr.h for more info. */
105 #ifndef FILE_HEADER_MAGIC
106 #define FILE_HEADER_MAGIC I960ROMAGIC /* ... */
107 #endif /* FILE_HEADER_MAGIC */
108
109 #endif /* TC_I960 */
110
111 #if defined(TC_A29K)
112
113 #define BYTE_ORDERING F_AR32W /* big endian. */
114 #ifndef FILE_HEADER_MAGIC
115 #define FILE_HEADER_MAGIC SIPFBOMAGIC
116 #endif /* FILE_HEADER_MAGIC */
117
118 #endif /* TC_A29K */
119
120 #ifndef OBJ_COFF_MAX_AUXENTRIES
121 #define OBJ_COFF_MAX_AUXENTRIES 1
122 #endif /* OBJ_COFF_MAX_AUXENTRIES */
123
124 extern const short seg_N_TYPE[];
125 extern const segT N_TYPE_seg[];
126
127 /* Magic number of paged executable. */
128 #define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (FILE_HEADER_MAGIC)
129
130 #ifndef BFD_HEADERS
131
132 /* Add these definitions to have a consistent convention for all the
133 types used in COFF format. */
134 #define AOUTHDR struct aouthdr
135 #define AOUTHDRSZ sizeof(AOUTHDR)
136 #endif
137
138 #endif /* not BFD_ASSEMBLER */
139
140
141 /* SYMBOL TABLE */
142
143 /* targets may also set this */
144 #ifndef SYMBOLS_NEED_BACKPOINTERS
145 #define SYMBOLS_NEED_BACKPOINTERS 1
146 #endif /* SYMBOLS_NEED_BACKPOINTERS */
147
148 #ifdef BFD_ASSEMBLER
149
150 /* Alter the field names, for now, until we've fixed up the other
151 references to use the new name. */
152 #ifdef TC_I960
153 #define TC_SYMFIELD_TYPE struct symbol *
154 #define sy_tc bal
155 #endif
156
157 #define OBJ_SYMFIELD_TYPE unsigned long
158 #define sy_obj sy_flags
159
160 #ifndef OBJ_COFF_MAX_AUXENTRIES
161 #define OBJ_COFF_MAX_AUXENTRIES 1
162 #endif
163
164 #else
165
166 /* Symbol table entry data type */
167
168 typedef struct
169 {
170 #ifdef BFD_HEADERS
171 struct internal_syment ost_entry; /* Basic symbol */
172 union internal_auxent ost_auxent[OBJ_COFF_MAX_AUXENTRIES]; /* Auxiliary entry. */
173 #else
174 SYMENT ost_entry; /* Basic symbol */
175 AUXENT ost_auxent[OBJ_COFF_MAX_AUXENTRIES]; /* Auxiliary entry. */
176 #endif
177 unsigned int ost_flags; /* obj_coff internal use only flags */
178 }
179 obj_symbol_type;
180 #endif /* ! BFD_ASSEMBLER */
181
182 #ifdef BFD_ASSEMBLER
183 #define SYM_AUXENT(S) (&coffsymbol ((S)->bsym)->native[1].u.auxent)
184 #else
185 #define SYM_AUXENT(S) (&(S)->sy_symbol.ost_auxent[0])
186 #endif
187
188 #define DO_NOT_STRIP 0
189 #define DO_STRIP 1
190
191 #ifndef BFD_ASSEMBLER
192
193 /* Symbol table macros and constants */
194
195 /* Possible and usefull section number in symbol table
196 * The values of TEXT, DATA and BSS may not be portable.
197 */
198
199 #define C_TEXT_SECTION ((short)1)
200 #define C_DATA_SECTION ((short)2)
201 #define C_BSS_SECTION ((short)3)
202 #define C_ABS_SECTION N_ABS
203 #define C_UNDEF_SECTION N_UNDEF
204 #define C_DEBUG_SECTION N_DEBUG
205 #define C_NTV_SECTION N_TV
206 #define C_PTV_SECTION P_TV
207 #define C_REGISTER_SECTION 4
208
209 /*
210 * Macros to extract information from a symbol table entry.
211 * This syntaxic indirection allows independence regarding a.out or coff.
212 * The argument (s) of all these macros is a pointer to a symbol table entry.
213 */
214
215 /* Predicates */
216 /* True if the symbol is external */
217 #define S_IS_EXTERNAL(s) ((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION)
218 /* True if symbol has been defined, ie :
219 section > 0 (DATA, TEXT or BSS)
220 section == 0 and value > 0 (external bss symbol) */
221 #define S_IS_DEFINED(s) ((s)->sy_symbol.ost_entry.n_scnum > C_UNDEF_SECTION || \
222 ((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION && \
223 S_GET_VALUE(s) > 0))
224 /* True if a debug special symbol entry */
225 #define S_IS_DEBUG(s) ((s)->sy_symbol.ost_entry.n_scnum == C_DEBUG_SECTION)
226 /* True if a symbol is local symbol name */
227 /* A symbol name whose name begin with ^A is a gas internal pseudo symbol */
228 #define S_IS_LOCAL(s) (S_GET_NAME(s)[0] == '\001' || \
229 (s)->sy_symbol.ost_entry.n_scnum == C_REGISTER_SECTION || \
230 (S_LOCAL_NAME(s) && !flagseen['L']))
231 /* True if a symbol is not defined in this file */
232 #define S_IS_EXTERN(s) ((s)->sy_symbol.ost_entry.n_scnum == 0 \
233 && S_GET_VALUE (s) == 0)
234 /*
235 * True if a symbol can be multiply defined (bss symbols have this def
236 * though it is bad practice)
237 */
238 #define S_IS_COMMON(s) ((s)->sy_symbol.ost_entry.n_scnum == 0 \
239 && S_GET_VALUE (s) != 0)
240 /* True if a symbol name is in the string table, i.e. its length is > 8. */
241 #define S_IS_STRING(s) (strlen(S_GET_NAME(s)) > 8 ? 1 : 0)
242
243 /* Accessors */
244 /* The name of the symbol */
245 #define S_GET_NAME(s) ((char*)(s)->sy_symbol.ost_entry.n_offset)
246 /* The pointer to the string table */
247 #define S_GET_OFFSET(s) ((s)->sy_symbol.ost_entry.n_offset)
248 /* The zeroes if symbol name is longer than 8 chars */
249 #define S_GET_ZEROES(s) ((s)->sy_symbol.ost_entry.n_zeroes)
250 /* The numeric value of the segment */
251 #define S_GET_SEGMENT(s) (N_TYPE_seg[(s)->sy_symbol.ost_entry.n_scnum+4])
252 /* The data type */
253 #define S_GET_DATA_TYPE(s) ((s)->sy_symbol.ost_entry.n_type)
254 /* The storage class */
255 #define S_GET_STORAGE_CLASS(s) ((s)->sy_symbol.ost_entry.n_sclass)
256 /* The number of auxiliary entries */
257 #define S_GET_NUMBER_AUXILIARY(s) ((s)->sy_symbol.ost_entry.n_numaux)
258
259 /* Modifiers */
260 /* Set the name of the symbol */
261 #define S_SET_NAME(s,v) ((s)->sy_symbol.ost_entry.n_offset = (unsigned long)(v))
262 /* Set the offset of the symbol */
263 #define S_SET_OFFSET(s,v) ((s)->sy_symbol.ost_entry.n_offset = (v))
264 /* The zeroes if symbol name is longer than 8 chars */
265 #define S_SET_ZEROES(s,v) ((s)->sy_symbol.ost_entry.n_zeroes = (v))
266 /* The numeric value of the segment */
267 #define S_SET_SEGMENT(s,v) ((s)->sy_symbol.ost_entry.n_scnum = SEGMENT_TO_SYMBOL_TYPE(v))
268 /* The data type */
269 #define S_SET_DATA_TYPE(s,v) ((s)->sy_symbol.ost_entry.n_type = (v))
270 /* The storage class */
271 #define S_SET_STORAGE_CLASS(s,v) ((s)->sy_symbol.ost_entry.n_sclass = (v))
272 /* The number of auxiliary entries */
273 #define S_SET_NUMBER_AUXILIARY(s,v) ((s)->sy_symbol.ost_entry.n_numaux = (v))
274
275 /* Additional modifiers */
276 /* The symbol is external (does not mean undefined) */
277 #define S_SET_EXTERNAL(s) { S_SET_STORAGE_CLASS(s, C_EXT) ; SF_CLEAR_LOCAL(s); }
278
279 #else /* BFD_ASSEMBLER */
280
281 extern void obj_coff_section PARAMS ((int));
282
283 /* The number of auxiliary entries */
284 #define S_GET_NUMBER_AUXILIARY(s) (coffsymbol((s)->bsym)->native->u.syment.n_numaux)
285 /* The number of auxiliary entries */
286 #define S_SET_NUMBER_AUXILIARY(s,v) (S_GET_NUMBER_AUXILIARY (s) = (v))
287
288 /* True if a symbol name is in the string table, i.e. its length is > 8. */
289 #define S_IS_STRING(s) (strlen(S_GET_NAME(s)) > 8 ? 1 : 0)
290
291 extern int S_SET_DATA_TYPE PARAMS ((struct symbol *, int));
292 extern int S_SET_STORAGE_CLASS PARAMS ((struct symbol *, int));
293 extern int S_GET_STORAGE_CLASS PARAMS ((struct symbol *));
294 extern void SA_SET_SYM_ENDNDX PARAMS ((struct symbol *, struct symbol *));
295
296 #endif /* ! BFD_ASSEMBLER */
297
298 /* Auxiliary entry macros. SA_ stands for symbol auxiliary */
299 /* Omit the tv related fields */
300 /* Accessors */
301
302 #if defined (BFD_HEADERS) || defined (BFD_ASSEMBLER)
303 #define SA_GET_SYM_TAGNDX(s) (SYM_AUXENT (s)->x_sym.x_tagndx.l)
304 #else
305 #define SA_GET_SYM_TAGNDX(s) (SYM_AUXENT (s)->x_sym.x_tagndx)
306 #endif
307 #define SA_GET_SYM_LNNO(s) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_lnno)
308 #define SA_GET_SYM_SIZE(s) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_size)
309 #define SA_GET_SYM_FSIZE(s) (SYM_AUXENT (s)->x_sym.x_misc.x_fsize)
310 #define SA_GET_SYM_LNNOPTR(s) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_lnnoptr)
311 #ifdef BFD_HEADERS
312 #define SA_GET_SYM_ENDNDX(s) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_endndx.l)
313 #else
314 #define SA_GET_SYM_ENDNDX(s) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_endndx)
315 #endif
316 #define SA_GET_SYM_DIMEN(s,i) (SYM_AUXENT (s)->x_sym.x_fcnary.x_ary.x_dimen[(i)])
317 #define SA_GET_FILE_FNAME(s) (SYM_AUXENT (s)->x_file.x_fname)
318 #define SA_GET_SCN_SCNLEN(s) (SYM_AUXENT (s)->x_scn.x_scnlen)
319 #define SA_GET_SCN_NRELOC(s) (SYM_AUXENT (s)->x_scn.x_nreloc)
320 #define SA_GET_SCN_NLINNO(s) (SYM_AUXENT (s)->x_scn.x_nlinno)
321
322 /* Modifiers */
323 #ifndef BFD_ASSEMBLER
324 #ifdef BFD_HEADERS
325 #define SA_SET_SYM_TAGNDX(s,v) (SYM_AUXENT (s)->x_sym.x_tagndx.l=(v))
326 #define SA_SET_SYM_ENDNDX(s,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_endndx.l=(v))
327 #else
328 #define SA_SET_SYM_ENDNDX(s,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_endndx=(v))
329 #define SA_SET_SYM_TAGNDX(s,v) (SYM_AUXENT (s)->x_sym.x_tagndx=(v))
330 #endif
331 #endif
332
333 #define SA_SET_SYM_LNNO(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_lnno=(v))
334 #define SA_SET_SYM_SIZE(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_size=(v))
335 #define SA_SET_SYM_FSIZE(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_fsize=(v))
336 #define SA_SET_SYM_LNNOPTR(s,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_lnnoptr=(v))
337 #define SA_SET_SYM_DIMEN(s,i,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_ary.x_dimen[(i)]=(v))
338 #define SA_SET_FILE_FNAME(s,v) strncpy(SYM_AUXENT (s)->x_file.x_fname,(v),FILNMLEN)
339 #define SA_SET_SCN_SCNLEN(s,v) (SYM_AUXENT (s)->x_scn.x_scnlen=(v))
340 #define SA_SET_SCN_NRELOC(s,v) (SYM_AUXENT (s)->x_scn.x_nreloc=(v))
341 #define SA_SET_SCN_NLINNO(s,v) (SYM_AUXENT (s)->x_scn.x_nlinno=(v))
342
343 /*
344 * Internal use only definitions. SF_ stands for symbol flags.
345 *
346 * These values can be assigned to sy_symbol.ost_flags field of a symbolS.
347 *
348 * You'll break i960 if you shift the SYSPROC bits anywhere else. for
349 * more on the balname/callname hack, see tc-i960.h. b.out is done
350 * differently.
351 */
352
353 #define SF_I960_MASK (0x000001ff) /* Bits 0-8 are used by the i960 port. */
354 #define SF_SYSPROC (0x0000003f) /* bits 0-5 are used to store the sysproc number */
355 #define SF_IS_SYSPROC (0x00000040) /* bit 6 marks symbols that are sysprocs */
356 #define SF_BALNAME (0x00000080) /* bit 7 marks BALNAME symbols */
357 #define SF_CALLNAME (0x00000100) /* bit 8 marks CALLNAME symbols */
358
359 #define SF_NORMAL_MASK (0x0000ffff) /* bits 12-15 are general purpose. */
360
361 #define SF_STATICS (0x00001000) /* Mark the .text & all symbols */
362 #define SF_DEFINED (0x00002000) /* Symbol is defined in this file */
363 #define SF_STRING (0x00004000) /* Symbol name length > 8 */
364 #define SF_LOCAL (0x00008000) /* Symbol must not be emitted */
365
366 #define SF_DEBUG_MASK (0xffff0000) /* bits 16-31 are debug info */
367
368 #define SF_FUNCTION (0x00010000) /* The symbol is a function */
369 #define SF_PROCESS (0x00020000) /* Process symbol before write */
370 #define SF_TAGGED (0x00040000) /* Is associated with a tag */
371 #define SF_TAG (0x00080000) /* Is a tag */
372 #define SF_DEBUG (0x00100000) /* Is in debug or abs section */
373 #define SF_GET_SEGMENT (0x00200000) /* Get the section of the forward symbol. */
374 /* All other bits are unused. */
375
376 /* Accessors */
377 #ifdef BFD_ASSEMBLER
378 #define SF_GET(s) ((s)->sy_flags)
379 #define SF_GET_DEBUG(s) ((s)->bsym->flags & BSF_DEBUGGING)
380 #define SF_SET_DEBUG(s) ((s)->bsym->flags |= BSF_DEBUGGING)
381 #else
382 #define SF_GET(s) ((s)->sy_symbol.ost_flags)
383 #define SF_GET_DEBUG(s) ((s)->sy_symbol.ost_flags & SF_DEBUG)
384 #define SF_SET_DEBUG(s) ((s)->sy_symbol.ost_flags |= SF_DEBUG)
385 #endif
386 #define SF_GET_NORMAL_FIELD(s) (SF_GET (s) & SF_NORMAL_MASK)
387 #define SF_GET_DEBUG_FIELD(s) (SF_GET (s) & SF_DEBUG_MASK)
388 #define SF_GET_FILE(s) (SF_GET (s) & SF_FILE)
389 #define SF_GET_STATICS(s) (SF_GET (s) & SF_STATICS)
390 #define SF_GET_DEFINED(s) (SF_GET (s) & SF_DEFINED)
391 #define SF_GET_STRING(s) (SF_GET (s) & SF_STRING)
392 #define SF_GET_LOCAL(s) (SF_GET (s) & SF_LOCAL)
393 #define SF_GET_FUNCTION(s) (SF_GET (s) & SF_FUNCTION)
394 #define SF_GET_PROCESS(s) (SF_GET (s) & SF_PROCESS)
395 #define SF_GET_TAGGED(s) (SF_GET (s) & SF_TAGGED)
396 #define SF_GET_TAG(s) (SF_GET (s) & SF_TAG)
397 #define SF_GET_GET_SEGMENT(s) (SF_GET (s) & SF_GET_SEGMENT)
398 #define SF_GET_I960(s) (SF_GET (s) & SF_I960_MASK) /* used by i960 */
399 #define SF_GET_BALNAME(s) (SF_GET (s) & SF_BALNAME) /* used by i960 */
400 #define SF_GET_CALLNAME(s) (SF_GET (s) & SF_CALLNAME) /* used by i960 */
401 #define SF_GET_IS_SYSPROC(s) (SF_GET (s) & SF_IS_SYSPROC) /* used by i960 */
402 #define SF_GET_SYSPROC(s) (SF_GET (s) & SF_SYSPROC) /* used by i960 */
403
404 /* Modifiers */
405 #define SF_SET(s,v) (SF_GET (s) = (v))
406 #define SF_SET_NORMAL_FIELD(s,v)(SF_GET (s) |= ((v) & SF_NORMAL_MASK))
407 #define SF_SET_DEBUG_FIELD(s,v) (SF_GET (s) |= ((v) & SF_DEBUG_MASK))
408 #define SF_SET_FILE(s) (SF_GET (s) |= SF_FILE)
409 #define SF_SET_STATICS(s) (SF_GET (s) |= SF_STATICS)
410 #define SF_SET_DEFINED(s) (SF_GET (s) |= SF_DEFINED)
411 #define SF_SET_STRING(s) (SF_GET (s) |= SF_STRING)
412 #define SF_SET_LOCAL(s) (SF_GET (s) |= SF_LOCAL)
413 #define SF_CLEAR_LOCAL(s) (SF_GET (s) &= ~SF_LOCAL)
414 #define SF_SET_FUNCTION(s) (SF_GET (s) |= SF_FUNCTION)
415 #define SF_SET_PROCESS(s) (SF_GET (s) |= SF_PROCESS)
416 #define SF_SET_TAGGED(s) (SF_GET (s) |= SF_TAGGED)
417 #define SF_SET_TAG(s) (SF_GET (s) |= SF_TAG)
418 #define SF_SET_GET_SEGMENT(s) (SF_GET (s) |= SF_GET_SEGMENT)
419 #define SF_SET_I960(s,v) (SF_GET (s) |= ((v) & SF_I960_MASK)) /* used by i960 */
420 #define SF_SET_BALNAME(s) (SF_GET (s) |= SF_BALNAME) /* used by i960 */
421 #define SF_SET_CALLNAME(s) (SF_GET (s) |= SF_CALLNAME) /* used by i960 */
422 #define SF_SET_IS_SYSPROC(s) (SF_GET (s) |= SF_IS_SYSPROC) /* used by i960 */
423 #define SF_SET_SYSPROC(s,v) (SF_GET (s) |= ((v) & SF_SYSPROC)) /* used by i960 */
424
425 /* File header macro and type definition */
426
427 #ifndef BFD_ASSEMBLER
428 /*
429 * File position calculators. Beware to use them when all the
430 * appropriate fields are set in the header.
431 */
432
433 #ifdef OBJ_COFF_OMIT_OPTIONAL_HEADER
434 #define OBJ_COFF_AOUTHDRSZ (0)
435 #else
436 #define OBJ_COFF_AOUTHDRSZ (AOUTHDRSZ)
437 #endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
438
439 #define H_GET_FILE_SIZE(h) \
440 (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
441 H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
442 H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
443 H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h) + \
444 H_GET_SYMBOL_TABLE_SIZE(h) + \
445 (h)->string_table_size)
446 #define H_GET_TEXT_FILE_OFFSET(h) \
447 (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
448 H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ)
449 #define H_GET_DATA_FILE_OFFSET(h) \
450 (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
451 H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
452 H_GET_TEXT_SIZE(h))
453 #define H_GET_BSS_FILE_OFFSET(h) 0
454 #define H_GET_RELOCATION_FILE_OFFSET(h) \
455 (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
456 H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
457 H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h))
458 #define H_GET_LINENO_FILE_OFFSET(h) \
459 (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
460 H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
461 H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
462 H_GET_RELOCATION_SIZE(h))
463 #define H_GET_SYMBOL_TABLE_FILE_OFFSET(h) \
464 (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \
465 H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \
466 H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \
467 H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h))
468
469 /* Accessors */
470 /* aouthdr */
471 #define H_GET_MAGIC_NUMBER(h) ((h)->aouthdr.magic)
472 #define H_GET_VERSION_STAMP(h) ((h)->aouthdr.vstamp)
473 #define H_GET_TEXT_SIZE(h) ((h)->aouthdr.tsize)
474 #define H_GET_DATA_SIZE(h) ((h)->aouthdr.dsize)
475 #define H_GET_BSS_SIZE(h) ((h)->aouthdr.bsize)
476 #define H_GET_ENTRY_POINT(h) ((h)->aouthdr.entry)
477 #define H_GET_TEXT_START(h) ((h)->aouthdr.text_start)
478 #define H_GET_DATA_START(h) ((h)->aouthdr.data_start)
479 /* filehdr */
480 #define H_GET_FILE_MAGIC_NUMBER(h) ((h)->filehdr.f_magic)
481 #define H_GET_NUMBER_OF_SECTIONS(h) ((h)->filehdr.f_nscns)
482 #define H_GET_TIME_STAMP(h) ((h)->filehdr.f_timdat)
483 #define H_GET_SYMBOL_TABLE_POINTER(h) ((h)->filehdr.f_symptr)
484 #define H_GET_SYMBOL_COUNT(h) ((h)->filehdr.f_nsyms)
485 #define H_GET_SYMBOL_TABLE_SIZE(h) (H_GET_SYMBOL_COUNT(h) * SYMESZ)
486 #define H_GET_SIZEOF_OPTIONAL_HEADER(h) ((h)->filehdr.f_opthdr)
487 #define H_GET_FLAGS(h) ((h)->filehdr.f_flags)
488 /* Extra fields to achieve bsd a.out compatibility and for convenience */
489 #define H_GET_RELOCATION_SIZE(h) ((h)->relocation_size)
490 #define H_GET_STRING_SIZE(h) ((h)->string_table_size)
491 #define H_GET_LINENO_SIZE(h) ((h)->lineno_size)
492
493 #ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER
494 #define H_GET_HEADER_SIZE(h) (sizeof(FILHDR) \
495 + sizeof(AOUTHDR)\
496 + (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ))
497 #else /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
498 #define H_GET_HEADER_SIZE(h) (sizeof(FILHDR) \
499 + (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ))
500 #endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */
501
502 #define H_GET_TEXT_RELOCATION_SIZE(h) (text_section_header.s_nreloc * RELSZ)
503 #define H_GET_DATA_RELOCATION_SIZE(h) (data_section_header.s_nreloc * RELSZ)
504
505 /* Modifiers */
506 /* aouthdr */
507 #define H_SET_MAGIC_NUMBER(h,v) ((h)->aouthdr.magic = (v))
508 #define H_SET_VERSION_STAMP(h,v) ((h)->aouthdr.vstamp = (v))
509 #define H_SET_TEXT_SIZE(h,v) ((h)->aouthdr.tsize = (v))
510 #define H_SET_DATA_SIZE(h,v) ((h)->aouthdr.dsize = (v))
511 #define H_SET_BSS_SIZE(h,v) ((h)->aouthdr.bsize = (v))
512 #define H_SET_ENTRY_POINT(h,v) ((h)->aouthdr.entry = (v))
513 #define H_SET_TEXT_START(h,v) ((h)->aouthdr.text_start = (v))
514 #define H_SET_DATA_START(h,v) ((h)->aouthdr.data_start = (v))
515 /* filehdr */
516 #define H_SET_FILE_MAGIC_NUMBER(h,v) ((h)->filehdr.f_magic = (v))
517 #define H_SET_NUMBER_OF_SECTIONS(h,v) ((h)->filehdr.f_nscns = (v))
518 #define H_SET_TIME_STAMP(h,v) ((h)->filehdr.f_timdat = (v))
519 #define H_SET_SYMBOL_TABLE_POINTER(h,v) ((h)->filehdr.f_symptr = (v))
520 #define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->filehdr.f_nsyms = (v))
521 #define H_SET_SIZEOF_OPTIONAL_HEADER(h,v) ((h)->filehdr.f_opthdr = (v))
522 #define H_SET_FLAGS(h,v) ((h)->filehdr.f_flags = (v))
523 /* Extra fields to achieve bsd a.out compatibility and for convinience */
524 #define H_SET_RELOCATION_SIZE(h,t,d) ((h)->relocation_size = (t)+(d))
525 #define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v))
526 #define H_SET_LINENO_SIZE(h,v) ((h)->lineno_size = (v))
527
528 /* Segment flipping */
529
530 typedef struct
531 {
532 #ifdef BFD_HEADERS
533 struct internal_aouthdr aouthdr; /* a.out header */
534 struct internal_filehdr filehdr; /* File header, not machine dep. */
535 #else
536 AOUTHDR aouthdr; /* a.out header */
537 FILHDR filehdr; /* File header, not machine dep. */
538 #endif
539 long string_table_size; /* names + '\0' + sizeof(int) */
540 long relocation_size; /* Cumulated size of relocation
541 information for all sections in
542 bytes. */
543 long lineno_size; /* Size of the line number information
544 table in bytes */
545 }
546
547 object_headers;
548 #endif /* ! BFD_ASSEMBLER */
549
550 /* -------------- Line number handling ------- */
551 extern int text_lineno_number;
552 extern int coff_line_base;
553
554 #ifndef BFD_ASSEMBLER
555 /* line numbering stuff. */
556
557 typedef struct internal_lineno
558 {
559 #ifdef BFD_HEADERS
560 struct bfd_internal_lineno line;
561 #else
562 LINENO line; /* The lineno structure itself */
563 #endif
564 char *frag; /* Frag to which the line number is related */
565 struct internal_lineno *next; /* Forward chain pointer */
566 } lineno;
567
568 extern lineno *lineno_lastP;
569 extern lineno *lineno_rootP;
570 #define OBJ_EMIT_LINENO(a, b, c) obj_emit_lineno((a),(b),(c))
571
572 void obj_emit_lineno PARAMS ((char **where, lineno * line, char *file_start));
573
574 #endif /* not BFD_ASSEMBLER */
575
576 #ifdef BFD_ASSEMBLER
577 #define obj_emit_lineno(WHERE,LINE,FILE_START) abort ()
578 extern void coff_add_linesym PARAMS ((struct symbol *));
579 #endif
580
581 /* stack stuff */
582 typedef struct
583 {
584 unsigned long chunk_size;
585 unsigned long element_size;
586 unsigned long size;
587 char *data;
588 unsigned long pointer;
589 }
590
591 stack;
592
593 char *stack_pop PARAMS ((stack * st));
594 char *stack_push PARAMS ((stack * st, char *element));
595 char *stack_top PARAMS ((stack * st));
596 stack *stack_init PARAMS ((unsigned long chunk_size,
597 unsigned long element_size));
598 void c_dot_file_symbol PARAMS ((char *filename));
599 void stack_delete PARAMS ((stack * st));
600
601 #ifndef BFD_ASSEMBLER
602 void obj_extra_stuff PARAMS ((object_headers * headers));
603 #ifndef tc_headers_hook
604 void tc_headers_hook PARAMS ((object_headers * headers));
605 #endif
606 #endif
607
608 #ifndef tc_coff_symbol_emit_hook
609 void tc_coff_symbol_emit_hook PARAMS ((/* symbolS * */));
610 #endif
611
612 extern void coff_frob_symbol PARAMS ((struct symbol *, int *));
613 extern void coff_frob_file PARAMS ((void));
614 #define obj_frob_symbol(S,P) coff_frob_symbol(S,&P)
615 #define obj_frob_file() coff_frob_file ()
616
617 extern struct symbol *coff_last_function;
618
619 /* Forward the segment of a forwarded symbol. */
620 #ifndef TE_I386AIX
621 #define obj_frob_forward_symbol(symp) \
622 (SF_GET_GET_SEGMENT (symp) \
623 ? (S_SET_SEGMENT (symp, S_GET_SEGMENT (symp->sy_value.X_add_symbol)), 0) \
624 : 0)
625 #else
626 #define obj_frob_forward_symbol(symp) \
627 (SF_GET_GET_SEGMENT (symp) && S_GET_SEGMENT (symp) == SEG_UNKNOWN \
628 ? (S_SET_SEGMENT (symp, S_GET_SEGMENT (symp->sy_value.X_add_symbol)), 0) \
629 : 0)
630 #endif
631
632 #ifndef BFD_ASSEMBLER
633 #ifdef BFD_HEADERS
634 void c_section_header PARAMS ((struct internal_scnhdr *header,
635 char *name, long core_address, long size,
636 long data_ptr, long reloc_ptr, long lineno_ptr,
637 long reloc_number, long lineno_number,
638 long alignment));
639 #else
640 void c_section_header PARAMS ((SCNHDR * header,
641 char *name, long core_address, long size,
642 long data_ptr, long reloc_ptr, long lineno_ptr,
643 long reloc_number, long lineno_number,
644 long alignment));
645 #endif
646 #endif
647
648 /* sanity check */
649
650 #ifdef TC_I960
651 #ifndef C_LEAFSTAT
652 hey ! Where is the C_LEAFSTAT definition ? i960 - coff support is depending on it.
653 #endif /* no C_LEAFSTAT */
654 #endif /* TC_I960 */
655 #ifndef BFD_ASSEMBLER
656 #ifdef BFD_HEADERS
657 extern struct internal_scnhdr data_section_header;
658 extern struct internal_scnhdr text_section_header;
659 #else
660 extern SCNHDR data_section_header;
661 extern SCNHDR text_section_header;
662 #endif
663 #endif
664
665 #define SEPARATE_STAB_SECTIONS
666
667 /* end of obj-coff.h */
This page took 0.042004 seconds and 4 git commands to generate.