Add support for the Z80 processor family
[deliverable/binutils-gdb.git] / gas / config / obj-coff.h
CommitLineData
252b5132 1/* coff object file format
f7e42eb4 2 Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
a5324a3e 3 1999, 2000, 2001, 2002, 2003, 2004, 2005
252b5132
RH
4 Free Software Foundation, Inc.
5
6 This file is part of GAS.
7
8 GAS is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GAS is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GAS; see the file COPYING. If not, write to the Free
4b4da160
NC
20 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
21 02110-1301, USA. */
252b5132
RH
22
23#ifndef OBJ_FORMAT_H
24#define OBJ_FORMAT_H
25
26#define OBJ_COFF 1
27
252b5132
RH
28#include "targ-cpu.h"
29
30#include "bfd.h"
31
32/* This internal_lineno crap is to stop namespace pollution from the
dcd619be 33 bfd internal coff headerfile. */
252b5132
RH
34#define internal_lineno bfd_internal_lineno
35#include "coff/internal.h"
36#undef internal_lineno
37
38/* CPU-specific setup: */
39
40#ifdef TC_ARM
41#include "coff/arm.h"
42#ifndef TARGET_FORMAT
43#define TARGET_FORMAT "coff-arm"
44#endif
45#endif
46
47#ifdef TC_PPC
48#ifdef TE_PE
49#include "coff/powerpc.h"
50#else
51#include "coff/rs6000.h"
52#endif
53#endif
54
55#ifdef TC_SPARC
56#include "coff/sparc.h"
57#endif
58
59#ifdef TC_I386
60#include "coff/i386.h"
61
62#ifdef TE_PE
63#define TARGET_FORMAT "pe-i386"
64#endif
65
66#ifndef TARGET_FORMAT
67#define TARGET_FORMAT "coff-i386"
68#endif
69#endif
70
71#ifdef TC_M68K
72#include "coff/m68k.h"
73#ifndef TARGET_FORMAT
74#define TARGET_FORMAT "coff-m68k"
75#endif
76#endif
77
3b16e843
NC
78#ifdef TC_OR32
79#include "coff/or32.h"
80#define TARGET_FORMAT "coff-or32-big"
81#endif
82
252b5132
RH
83#ifdef TC_I960
84#include "coff/i960.h"
85#define TARGET_FORMAT "coff-Intel-little"
86#endif
87
3c9b82ba
NC
88#ifdef TC_Z80
89#include "coff/z80.h"
90#define TARGET_FORMAT "coff-z80"
91#endif
92
252b5132
RH
93#ifdef TC_Z8K
94#include "coff/z8k.h"
95#define TARGET_FORMAT "coff-z8k"
96#endif
97
98#ifdef TC_H8300
99#include "coff/h8300.h"
100#define TARGET_FORMAT "coff-h8300"
101#endif
102
103#ifdef TC_H8500
104#include "coff/h8500.h"
105#define TARGET_FORMAT "coff-h8500"
106#endif
107
7499d566
NC
108#ifdef TC_MAXQ20
109#include "coff/maxq.h"
110#define TARGET_FORMAT "coff-maxq"
111#endif
112
252b5132 113#ifdef TC_SH
056350c6
NC
114
115#ifdef TE_PE
116#define COFF_WITH_PE
117#endif
118
252b5132 119#include "coff/sh.h"
056350c6
NC
120
121#ifdef TE_PE
122#define TARGET_FORMAT "pe-shl"
123#else
94f592af 124
252b5132 125#define TARGET_FORMAT \
a245a9aa 126 (!target_big_endian \
252b5132
RH
127 ? (sh_small ? "coff-shl-small" : "coff-shl") \
128 : (sh_small ? "coff-sh-small" : "coff-sh"))
94f592af 129
252b5132 130#endif
056350c6
NC
131#endif
132
133#ifdef TC_MIPS
134#define COFF_WITH_PE
135#include "coff/mipspe.h"
136#undef TARGET_FORMAT
137#define TARGET_FORMAT "pe-mips"
138#endif
252b5132 139
252b5132
RH
140#ifdef TC_TIC30
141#include "coff/tic30.h"
142#define TARGET_FORMAT "coff-tic30"
143#endif
144
026df7c5
NC
145#ifdef TC_TIC4X
146#include "coff/tic4x.h"
be33c5dd 147#define TARGET_FORMAT "coff2-tic4x"
026df7c5
NC
148#endif
149
39bec121
TW
150#ifdef TC_TIC54X
151#include "coff/tic54x.h"
152#define TARGET_FORMAT "coff1-c54x"
153#endif
154
252b5132
RH
155#ifdef TC_MCORE
156#include "coff/mcore.h"
157#ifndef TARGET_FORMAT
158#define TARGET_FORMAT "pe-mcore"
159#endif
160#endif
161
977cdf5a
NC
162#ifdef TE_PE
163/* PE weak symbols need USE_UNIQUE. */
164#define USE_UNIQUE 1
06e77878
AO
165
166#define obj_set_weak_hook pecoff_obj_set_weak_hook
167#define obj_clear_weak_hook pecoff_obj_clear_weak_hook
977cdf5a
NC
168#endif
169
252b5132
RH
170#ifndef OBJ_COFF_MAX_AUXENTRIES
171#define OBJ_COFF_MAX_AUXENTRIES 1
977cdf5a 172#endif
252b5132 173
252b5132 174#define obj_symbol_new_hook coff_obj_symbol_new_hook
252b5132
RH
175#define obj_read_begin_hook coff_obj_read_begin_hook
176
252b5132
RH
177#include "bfd/libcoff.h"
178
179#define OUTPUT_FLAVOR bfd_target_coff_flavour
180
252b5132
RH
181/* Alter the field names, for now, until we've fixed up the other
182 references to use the new name. */
183#ifdef TC_I960
49309057 184#define TC_SYMFIELD_TYPE symbolS *
252b5132
RH
185#define sy_tc bal
186#endif
187
188#define OBJ_SYMFIELD_TYPE unsigned long
189#define sy_obj sy_flags
190
a161fe53
AM
191/* We can't use the predefined section symbols in bfd/section.c, as
192 COFF symbols have extra fields. See bfd/libcoff.h:coff_symbol_type. */
193#ifndef obj_sec_sym_ok_for_reloc
194#define obj_sec_sym_ok_for_reloc(SEC) ((SEC)->owner != 0)
195#endif
196
49309057
ILT
197#define SYM_AUXENT(S) \
198 (&coffsymbol (symbol_get_bfdsym (S))->native[1].u.auxent)
199#define SYM_AUXINFO(S) \
200 (&coffsymbol (symbol_get_bfdsym (S))->native[1])
252b5132 201
3b16e843 202/* The number of auxiliary entries. */
49309057
ILT
203#define S_GET_NUMBER_AUXILIARY(s) \
204 (coffsymbol (symbol_get_bfdsym (s))->native->u.syment.n_numaux)
3b16e843 205/* The number of auxiliary entries. */
a5324a3e 206#define S_SET_NUMBER_AUXILIARY(s, v) (S_GET_NUMBER_AUXILIARY (s) = (v))
252b5132 207
dcd619be 208/* True if a symbol name is in the string table, i.e. its length is > 8. */
a5324a3e 209#define S_IS_STRING(s) (strlen (S_GET_NAME (s)) > 8 ? 1 : 0)
252b5132 210
3b16e843
NC
211/* Auxiliary entry macros. SA_ stands for symbol auxiliary. */
212/* Omit the tv related fields. */
213/* Accessors. */
252b5132
RH
214
215#define SA_GET_SYM_TAGNDX(s) (SYM_AUXENT (s)->x_sym.x_tagndx.l)
216#define SA_GET_SYM_LNNO(s) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_lnno)
217#define SA_GET_SYM_SIZE(s) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_size)
218#define SA_GET_SYM_FSIZE(s) (SYM_AUXENT (s)->x_sym.x_misc.x_fsize)
219#define SA_GET_SYM_LNNOPTR(s) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_lnnoptr)
220#define SA_GET_SYM_ENDNDX(s) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_endndx)
221#define SA_GET_SYM_DIMEN(s,i) (SYM_AUXENT (s)->x_sym.x_fcnary.x_ary.x_dimen[(i)])
222#define SA_GET_FILE_FNAME(s) (SYM_AUXENT (s)->x_file.x_fname)
223#define SA_GET_SCN_SCNLEN(s) (SYM_AUXENT (s)->x_scn.x_scnlen)
224#define SA_GET_SCN_NRELOC(s) (SYM_AUXENT (s)->x_scn.x_nreloc)
225#define SA_GET_SCN_NLINNO(s) (SYM_AUXENT (s)->x_scn.x_nlinno)
226
a5324a3e
NC
227#define SA_SET_SYM_LNNO(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_lnno = (v))
228#define SA_SET_SYM_SIZE(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_size = (v))
229#define SA_SET_SYM_FSIZE(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_fsize = (v))
230#define SA_SET_SYM_LNNOPTR(s,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_lnnoptr = (v))
231#define SA_SET_SYM_DIMEN(s,i,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_ary.x_dimen[(i)] = (v))
232#define SA_SET_FILE_FNAME(s,v) strncpy (SYM_AUXENT (s)->x_file.x_fname, (v), FILNMLEN)
233#define SA_SET_SCN_SCNLEN(s,v) (SYM_AUXENT (s)->x_scn.x_scnlen = (v))
234#define SA_SET_SCN_NRELOC(s,v) (SYM_AUXENT (s)->x_scn.x_nreloc = (v))
235#define SA_SET_SCN_NLINNO(s,v) (SYM_AUXENT (s)->x_scn.x_nlinno = (v))
252b5132 236
3b16e843 237/* Internal use only definitions. SF_ stands for symbol flags.
5d6255fe 238
3b16e843 239 These values can be assigned to sy_symbol.ost_flags field of a symbolS.
5d6255fe 240
3b16e843
NC
241 You'll break i960 if you shift the SYSPROC bits anywhere else. for
242 more on the balname/callname hack, see tc-i960.h. b.out is done
243 differently. */
252b5132 244
a5324a3e
NC
245#define SF_I960_MASK 0x000001ff /* Bits 0-8 are used by the i960 port. */
246#define SF_SYSPROC 0x0000003f /* bits 0-5 are used to store the sysproc number. */
247#define SF_IS_SYSPROC 0x00000040 /* bit 6 marks symbols that are sysprocs. */
248#define SF_BALNAME 0x00000080 /* bit 7 marks BALNAME symbols. */
249#define SF_CALLNAME 0x00000100 /* bit 8 marks CALLNAME symbols. */
250
251#define SF_NORMAL_MASK 0x0000ffff /* bits 12-15 are general purpose. */
252
253#define SF_STATICS 0x00001000 /* Mark the .text & all symbols. */
254#define SF_DEFINED 0x00002000 /* Symbol is defined in this file. */
255#define SF_STRING 0x00004000 /* Symbol name length > 8. */
256#define SF_LOCAL 0x00008000 /* Symbol must not be emitted. */
257
258#define SF_DEBUG_MASK 0xffff0000 /* bits 16-31 are debug info. */
259
260#define SF_FUNCTION 0x00010000 /* The symbol is a function. */
261#define SF_PROCESS 0x00020000 /* Process symbol before write. */
262#define SF_TAGGED 0x00040000 /* Is associated with a tag. */
263#define SF_TAG 0x00080000 /* Is a tag. */
264#define SF_DEBUG 0x00100000 /* Is in debug or abs section. */
265#define SF_GET_SEGMENT 0x00200000 /* Get the section of the forward symbol. */
dcd619be 266/* All other bits are unused. */
252b5132 267
3b16e843 268/* Accessors. */
a5324a3e 269#define SF_GET(s) (* symbol_get_obj (s))
49309057
ILT
270#define SF_GET_DEBUG(s) (symbol_get_bfdsym (s)->flags & BSF_DEBUGGING)
271#define SF_SET_DEBUG(s) (symbol_get_bfdsym (s)->flags |= BSF_DEBUGGING)
252b5132
RH
272#define SF_GET_NORMAL_FIELD(s) (SF_GET (s) & SF_NORMAL_MASK)
273#define SF_GET_DEBUG_FIELD(s) (SF_GET (s) & SF_DEBUG_MASK)
274#define SF_GET_FILE(s) (SF_GET (s) & SF_FILE)
275#define SF_GET_STATICS(s) (SF_GET (s) & SF_STATICS)
276#define SF_GET_DEFINED(s) (SF_GET (s) & SF_DEFINED)
277#define SF_GET_STRING(s) (SF_GET (s) & SF_STRING)
278#define SF_GET_LOCAL(s) (SF_GET (s) & SF_LOCAL)
279#define SF_GET_FUNCTION(s) (SF_GET (s) & SF_FUNCTION)
280#define SF_GET_PROCESS(s) (SF_GET (s) & SF_PROCESS)
281#define SF_GET_TAGGED(s) (SF_GET (s) & SF_TAGGED)
282#define SF_GET_TAG(s) (SF_GET (s) & SF_TAG)
283#define SF_GET_GET_SEGMENT(s) (SF_GET (s) & SF_GET_SEGMENT)
a5324a3e
NC
284#define SF_GET_I960(s) (SF_GET (s) & SF_I960_MASK) /* Used by i960. */
285#define SF_GET_BALNAME(s) (SF_GET (s) & SF_BALNAME) /* Used by i960. */
286#define SF_GET_CALLNAME(s) (SF_GET (s) & SF_CALLNAME) /* Used by i960. */
287#define SF_GET_IS_SYSPROC(s) (SF_GET (s) & SF_IS_SYSPROC) /* Used by i960. */
288#define SF_GET_SYSPROC(s) (SF_GET (s) & SF_SYSPROC) /* Used by i960. */
252b5132 289
3b16e843 290/* Modifiers. */
252b5132 291#define SF_SET(s,v) (SF_GET (s) = (v))
a5324a3e 292#define SF_SET_NORMAL_FIELD(s,v)(SF_GET (s) |= ((v) & SF_NORMAL_MASK))
252b5132
RH
293#define SF_SET_DEBUG_FIELD(s,v) (SF_GET (s) |= ((v) & SF_DEBUG_MASK))
294#define SF_SET_FILE(s) (SF_GET (s) |= SF_FILE)
295#define SF_SET_STATICS(s) (SF_GET (s) |= SF_STATICS)
296#define SF_SET_DEFINED(s) (SF_GET (s) |= SF_DEFINED)
297#define SF_SET_STRING(s) (SF_GET (s) |= SF_STRING)
298#define SF_SET_LOCAL(s) (SF_GET (s) |= SF_LOCAL)
299#define SF_CLEAR_LOCAL(s) (SF_GET (s) &= ~SF_LOCAL)
300#define SF_SET_FUNCTION(s) (SF_GET (s) |= SF_FUNCTION)
301#define SF_SET_PROCESS(s) (SF_GET (s) |= SF_PROCESS)
302#define SF_SET_TAGGED(s) (SF_GET (s) |= SF_TAGGED)
303#define SF_SET_TAG(s) (SF_GET (s) |= SF_TAG)
304#define SF_SET_GET_SEGMENT(s) (SF_GET (s) |= SF_GET_SEGMENT)
a5324a3e
NC
305#define SF_SET_I960(s,v) (SF_GET (s) |= ((v) & SF_I960_MASK)) /* Used by i960. */
306#define SF_SET_BALNAME(s) (SF_GET (s) |= SF_BALNAME) /* Used by i960. */
307#define SF_SET_CALLNAME(s) (SF_GET (s) |= SF_CALLNAME) /* Used by i960. */
308#define SF_SET_IS_SYSPROC(s) (SF_GET (s) |= SF_IS_SYSPROC) /* Used by i960. */
309#define SF_SET_SYSPROC(s,v) (SF_GET (s) |= ((v) & SF_SYSPROC)) /* Used by i960. */
252b5132 310
a5324a3e
NC
311
312/* Line number handling. */
252b5132
RH
313extern int text_lineno_number;
314extern int coff_line_base;
315extern int coff_n_line_nos;
a5324a3e 316extern symbolS *coff_last_function;
252b5132 317
a5324a3e
NC
318#define obj_emit_lineno(WHERE, LINE, FILE_START) abort ()
319#define obj_app_file(name, app) c_dot_file_symbol (name, app)
320#define obj_frob_symbol(S,P) coff_frob_symbol (S, & P)
321#define obj_frob_section(S) coff_frob_section (S)
322#define obj_frob_file_after_relocs() coff_frob_file_after_relocs ()
252b5132 323#ifndef obj_adjust_symtab
a5324a3e 324#define obj_adjust_symtab() coff_adjust_symtab ()
252b5132 325#endif
252b5132
RH
326
327/* Forward the segment of a forwarded symbol, handle assignments that
328 just copy symbol values, etc. */
2c1c4c62 329#ifndef OBJ_COPY_SYMBOL_ATTRIBUTES
252b5132 330#ifndef TE_I386AIX
a5324a3e 331#define OBJ_COPY_SYMBOL_ATTRIBUTES(dest, src) \
252b5132
RH
332 (SF_GET_GET_SEGMENT (dest) \
333 ? (S_SET_SEGMENT (dest, S_GET_SEGMENT (src)), 0) \
334 : 0)
335#else
a5324a3e 336#define OBJ_COPY_SYMBOL_ATTRIBUTES(dest, src) \
252b5132
RH
337 (SF_GET_GET_SEGMENT (dest) && S_GET_SEGMENT (dest) == SEG_UNKNOWN \
338 ? (S_SET_SEGMENT (dest, S_GET_SEGMENT (src)), 0) \
339 : 0)
340#endif
2c1c4c62 341#endif
252b5132 342
3b16e843 343/* Sanity check. */
252b5132
RH
344
345#ifdef TC_I960
346#ifndef C_LEAFSTAT
347hey ! Where is the C_LEAFSTAT definition ? i960 - coff support is depending on it.
348#endif /* no C_LEAFSTAT */
349#endif /* TC_I960 */
350
4c63da97
AM
351extern const pseudo_typeS coff_pseudo_table[];
352
353#ifndef obj_pop_insert
354#define obj_pop_insert() pop_insert (coff_pseudo_table)
355#endif
356
252b5132
RH
357/* In COFF, if a symbol is defined using .def/.val SYM/.endef, it's OK
358 to redefine the symbol later on. This can happen if C symbols use
359 a prefix, and a symbol is defined both with and without the prefix,
360 as in start/_start/__start in gcc/libgcc1-test.c. */
361#define RESOLVE_SYMBOL_REDEFINITION(sym) \
362(SF_GET_GET_SEGMENT (sym) \
363 ? (sym->sy_frag = frag_now, \
364 S_SET_VALUE (sym, frag_now_fix ()), \
365 S_SET_SEGMENT (sym, now_seg), \
366 0) \
367 : 0)
368
369/* Stabs in a coff file go into their own section. */
370#define SEPARATE_STAB_SECTIONS 1
371
372/* We need 12 bytes at the start of the section to hold some initial
373 information. */
252b5132
RH
374#define INIT_STAB_SECTION(seg) obj_coff_init_stab_section (seg)
375
945a1a6b
ILT
376/* Store the number of relocations in the section aux entry. */
377#define SET_SECTION_RELOCS(sec, relocs, n) \
378 SA_SET_SCN_NRELOC (section_symbol (sec), n)
379
a5324a3e
NC
380#define obj_app_file(name, app) c_dot_file_symbol (name, app)
381
a5324a3e
NC
382extern int S_SET_DATA_TYPE (symbolS *, int);
383extern int S_SET_STORAGE_CLASS (symbolS *, int);
384extern int S_GET_STORAGE_CLASS (symbolS *);
385extern void SA_SET_SYM_ENDNDX (symbolS *, symbolS *);
386extern void coff_add_linesym (symbolS *);
387extern void c_dot_file_symbol (const char *, int);
388extern void coff_frob_symbol (symbolS *, int *);
389extern void coff_adjust_symtab (void);
390extern void coff_frob_section (segT);
391extern void coff_adjust_section_syms (bfd *, asection *, void *);
392extern void coff_frob_file_after_relocs (void);
a5324a3e
NC
393extern void coff_obj_symbol_new_hook (symbolS *);
394extern void coff_obj_read_begin_hook (void);
06e77878
AO
395#ifdef TE_PE
396extern void pecoff_obj_set_weak_hook (symbolS *);
397extern void pecoff_obj_clear_weak_hook (symbolS *);
398#endif
a5324a3e
NC
399extern void obj_coff_section (int);
400extern segT obj_coff_add_segment (const char *);
401extern void obj_coff_section (int);
402extern void c_dot_file_symbol (const char *, int);
403extern segT s_get_segment (symbolS *);
36bfbdd3 404#ifndef tc_coff_symbol_emit_hook
a5324a3e 405extern void tc_coff_symbol_emit_hook (symbolS *);
36bfbdd3 406#endif
a5324a3e
NC
407extern void obj_coff_pe_handle_link_once (void);
408extern void obj_coff_init_stab_section (segT);
409extern void c_section_header (struct internal_scnhdr *,
410 char *, long, long, long, long,
411 long, long, long, long);
252b5132 412#endif /* OBJ_FORMAT_H */
This page took 0.39672 seconds and 4 git commands to generate.