gdb/testsuite/gdb.base/stap-probe: Minor clean-up
[deliverable/binutils-gdb.git] / gas / config / obj-coff.h
CommitLineData
252b5132 1/* coff object file format
b3adc24a 2 Copyright (C) 1989-2020 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
252b5132 51#ifdef TC_I386
321098a5 52#ifdef TE_PEP
99ad8390
NC
53#include "coff/x86_64.h"
54#else
252b5132 55#include "coff/i386.h"
99ad8390 56#endif
252b5132 57
252b5132 58#ifndef TARGET_FORMAT
99ad8390
NC
59#ifdef TE_PEP
60#define TARGET_FORMAT "coff-x86-64"
61#else
252b5132
RH
62#define TARGET_FORMAT "coff-i386"
63#endif
64#endif
99ad8390 65#endif
252b5132
RH
66
67#ifdef TC_M68K
68#include "coff/m68k.h"
69#ifndef TARGET_FORMAT
70#define TARGET_FORMAT "coff-m68k"
71#endif
72#endif
73
3c9b82ba
NC
74#ifdef TC_Z80
75#include "coff/z80.h"
76#define TARGET_FORMAT "coff-z80"
77#endif
78
252b5132
RH
79#ifdef TC_Z8K
80#include "coff/z8k.h"
81#define TARGET_FORMAT "coff-z8k"
82#endif
83
252b5132 84#ifdef TC_SH
056350c6
NC
85
86#ifdef TE_PE
87#define COFF_WITH_PE
88#endif
89
252b5132 90#include "coff/sh.h"
056350c6
NC
91
92#ifdef TE_PE
93#define TARGET_FORMAT "pe-shl"
94#else
94f592af 95
252b5132 96#define TARGET_FORMAT \
a245a9aa 97 (!target_big_endian \
252b5132
RH
98 ? (sh_small ? "coff-shl-small" : "coff-shl") \
99 : (sh_small ? "coff-sh-small" : "coff-sh"))
94f592af 100
252b5132 101#endif
056350c6
NC
102#endif
103
104#ifdef TC_MIPS
105#define COFF_WITH_PE
106#include "coff/mipspe.h"
107#undef TARGET_FORMAT
108#define TARGET_FORMAT "pe-mips"
109#endif
252b5132 110
252b5132
RH
111#ifdef TC_TIC30
112#include "coff/tic30.h"
113#define TARGET_FORMAT "coff-tic30"
114#endif
115
026df7c5
NC
116#ifdef TC_TIC4X
117#include "coff/tic4x.h"
be33c5dd 118#define TARGET_FORMAT "coff2-tic4x"
026df7c5
NC
119#endif
120
39bec121
TW
121#ifdef TC_TIC54X
122#include "coff/tic54x.h"
123#define TARGET_FORMAT "coff1-c54x"
124#endif
125
252b5132
RH
126#ifdef TC_MCORE
127#include "coff/mcore.h"
128#ifndef TARGET_FORMAT
129#define TARGET_FORMAT "pe-mcore"
130#endif
131#endif
132
977cdf5a 133#ifdef TE_PE
06e77878
AO
134#define obj_set_weak_hook pecoff_obj_set_weak_hook
135#define obj_clear_weak_hook pecoff_obj_clear_weak_hook
977cdf5a
NC
136#endif
137
252b5132
RH
138#ifndef OBJ_COFF_MAX_AUXENTRIES
139#define OBJ_COFF_MAX_AUXENTRIES 1
977cdf5a 140#endif
252b5132 141
252b5132 142#define obj_symbol_new_hook coff_obj_symbol_new_hook
6a2b6326 143#define obj_symbol_clone_hook coff_obj_symbol_clone_hook
252b5132
RH
144#define obj_read_begin_hook coff_obj_read_begin_hook
145
252b5132
RH
146#include "bfd/libcoff.h"
147
148#define OUTPUT_FLAVOR bfd_target_coff_flavour
149
252b5132
RH
150/* Alter the field names, for now, until we've fixed up the other
151 references to use the new name. */
252b5132 152#define OBJ_SYMFIELD_TYPE unsigned long
0a4734dc 153#define sy_obj sy_obj_flags
252b5132 154
a161fe53
AM
155/* We can't use the predefined section symbols in bfd/section.c, as
156 COFF symbols have extra fields. See bfd/libcoff.h:coff_symbol_type. */
157#ifndef obj_sec_sym_ok_for_reloc
158#define obj_sec_sym_ok_for_reloc(SEC) ((SEC)->owner != 0)
159#endif
160
49309057
ILT
161#define SYM_AUXENT(S) \
162 (&coffsymbol (symbol_get_bfdsym (S))->native[1].u.auxent)
163#define SYM_AUXINFO(S) \
164 (&coffsymbol (symbol_get_bfdsym (S))->native[1])
252b5132 165
3b16e843 166/* The number of auxiliary entries. */
49309057
ILT
167#define S_GET_NUMBER_AUXILIARY(s) \
168 (coffsymbol (symbol_get_bfdsym (s))->native->u.syment.n_numaux)
3b16e843 169/* The number of auxiliary entries. */
a5324a3e 170#define S_SET_NUMBER_AUXILIARY(s, v) (S_GET_NUMBER_AUXILIARY (s) = (v))
252b5132 171
dcd619be 172/* True if a symbol name is in the string table, i.e. its length is > 8. */
a5324a3e 173#define S_IS_STRING(s) (strlen (S_GET_NAME (s)) > 8 ? 1 : 0)
252b5132 174
3b16e843
NC
175/* Auxiliary entry macros. SA_ stands for symbol auxiliary. */
176/* Omit the tv related fields. */
177/* Accessors. */
252b5132
RH
178
179#define SA_GET_SYM_TAGNDX(s) (SYM_AUXENT (s)->x_sym.x_tagndx.l)
180#define SA_GET_SYM_LNNO(s) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_lnno)
181#define SA_GET_SYM_SIZE(s) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_size)
182#define SA_GET_SYM_FSIZE(s) (SYM_AUXENT (s)->x_sym.x_misc.x_fsize)
183#define SA_GET_SYM_LNNOPTR(s) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_lnnoptr)
184#define SA_GET_SYM_ENDNDX(s) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_endndx)
185#define SA_GET_SYM_DIMEN(s,i) (SYM_AUXENT (s)->x_sym.x_fcnary.x_ary.x_dimen[(i)])
186#define SA_GET_FILE_FNAME(s) (SYM_AUXENT (s)->x_file.x_fname)
187#define SA_GET_SCN_SCNLEN(s) (SYM_AUXENT (s)->x_scn.x_scnlen)
188#define SA_GET_SCN_NRELOC(s) (SYM_AUXENT (s)->x_scn.x_nreloc)
189#define SA_GET_SCN_NLINNO(s) (SYM_AUXENT (s)->x_scn.x_nlinno)
190
a5324a3e
NC
191#define SA_SET_SYM_LNNO(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_lnno = (v))
192#define SA_SET_SYM_SIZE(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_lnsz.x_size = (v))
193#define SA_SET_SYM_FSIZE(s,v) (SYM_AUXENT (s)->x_sym.x_misc.x_fsize = (v))
194#define SA_SET_SYM_LNNOPTR(s,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_fcn.x_lnnoptr = (v))
195#define SA_SET_SYM_DIMEN(s,i,v) (SYM_AUXENT (s)->x_sym.x_fcnary.x_ary.x_dimen[(i)] = (v))
196#define SA_SET_FILE_FNAME(s,v) strncpy (SYM_AUXENT (s)->x_file.x_fname, (v), FILNMLEN)
197#define SA_SET_SCN_SCNLEN(s,v) (SYM_AUXENT (s)->x_scn.x_scnlen = (v))
198#define SA_SET_SCN_NRELOC(s,v) (SYM_AUXENT (s)->x_scn.x_nreloc = (v))
199#define SA_SET_SCN_NLINNO(s,v) (SYM_AUXENT (s)->x_scn.x_nlinno = (v))
252b5132 200
3b16e843 201/* Internal use only definitions. SF_ stands for symbol flags.
5d6255fe 202
a8eb42a8 203 These values can be assigned to sy_symbol.ost_flags field of a symbolS. */
3739860c 204
a5324a3e 205#define SF_NORMAL_MASK 0x0000ffff /* bits 12-15 are general purpose. */
3739860c 206
a5324a3e
NC
207#define SF_STATICS 0x00001000 /* Mark the .text & all symbols. */
208#define SF_DEFINED 0x00002000 /* Symbol is defined in this file. */
209#define SF_STRING 0x00004000 /* Symbol name length > 8. */
210#define SF_LOCAL 0x00008000 /* Symbol must not be emitted. */
3739860c 211
a5324a3e 212#define SF_DEBUG_MASK 0xffff0000 /* bits 16-31 are debug info. */
3739860c 213
a5324a3e
NC
214#define SF_FUNCTION 0x00010000 /* The symbol is a function. */
215#define SF_PROCESS 0x00020000 /* Process symbol before write. */
216#define SF_TAGGED 0x00040000 /* Is associated with a tag. */
217#define SF_TAG 0x00080000 /* Is a tag. */
218#define SF_DEBUG 0x00100000 /* Is in debug or abs section. */
219#define SF_GET_SEGMENT 0x00200000 /* Get the section of the forward symbol. */
dcd619be 220/* All other bits are unused. */
252b5132 221
3b16e843 222/* Accessors. */
a5324a3e 223#define SF_GET(s) (* symbol_get_obj (s))
49309057
ILT
224#define SF_GET_DEBUG(s) (symbol_get_bfdsym (s)->flags & BSF_DEBUGGING)
225#define SF_SET_DEBUG(s) (symbol_get_bfdsym (s)->flags |= BSF_DEBUGGING)
252b5132
RH
226#define SF_GET_NORMAL_FIELD(s) (SF_GET (s) & SF_NORMAL_MASK)
227#define SF_GET_DEBUG_FIELD(s) (SF_GET (s) & SF_DEBUG_MASK)
228#define SF_GET_FILE(s) (SF_GET (s) & SF_FILE)
229#define SF_GET_STATICS(s) (SF_GET (s) & SF_STATICS)
230#define SF_GET_DEFINED(s) (SF_GET (s) & SF_DEFINED)
231#define SF_GET_STRING(s) (SF_GET (s) & SF_STRING)
232#define SF_GET_LOCAL(s) (SF_GET (s) & SF_LOCAL)
233#define SF_GET_FUNCTION(s) (SF_GET (s) & SF_FUNCTION)
234#define SF_GET_PROCESS(s) (SF_GET (s) & SF_PROCESS)
235#define SF_GET_TAGGED(s) (SF_GET (s) & SF_TAGGED)
236#define SF_GET_TAG(s) (SF_GET (s) & SF_TAG)
237#define SF_GET_GET_SEGMENT(s) (SF_GET (s) & SF_GET_SEGMENT)
252b5132 238
3b16e843 239/* Modifiers. */
252b5132 240#define SF_SET(s,v) (SF_GET (s) = (v))
a5324a3e 241#define SF_SET_NORMAL_FIELD(s,v)(SF_GET (s) |= ((v) & SF_NORMAL_MASK))
252b5132
RH
242#define SF_SET_DEBUG_FIELD(s,v) (SF_GET (s) |= ((v) & SF_DEBUG_MASK))
243#define SF_SET_FILE(s) (SF_GET (s) |= SF_FILE)
244#define SF_SET_STATICS(s) (SF_GET (s) |= SF_STATICS)
245#define SF_SET_DEFINED(s) (SF_GET (s) |= SF_DEFINED)
246#define SF_SET_STRING(s) (SF_GET (s) |= SF_STRING)
247#define SF_SET_LOCAL(s) (SF_GET (s) |= SF_LOCAL)
248#define SF_CLEAR_LOCAL(s) (SF_GET (s) &= ~SF_LOCAL)
249#define SF_SET_FUNCTION(s) (SF_GET (s) |= SF_FUNCTION)
250#define SF_SET_PROCESS(s) (SF_GET (s) |= SF_PROCESS)
251#define SF_SET_TAGGED(s) (SF_GET (s) |= SF_TAGGED)
252#define SF_SET_TAG(s) (SF_GET (s) |= SF_TAG)
253#define SF_SET_GET_SEGMENT(s) (SF_GET (s) |= SF_GET_SEGMENT)
252b5132 254
a5324a3e
NC
255
256/* Line number handling. */
252b5132
RH
257extern int text_lineno_number;
258extern int coff_line_base;
259extern int coff_n_line_nos;
a5324a3e 260extern symbolS *coff_last_function;
252b5132 261
a5324a3e
NC
262#define obj_emit_lineno(WHERE, LINE, FILE_START) abort ()
263#define obj_app_file(name, app) c_dot_file_symbol (name, app)
264#define obj_frob_symbol(S,P) coff_frob_symbol (S, & P)
265#define obj_frob_section(S) coff_frob_section (S)
266#define obj_frob_file_after_relocs() coff_frob_file_after_relocs ()
252b5132 267#ifndef obj_adjust_symtab
a5324a3e 268#define obj_adjust_symtab() coff_adjust_symtab ()
252b5132 269#endif
252b5132
RH
270
271/* Forward the segment of a forwarded symbol, handle assignments that
272 just copy symbol values, etc. */
2c1c4c62 273#ifndef OBJ_COPY_SYMBOL_ATTRIBUTES
252b5132 274#ifndef TE_I386AIX
a5324a3e 275#define OBJ_COPY_SYMBOL_ATTRIBUTES(dest, src) \
252b5132
RH
276 (SF_GET_GET_SEGMENT (dest) \
277 ? (S_SET_SEGMENT (dest, S_GET_SEGMENT (src)), 0) \
278 : 0)
279#else
a5324a3e 280#define OBJ_COPY_SYMBOL_ATTRIBUTES(dest, src) \
252b5132
RH
281 (SF_GET_GET_SEGMENT (dest) && S_GET_SEGMENT (dest) == SEG_UNKNOWN \
282 ? (S_SET_SEGMENT (dest, S_GET_SEGMENT (src)), 0) \
283 : 0)
284#endif
2c1c4c62 285#endif
252b5132 286
3b16e843 287/* Sanity check. */
252b5132 288
4c63da97
AM
289extern const pseudo_typeS coff_pseudo_table[];
290
291#ifndef obj_pop_insert
292#define obj_pop_insert() pop_insert (coff_pseudo_table)
293#endif
294
252b5132
RH
295/* In COFF, if a symbol is defined using .def/.val SYM/.endef, it's OK
296 to redefine the symbol later on. This can happen if C symbols use
297 a prefix, and a symbol is defined both with and without the prefix,
298 as in start/_start/__start in gcc/libgcc1-test.c. */
299#define RESOLVE_SYMBOL_REDEFINITION(sym) \
300(SF_GET_GET_SEGMENT (sym) \
301 ? (sym->sy_frag = frag_now, \
302 S_SET_VALUE (sym, frag_now_fix ()), \
303 S_SET_SEGMENT (sym, now_seg), \
304 0) \
305 : 0)
306
307/* Stabs in a coff file go into their own section. */
308#define SEPARATE_STAB_SECTIONS 1
309
310/* We need 12 bytes at the start of the section to hold some initial
311 information. */
252b5132
RH
312#define INIT_STAB_SECTION(seg) obj_coff_init_stab_section (seg)
313
945a1a6b
ILT
314/* Store the number of relocations in the section aux entry. */
315#define SET_SECTION_RELOCS(sec, relocs, n) \
316 SA_SET_SCN_NRELOC (section_symbol (sec), n)
317
a5324a3e
NC
318#define obj_app_file(name, app) c_dot_file_symbol (name, app)
319
a5324a3e
NC
320extern int S_SET_DATA_TYPE (symbolS *, int);
321extern int S_SET_STORAGE_CLASS (symbolS *, int);
322extern int S_GET_STORAGE_CLASS (symbolS *);
323extern void SA_SET_SYM_ENDNDX (symbolS *, symbolS *);
324extern void coff_add_linesym (symbolS *);
325extern void c_dot_file_symbol (const char *, int);
326extern void coff_frob_symbol (symbolS *, int *);
327extern void coff_adjust_symtab (void);
328extern void coff_frob_section (segT);
329extern void coff_adjust_section_syms (bfd *, asection *, void *);
330extern void coff_frob_file_after_relocs (void);
a5324a3e 331extern void coff_obj_symbol_new_hook (symbolS *);
6a2b6326 332extern void coff_obj_symbol_clone_hook (symbolS *, symbolS *);
a5324a3e 333extern void coff_obj_read_begin_hook (void);
06e77878
AO
334#ifdef TE_PE
335extern void pecoff_obj_set_weak_hook (symbolS *);
336extern void pecoff_obj_clear_weak_hook (symbolS *);
337#endif
a5324a3e
NC
338extern void obj_coff_section (int);
339extern segT obj_coff_add_segment (const char *);
340extern void obj_coff_section (int);
341extern void c_dot_file_symbol (const char *, int);
342extern segT s_get_segment (symbolS *);
36bfbdd3 343#ifndef tc_coff_symbol_emit_hook
a5324a3e 344extern void tc_coff_symbol_emit_hook (symbolS *);
36bfbdd3 345#endif
a5324a3e
NC
346extern void obj_coff_pe_handle_link_once (void);
347extern void obj_coff_init_stab_section (segT);
348extern void c_section_header (struct internal_scnhdr *,
349 char *, long, long, long, long,
350 long, long, long, long);
f3d2b04b
KT
351extern void obj_coff_seh_do_final (void);
352
353#ifndef obj_coff_generate_pdata
354#define obj_coff_generate_pdata obj_coff_seh_do_final
355#endif
356
357
252b5132 358#endif /* OBJ_FORMAT_H */
This page took 1.314242 seconds and 4 git commands to generate.