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