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