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