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