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