171671b9obrien/* ELF object file format.
271671b9obrien   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3d0f678fdim   2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
471671b9obrien
571671b9obrien   This file is part of GAS, the GNU Assembler.
671671b9obrien
771671b9obrien   GAS is free software; you can redistribute it and/or modify
871671b9obrien   it under the terms of the GNU General Public License as published by
971671b9obrien   the Free Software Foundation; either version 2, or (at your option)
1071671b9obrien   any later version.
1171671b9obrien
1271671b9obrien   GAS is distributed in the hope that it will be useful,
1371671b9obrien   but WITHOUT ANY WARRANTY; without even the implied warranty of
1471671b9obrien   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1571671b9obrien   GNU General Public License for more details.
1671671b9obrien
1771671b9obrien   You should have received a copy of the GNU General Public License
1871671b9obrien   along with GAS; see the file COPYING.  If not, write to the Free
190acbbeedim   Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
200acbbeedim   02110-1301, USA.  */
2171671b9obrien
2271671b9obrien/* HP PA-RISC support was contributed by the Center for Software Science
2371671b9obrien   at the University of Utah.  */
2471671b9obrien
2571671b9obrien#ifndef _OBJ_ELF_H
2671671b9obrien#define _OBJ_ELF_H
2771671b9obrien
2871671b9obrien#define OBJ_ELF 1
2971671b9obrien
3071671b9obrien/* Note that all macros in this file should be wrapped in #ifndef, for
3171671b9obrien   sake of obj-multi.h which includes this file.  */
3271671b9obrien
3371671b9obrien#ifndef OUTPUT_FLAVOR
3471671b9obrien#define OUTPUT_FLAVOR bfd_target_elf_flavour
3571671b9obrien#endif
3671671b9obrien
3771671b9obrien#define BYTES_IN_WORD 4		/* for now */
3871671b9obrien#include "bfd/elf-bfd.h"
3971671b9obrien
4071671b9obrien#include "targ-cpu.h"
4171671b9obrien
4271671b9obrien#ifdef TC_ALPHA
4371671b9obrien#define ECOFF_DEBUGGING (alpha_flag_mdebug > 0)
4471671b9obrienextern int alpha_flag_mdebug;
4571671b9obrien#endif
4671671b9obrien
4771671b9obrien/* For now, always set ECOFF_DEBUGGING for a MIPS target.  */
4871671b9obrien#ifdef TC_MIPS
4971671b9obrien#define ECOFF_DEBUGGING mips_flag_mdebug
5071671b9obrienextern int mips_flag_mdebug;
5171671b9obrien#endif /* TC_MIPS */
5271671b9obrien
5371671b9obrien#ifdef OBJ_MAYBE_ECOFF
5471671b9obrien#ifndef ECOFF_DEBUGGING
5571671b9obrien#define ECOFF_DEBUGGING 1
5671671b9obrien#endif
5771671b9obrien#endif
5871671b9obrien
5971671b9obrien/* Additional information we keep for each symbol.  */
6071671b9obrienstruct elf_obj_sy
6171671b9obrien{
6271671b9obrien  /* Whether the symbol has been marked as local.  */
6371671b9obrien  int local;
6471671b9obrien
6571671b9obrien  /* Use this to keep track of .size expressions that involve
6671671b9obrien     differences that we can't compute yet.  */
6771671b9obrien  expressionS *size;
6871671b9obrien
6971671b9obrien  /* The name specified by the .symver directive.  */
7071671b9obrien  char *versioned_name;
7171671b9obrien
7271671b9obrien#ifdef ECOFF_DEBUGGING
7371671b9obrien  /* If we are generating ECOFF debugging information, we need some
7471671b9obrien     additional fields for each symbol.  */
7571671b9obrien  struct efdr *ecoff_file;
7671671b9obrien  struct localsym *ecoff_symbol;
7771671b9obrien  valueT ecoff_extern_size;
7871671b9obrien#endif
7971671b9obrien};
8071671b9obrien
8171671b9obrien#define OBJ_SYMFIELD_TYPE struct elf_obj_sy
8271671b9obrien
8371671b9obrien/* Symbol fields used by the ELF back end.  */
84d0f678fdim#define ELF_TARGET_SYMBOL_FIELDS unsigned int local:1;
8571671b9obrien
8671671b9obrien/* Don't change this; change ELF_TARGET_SYMBOL_FIELDS instead.  */
8771671b9obrien#ifndef TARGET_SYMBOL_FIELDS
8871671b9obrien#define TARGET_SYMBOL_FIELDS ELF_TARGET_SYMBOL_FIELDS
8971671b9obrien#endif
9071671b9obrien
9171671b9obrien#ifndef FALSE
9271671b9obrien#define FALSE 0
9371671b9obrien#define TRUE  !FALSE
9471671b9obrien#endif
9571671b9obrien
9671671b9obrien#ifndef obj_begin
9771671b9obrien#define obj_begin() elf_begin ()
9871671b9obrien#endif
9971671b9obrienextern void elf_begin (void);
10071671b9obrien
10171671b9obrien/* should be conditional on address size! */
10271671b9obrien#define elf_symbol(asymbol) ((elf_symbol_type *) (&(asymbol)->the_bfd))
10371671b9obrien
10471671b9obrien#ifndef S_GET_SIZE
10571671b9obrien#define S_GET_SIZE(S) \
10671671b9obrien  (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size)
10771671b9obrien#endif
10871671b9obrien#ifndef S_SET_SIZE
10971671b9obrien#define S_SET_SIZE(S,V) \
11071671b9obrien  (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size = (V))
11171671b9obrien#endif
11271671b9obrien
11371671b9obrien#ifndef S_GET_ALIGN
11471671b9obrien#define S_GET_ALIGN(S) \
11571671b9obrien  (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value)
11671671b9obrien#endif
11771671b9obrien#ifndef S_SET_ALIGN
11871671b9obrien#define S_SET_ALIGN(S,V) \
11971671b9obrien  (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value = (V))
12071671b9obrien#endif
12171671b9obrien
12271671b9obrienint elf_s_get_other (symbolS *);
12371671b9obrien#ifndef S_GET_OTHER
12471671b9obrien#define S_GET_OTHER(S)	(elf_s_get_other (S))
12571671b9obrien#endif
12671671b9obrien#ifndef S_SET_OTHER
12771671b9obrien#define S_SET_OTHER(S,V) \
12871671b9obrien  (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_other = (V))
12971671b9obrien#endif
13071671b9obrien
13171671b9obrienextern asection *gdb_section;
13271671b9obrien
13371671b9obrien#ifndef obj_frob_file
13471671b9obrien#define obj_frob_file  elf_frob_file
13571671b9obrien#endif
13671671b9obrienextern void elf_frob_file (void);
13771671b9obrien
13871671b9obrien#ifndef obj_frob_file_before_adjust
13971671b9obrien#define obj_frob_file_before_adjust  elf_frob_file_before_adjust
14071671b9obrien#endif
14171671b9obrienextern void elf_frob_file_before_adjust (void);
14271671b9obrien
14371671b9obrien#ifndef obj_frob_file_after_relocs
14471671b9obrien#define obj_frob_file_after_relocs  elf_frob_file_after_relocs
14571671b9obrien#endif
14671671b9obrienextern void elf_frob_file_after_relocs (void);
14771671b9obrien
1480acbbeedim/* If the target doesn't have special processing for labels, take care of
1490acbbeedim   dwarf2 output at the object file level.  */
1500acbbeedim#ifndef tc_frob_label
1510acbbeedim#include "dwarf2dbg.h"
1520acbbeedim#define obj_frob_label  dwarf2_emit_label
1530acbbeedim#endif
1540acbbeedim
15571671b9obrien#ifndef obj_app_file
15671671b9obrien#define obj_app_file elf_file_symbol
15771671b9obrien#endif
1580acbbeedimextern void elf_file_symbol (const char *, int);
15971671b9obrien
16071671b9obrienextern void obj_elf_section_change_hook (void);
16171671b9obrien
16271671b9obrienextern void obj_elf_section (int);
16371671b9obrienextern void obj_elf_previous (int);
16471671b9obrienextern void obj_elf_version (int);
16571671b9obrienextern void obj_elf_common (int);
16671671b9obrienextern void obj_elf_data (int);
16771671b9obrienextern void obj_elf_text (int);
16871671b9obrienextern void obj_elf_change_section
16971671b9obrien  (const char *, int, int, int, const char *, int, int);
17071671b9obrienextern struct fix *obj_elf_vtable_inherit (int);
17171671b9obrienextern struct fix *obj_elf_vtable_entry (int);
17271671b9obrien
17371671b9obrien/* BFD wants to write the udata field, which is a no-no for the
17471671b9obrien   predefined section symbols in bfd/section.c.  They are read-only.  */
17571671b9obrien#ifndef obj_sec_sym_ok_for_reloc
17671671b9obrien#define obj_sec_sym_ok_for_reloc(SEC)	((SEC)->owner != 0)
17771671b9obrien#endif
17871671b9obrien
17971671b9obrienvoid elf_obj_read_begin_hook (void);
18071671b9obrien#ifndef obj_read_begin_hook
18171671b9obrien#define obj_read_begin_hook	elf_obj_read_begin_hook
18271671b9obrien#endif
18371671b9obrien
18471671b9obrienvoid elf_obj_symbol_new_hook (symbolS *);
18571671b9obrien#ifndef obj_symbol_new_hook
18671671b9obrien#define obj_symbol_new_hook	elf_obj_symbol_new_hook
18771671b9obrien#endif
18871671b9obrien
18971671b9obrienvoid elf_copy_symbol_attributes (symbolS *, symbolS *);
19071671b9obrien#ifndef OBJ_COPY_SYMBOL_ATTRIBUTES
19171671b9obrien#define OBJ_COPY_SYMBOL_ATTRIBUTES(DEST, SRC) \
19271671b9obrien  (elf_copy_symbol_attributes (DEST, SRC))
19371671b9obrien#endif
19471671b9obrien
19571671b9obrien#ifndef SEPARATE_STAB_SECTIONS
19671671b9obrien/* Avoid ifndef each separate macro setting by wrapping the whole of the
19771671b9obrien   stab group on the assumption that whoever sets SEPARATE_STAB_SECTIONS
19871671b9obrien   caters to ECOFF_DEBUGGING and the right setting of INIT_STAB_SECTIONS
19971671b9obrien   and OBJ_PROCESS_STAB too, without needing the tweaks below.  */
20071671b9obrien
20171671b9obrien/* Stabs go in a separate section.  */
20271671b9obrien#define SEPARATE_STAB_SECTIONS 1
20371671b9obrien
20471671b9obrien/* We need 12 bytes at the start of the section to hold some initial
20571671b9obrien   information.  */
20671671b9obrienextern void obj_elf_init_stab_section (segT);
20771671b9obrien#define INIT_STAB_SECTION(seg) obj_elf_init_stab_section (seg)
20871671b9obrien
20971671b9obrien#ifdef ECOFF_DEBUGGING
21071671b9obrien/* We smuggle stabs in ECOFF rather than using a separate section.
21171671b9obrien   The Irix linker can not handle a separate stabs section.  */
21271671b9obrien
21371671b9obrien#undef  SEPARATE_STAB_SECTIONS
21471671b9obrien#define SEPARATE_STAB_SECTIONS (!ECOFF_DEBUGGING)
21571671b9obrien
21671671b9obrien#undef  INIT_STAB_SECTION
21771671b9obrien#define INIT_STAB_SECTION(seg) \
21871671b9obrien  ((void) (ECOFF_DEBUGGING ? 0 : (obj_elf_init_stab_section (seg), 0)))
21971671b9obrien
22071671b9obrien#undef OBJ_PROCESS_STAB
22171671b9obrien#define OBJ_PROCESS_STAB(seg, what, string, type, other, desc)		\
22271671b9obrien  if (ECOFF_DEBUGGING)							\
22371671b9obrien    ecoff_stab ((seg), (what), (string), (type), (other), (desc))
22471671b9obrien#endif /* ECOFF_DEBUGGING */
22571671b9obrien
22671671b9obrien#endif /* SEPARATE_STAB_SECTIONS not defined.  */
22771671b9obrien
22871671b9obrienextern void elf_frob_symbol (symbolS *, int *);
22971671b9obrien#ifndef obj_frob_symbol
23071671b9obrien#define obj_frob_symbol(symp, punt) elf_frob_symbol (symp, &punt)
23171671b9obrien#endif
23271671b9obrien
23371671b9obrienextern void elf_pop_insert (void);
23471671b9obrien#ifndef obj_pop_insert
23571671b9obrien#define obj_pop_insert()	elf_pop_insert()
23671671b9obrien#endif
23771671b9obrien
23871671b9obrien#ifndef OBJ_MAYBE_ELF
239d0f678fdim/* If OBJ_MAYBE_ELF then obj-multi.h will define obj_ecoff_set_ext.  */
24071671b9obrien#define obj_ecoff_set_ext elf_ecoff_set_ext
24171671b9obrienstruct ecoff_extr;
24271671b9obrienextern void elf_ecoff_set_ext (symbolS *, struct ecoff_extr *);
24371671b9obrien#endif
2440acbbeedimextern asection *elf_com_section_ptr;
2450acbbeedimextern symbolS * elf_common_parse (int ignore ATTRIBUTE_UNUSED, symbolS *symbolP,
2460acbbeedim				   addressT size);
24771671b9obrien
24871671b9obrien#endif /* _OBJ_ELF_H */
249