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