133965Sjdp/* ELF object file format.
2130561Sobrien   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3218822Sdim   2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
433965Sjdp
533965Sjdp   This file is part of GAS, the GNU Assembler.
633965Sjdp
733965Sjdp   GAS is free software; you can redistribute it and/or modify
833965Sjdp   it under the terms of the GNU General Public License as published by
977298Sobrien   the Free Software Foundation; either version 2, or (at your option)
1033965Sjdp   any later version.
1133965Sjdp
1233965Sjdp   GAS is distributed in the hope that it will be useful,
1333965Sjdp   but WITHOUT ANY WARRANTY; without even the implied warranty of
1433965Sjdp   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1533965Sjdp   GNU General Public License for more details.
1633965Sjdp
1733965Sjdp   You should have received a copy of the GNU General Public License
1833965Sjdp   along with GAS; see the file COPYING.  If not, write to the Free
19218822Sdim   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20218822Sdim   02110-1301, USA.  */
2133965Sjdp
2233965Sjdp/* HP PA-RISC support was contributed by the Center for Software Science
2333965Sjdp   at the University of Utah.  */
2433965Sjdp
2533965Sjdp#ifndef _OBJ_ELF_H
2633965Sjdp#define _OBJ_ELF_H
2733965Sjdp
2833965Sjdp#define OBJ_ELF 1
2933965Sjdp
3077298Sobrien/* Note that all macros in this file should be wrapped in #ifndef, for
3177298Sobrien   sake of obj-multi.h which includes this file.  */
3277298Sobrien
3360484Sobrien#ifndef OUTPUT_FLAVOR
3433965Sjdp#define OUTPUT_FLAVOR bfd_target_elf_flavour
3560484Sobrien#endif
3633965Sjdp
3733965Sjdp#define BYTES_IN_WORD 4		/* for now */
3833965Sjdp#include "bfd/elf-bfd.h"
3933965Sjdp
4060484Sobrien#include "targ-cpu.h"
4160484Sobrien
4260484Sobrien#ifdef TC_ALPHA
4377298Sobrien#define ECOFF_DEBUGGING (alpha_flag_mdebug > 0)
4460484Sobrienextern int alpha_flag_mdebug;
4560484Sobrien#endif
4660484Sobrien
4760484Sobrien/* For now, always set ECOFF_DEBUGGING for a MIPS target.  */
4860484Sobrien#ifdef TC_MIPS
49104834Sobrien#define ECOFF_DEBUGGING mips_flag_mdebug
50104834Sobrienextern int mips_flag_mdebug;
5160484Sobrien#endif /* TC_MIPS */
5260484Sobrien
5360484Sobrien#ifdef OBJ_MAYBE_ECOFF
5460484Sobrien#ifndef ECOFF_DEBUGGING
5560484Sobrien#define ECOFF_DEBUGGING 1
5660484Sobrien#endif
5760484Sobrien#endif
5860484Sobrien
5933965Sjdp/* Additional information we keep for each symbol.  */
6033965Sjdpstruct elf_obj_sy
6133965Sjdp{
6260484Sobrien  /* Whether the symbol has been marked as local.  */
6360484Sobrien  int local;
6460484Sobrien
6533965Sjdp  /* Use this to keep track of .size expressions that involve
6633965Sjdp     differences that we can't compute yet.  */
6733965Sjdp  expressionS *size;
6833965Sjdp
6933965Sjdp  /* The name specified by the .symver directive.  */
7033965Sjdp  char *versioned_name;
7160484Sobrien
7260484Sobrien#ifdef ECOFF_DEBUGGING
7360484Sobrien  /* If we are generating ECOFF debugging information, we need some
7460484Sobrien     additional fields for each symbol.  */
7560484Sobrien  struct efdr *ecoff_file;
7660484Sobrien  struct localsym *ecoff_symbol;
7760484Sobrien  valueT ecoff_extern_size;
7860484Sobrien#endif
7933965Sjdp};
8033965Sjdp
8133965Sjdp#define OBJ_SYMFIELD_TYPE struct elf_obj_sy
8233965Sjdp
8377298Sobrien/* Symbol fields used by the ELF back end.  */
84218822Sdim#define ELF_TARGET_SYMBOL_FIELDS unsigned int local:1;
8577298Sobrien
8677298Sobrien/* Don't change this; change ELF_TARGET_SYMBOL_FIELDS instead.  */
87104834Sobrien#ifndef TARGET_SYMBOL_FIELDS
8877298Sobrien#define TARGET_SYMBOL_FIELDS ELF_TARGET_SYMBOL_FIELDS
89104834Sobrien#endif
9077298Sobrien
9133965Sjdp#ifndef FALSE
9233965Sjdp#define FALSE 0
9333965Sjdp#define TRUE  !FALSE
9433965Sjdp#endif
9533965Sjdp
9677298Sobrien#ifndef obj_begin
9733965Sjdp#define obj_begin() elf_begin ()
9877298Sobrien#endif
99130561Sobrienextern void elf_begin (void);
10033965Sjdp
10133965Sjdp/* should be conditional on address size! */
10277298Sobrien#define elf_symbol(asymbol) ((elf_symbol_type *) (&(asymbol)->the_bfd))
10333965Sjdp
10460484Sobrien#ifndef S_GET_SIZE
10560484Sobrien#define S_GET_SIZE(S) \
10660484Sobrien  (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size)
10760484Sobrien#endif
10860484Sobrien#ifndef S_SET_SIZE
10933965Sjdp#define S_SET_SIZE(S,V) \
11060484Sobrien  (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size = (V))
11160484Sobrien#endif
11233965Sjdp
11360484Sobrien#ifndef S_GET_ALIGN
11460484Sobrien#define S_GET_ALIGN(S) \
11560484Sobrien  (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value)
11660484Sobrien#endif
11760484Sobrien#ifndef S_SET_ALIGN
11833965Sjdp#define S_SET_ALIGN(S,V) \
11960484Sobrien  (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value = (V))
12060484Sobrien#endif
12133965Sjdp
122130561Sobrienint elf_s_get_other (symbolS *);
12360484Sobrien#ifndef S_GET_OTHER
12460484Sobrien#define S_GET_OTHER(S)	(elf_s_get_other (S))
12560484Sobrien#endif
12660484Sobrien#ifndef S_SET_OTHER
12733965Sjdp#define S_SET_OTHER(S,V) \
12860484Sobrien  (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_other = (V))
12960484Sobrien#endif
13033965Sjdp
13133965Sjdpextern asection *gdb_section;
13233965Sjdp
13360484Sobrien#ifndef obj_frob_file
13433965Sjdp#define obj_frob_file  elf_frob_file
13560484Sobrien#endif
136130561Sobrienextern void elf_frob_file (void);
13733965Sjdp
13877298Sobrien#ifndef obj_frob_file_before_adjust
13977298Sobrien#define obj_frob_file_before_adjust  elf_frob_file_before_adjust
14077298Sobrien#endif
141130561Sobrienextern void elf_frob_file_before_adjust (void);
14277298Sobrien
14360484Sobrien#ifndef obj_frob_file_after_relocs
14433965Sjdp#define obj_frob_file_after_relocs  elf_frob_file_after_relocs
14560484Sobrien#endif
146130561Sobrienextern void elf_frob_file_after_relocs (void);
14733965Sjdp
148218822Sdim/* If the target doesn't have special processing for labels, take care of
149218822Sdim   dwarf2 output at the object file level.  */
150218822Sdim#ifndef tc_frob_label
151218822Sdim#include "dwarf2dbg.h"
152218822Sdim#define obj_frob_label  dwarf2_emit_label
153218822Sdim#endif
154218822Sdim
15577298Sobrien#ifndef obj_app_file
15633965Sjdp#define obj_app_file elf_file_symbol
15777298Sobrien#endif
158218822Sdimextern void elf_file_symbol (const char *, int);
15933965Sjdp
160130561Sobrienextern void obj_elf_section_change_hook (void);
16133965Sjdp
162130561Sobrienextern void obj_elf_section (int);
163130561Sobrienextern void obj_elf_previous (int);
164130561Sobrienextern void obj_elf_version (int);
165130561Sobrienextern void obj_elf_common (int);
166130561Sobrienextern void obj_elf_data (int);
167130561Sobrienextern void obj_elf_text (int);
168130561Sobrienextern void obj_elf_change_section
169130561Sobrien  (const char *, int, int, int, const char *, int, int);
170130561Sobrienextern struct fix *obj_elf_vtable_inherit (int);
171130561Sobrienextern struct fix *obj_elf_vtable_entry (int);
17233965Sjdp
17333965Sjdp/* BFD wants to write the udata field, which is a no-no for the
174130561Sobrien   predefined section symbols in bfd/section.c.  They are read-only.  */
17560484Sobrien#ifndef obj_sec_sym_ok_for_reloc
17633965Sjdp#define obj_sec_sym_ok_for_reloc(SEC)	((SEC)->owner != 0)
17760484Sobrien#endif
17833965Sjdp
179130561Sobrienvoid elf_obj_read_begin_hook (void);
18060484Sobrien#ifndef obj_read_begin_hook
18160484Sobrien#define obj_read_begin_hook	elf_obj_read_begin_hook
18260484Sobrien#endif
18360484Sobrien
184130561Sobrienvoid elf_obj_symbol_new_hook (symbolS *);
18560484Sobrien#ifndef obj_symbol_new_hook
18660484Sobrien#define obj_symbol_new_hook	elf_obj_symbol_new_hook
18760484Sobrien#endif
18860484Sobrien
189130561Sobrienvoid elf_copy_symbol_attributes (symbolS *, symbolS *);
19060484Sobrien#ifndef OBJ_COPY_SYMBOL_ATTRIBUTES
19189857Sobrien#define OBJ_COPY_SYMBOL_ATTRIBUTES(DEST, SRC) \
19289857Sobrien  (elf_copy_symbol_attributes (DEST, SRC))
19360484Sobrien#endif
19433965Sjdp
19577298Sobrien#ifndef SEPARATE_STAB_SECTIONS
19677298Sobrien/* Avoid ifndef each separate macro setting by wrapping the whole of the
19777298Sobrien   stab group on the assumption that whoever sets SEPARATE_STAB_SECTIONS
19877298Sobrien   caters to ECOFF_DEBUGGING and the right setting of INIT_STAB_SECTIONS
19977298Sobrien   and OBJ_PROCESS_STAB too, without needing the tweaks below.  */
20077298Sobrien
20133965Sjdp/* Stabs go in a separate section.  */
20233965Sjdp#define SEPARATE_STAB_SECTIONS 1
20333965Sjdp
20433965Sjdp/* We need 12 bytes at the start of the section to hold some initial
20533965Sjdp   information.  */
206130561Sobrienextern void obj_elf_init_stab_section (segT);
20733965Sjdp#define INIT_STAB_SECTION(seg) obj_elf_init_stab_section (seg)
20833965Sjdp
20960484Sobrien#ifdef ECOFF_DEBUGGING
21033965Sjdp/* We smuggle stabs in ECOFF rather than using a separate section.
21133965Sjdp   The Irix linker can not handle a separate stabs section.  */
21233965Sjdp
21360484Sobrien#undef  SEPARATE_STAB_SECTIONS
21460484Sobrien#define SEPARATE_STAB_SECTIONS (!ECOFF_DEBUGGING)
21533965Sjdp
21660484Sobrien#undef  INIT_STAB_SECTION
21760484Sobrien#define INIT_STAB_SECTION(seg) \
21877298Sobrien  ((void) (ECOFF_DEBUGGING ? 0 : (obj_elf_init_stab_section (seg), 0)))
21960484Sobrien
22060484Sobrien#undef OBJ_PROCESS_STAB
22160484Sobrien#define OBJ_PROCESS_STAB(seg, what, string, type, other, desc)		\
22260484Sobrien  if (ECOFF_DEBUGGING)							\
22360484Sobrien    ecoff_stab ((seg), (what), (string), (type), (other), (desc))
22433965Sjdp#endif /* ECOFF_DEBUGGING */
22533965Sjdp
22677298Sobrien#endif /* SEPARATE_STAB_SECTIONS not defined.  */
22777298Sobrien
228130561Sobrienextern void elf_frob_symbol (symbolS *, int *);
22960484Sobrien#ifndef obj_frob_symbol
23033965Sjdp#define obj_frob_symbol(symp, punt) elf_frob_symbol (symp, &punt)
23160484Sobrien#endif
23233965Sjdp
233130561Sobrienextern void elf_pop_insert (void);
23460484Sobrien#ifndef obj_pop_insert
23533965Sjdp#define obj_pop_insert()	elf_pop_insert()
23660484Sobrien#endif
23733965Sjdp
23833965Sjdp#ifndef OBJ_MAYBE_ELF
239218822Sdim/* If OBJ_MAYBE_ELF then obj-multi.h will define obj_ecoff_set_ext.  */
24033965Sjdp#define obj_ecoff_set_ext elf_ecoff_set_ext
24133965Sjdpstruct ecoff_extr;
242130561Sobrienextern void elf_ecoff_set_ext (symbolS *, struct ecoff_extr *);
24333965Sjdp#endif
244218822Sdimextern asection *elf_com_section_ptr;
245218822Sdimextern symbolS * elf_common_parse (int ignore ATTRIBUTE_UNUSED, symbolS *symbolP,
246218822Sdim				   addressT size);
24733965Sjdp
24833965Sjdp#endif /* _OBJ_ELF_H */
249