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