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