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