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