Back to index

cell-binutils  2.17cvs20070401
obj-elf.h
Go to the documentation of this file.
00001 /* ELF object file format.
00002    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
00003    2002, 2003, 2004, 2006 Free Software Foundation, Inc.
00004 
00005    This file is part of GAS, the GNU Assembler.
00006 
00007    GAS is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 2, or (at your option)
00010    any later version.
00011 
00012    GAS is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with GAS; see the file COPYING.  If not, write to the Free
00019    Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
00020    02110-1301, USA.  */
00021 
00022 /* HP PA-RISC support was contributed by the Center for Software Science
00023    at the University of Utah.  */
00024 
00025 #ifndef _OBJ_ELF_H
00026 #define _OBJ_ELF_H
00027 
00028 #define OBJ_ELF 1
00029 
00030 /* Note that all macros in this file should be wrapped in #ifndef, for
00031    sake of obj-multi.h which includes this file.  */
00032 
00033 #ifndef OUTPUT_FLAVOR
00034 #define OUTPUT_FLAVOR bfd_target_elf_flavour
00035 #endif
00036 
00037 #define BYTES_IN_WORD 4            /* for now */
00038 #include "bfd/elf-bfd.h"
00039 
00040 #include "targ-cpu.h"
00041 
00042 #ifdef TC_ALPHA
00043 #define ECOFF_DEBUGGING (alpha_flag_mdebug > 0)
00044 extern int alpha_flag_mdebug;
00045 #endif
00046 
00047 /* For now, always set ECOFF_DEBUGGING for a MIPS target.  */
00048 #ifdef TC_MIPS
00049 #define ECOFF_DEBUGGING mips_flag_mdebug
00050 extern int mips_flag_mdebug;
00051 #endif /* TC_MIPS */
00052 
00053 #ifdef OBJ_MAYBE_ECOFF
00054 #ifndef ECOFF_DEBUGGING
00055 #define ECOFF_DEBUGGING 1
00056 #endif
00057 #endif
00058 
00059 /* Additional information we keep for each symbol.  */
00060 struct elf_obj_sy
00061 {
00062   /* Whether the symbol has been marked as local.  */
00063   int local;
00064 
00065   /* Use this to keep track of .size expressions that involve
00066      differences that we can't compute yet.  */
00067   expressionS *size;
00068 
00069   /* The name specified by the .symver directive.  */
00070   char *versioned_name;
00071 
00072 #ifdef ECOFF_DEBUGGING
00073   /* If we are generating ECOFF debugging information, we need some
00074      additional fields for each symbol.  */
00075   struct efdr *ecoff_file;
00076   struct localsym *ecoff_symbol;
00077   valueT ecoff_extern_size;
00078 #endif
00079 };
00080 
00081 #define OBJ_SYMFIELD_TYPE struct elf_obj_sy
00082 
00083 /* Symbol fields used by the ELF back end.  */
00084 #define ELF_TARGET_SYMBOL_FIELDS unsigned int local:1;
00085 
00086 /* Don't change this; change ELF_TARGET_SYMBOL_FIELDS instead.  */
00087 #ifndef TARGET_SYMBOL_FIELDS
00088 #define TARGET_SYMBOL_FIELDS ELF_TARGET_SYMBOL_FIELDS
00089 #endif
00090 
00091 #ifndef FALSE
00092 #define FALSE 0
00093 #define TRUE  !FALSE
00094 #endif
00095 
00096 #ifndef obj_begin
00097 #define obj_begin() elf_begin ()
00098 #endif
00099 extern void elf_begin (void);
00100 
00101 /* should be conditional on address size! */
00102 #define elf_symbol(asymbol) ((elf_symbol_type *) (&(asymbol)->the_bfd))
00103 
00104 #ifndef S_GET_SIZE
00105 #define S_GET_SIZE(S) \
00106   (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size)
00107 #endif
00108 #ifndef S_SET_SIZE
00109 #define S_SET_SIZE(S,V) \
00110   (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size = (V))
00111 #endif
00112 
00113 #ifndef S_GET_ALIGN
00114 #define S_GET_ALIGN(S) \
00115   (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value)
00116 #endif
00117 #ifndef S_SET_ALIGN
00118 #define S_SET_ALIGN(S,V) \
00119   (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value = (V))
00120 #endif
00121 
00122 int elf_s_get_other (symbolS *);
00123 #ifndef S_GET_OTHER
00124 #define S_GET_OTHER(S)      (elf_s_get_other (S))
00125 #endif
00126 #ifndef S_SET_OTHER
00127 #define S_SET_OTHER(S,V) \
00128   (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_other = (V))
00129 #endif
00130 
00131 extern asection *gdb_section;
00132 
00133 #ifndef obj_frob_file
00134 #define obj_frob_file  elf_frob_file
00135 #endif
00136 extern void elf_frob_file (void);
00137 
00138 #ifndef obj_frob_file_before_adjust
00139 #define obj_frob_file_before_adjust  elf_frob_file_before_adjust
00140 #endif
00141 extern void elf_frob_file_before_adjust (void);
00142 
00143 #ifndef obj_frob_file_after_relocs
00144 #define obj_frob_file_after_relocs  elf_frob_file_after_relocs
00145 #endif
00146 extern void elf_frob_file_after_relocs (void);
00147 
00148 /* If the target doesn't have special processing for labels, take care of
00149    dwarf2 output at the object file level.  */
00150 #ifndef tc_frob_label
00151 #include "dwarf2dbg.h"
00152 #define obj_frob_label  dwarf2_emit_label
00153 #endif
00154 
00155 #ifndef obj_app_file
00156 #define obj_app_file elf_file_symbol
00157 #endif
00158 extern void elf_file_symbol (const char *, int);
00159 
00160 extern void obj_elf_section_change_hook (void);
00161 
00162 extern void obj_elf_section (int);
00163 extern void obj_elf_previous (int);
00164 extern void obj_elf_version (int);
00165 extern void obj_elf_common (int);
00166 extern void obj_elf_data (int);
00167 extern void obj_elf_text (int);
00168 extern void obj_elf_change_section
00169   (const char *, int, int, int, const char *, int, int);
00170 extern struct fix *obj_elf_vtable_inherit (int);
00171 extern struct fix *obj_elf_vtable_entry (int);
00172 
00173 /* BFD wants to write the udata field, which is a no-no for the
00174    predefined section symbols in bfd/section.c.  They are read-only.  */
00175 #ifndef obj_sec_sym_ok_for_reloc
00176 #define obj_sec_sym_ok_for_reloc(SEC)     ((SEC)->owner != 0)
00177 #endif
00178 
00179 void elf_obj_read_begin_hook (void);
00180 #ifndef obj_read_begin_hook
00181 #define obj_read_begin_hook elf_obj_read_begin_hook
00182 #endif
00183 
00184 void elf_obj_symbol_new_hook (symbolS *);
00185 #ifndef obj_symbol_new_hook
00186 #define obj_symbol_new_hook elf_obj_symbol_new_hook
00187 #endif
00188 
00189 void elf_copy_symbol_attributes (symbolS *, symbolS *);
00190 #ifndef OBJ_COPY_SYMBOL_ATTRIBUTES
00191 #define OBJ_COPY_SYMBOL_ATTRIBUTES(DEST, SRC) \
00192   (elf_copy_symbol_attributes (DEST, SRC))
00193 #endif
00194 
00195 #ifndef SEPARATE_STAB_SECTIONS
00196 /* Avoid ifndef each separate macro setting by wrapping the whole of the
00197    stab group on the assumption that whoever sets SEPARATE_STAB_SECTIONS
00198    caters to ECOFF_DEBUGGING and the right setting of INIT_STAB_SECTIONS
00199    and OBJ_PROCESS_STAB too, without needing the tweaks below.  */
00200 
00201 /* Stabs go in a separate section.  */
00202 #define SEPARATE_STAB_SECTIONS 1
00203 
00204 /* We need 12 bytes at the start of the section to hold some initial
00205    information.  */
00206 extern void obj_elf_init_stab_section (segT);
00207 #define INIT_STAB_SECTION(seg) obj_elf_init_stab_section (seg)
00208 
00209 #ifdef ECOFF_DEBUGGING
00210 /* We smuggle stabs in ECOFF rather than using a separate section.
00211    The Irix linker can not handle a separate stabs section.  */
00212 
00213 #undef  SEPARATE_STAB_SECTIONS
00214 #define SEPARATE_STAB_SECTIONS (!ECOFF_DEBUGGING)
00215 
00216 #undef  INIT_STAB_SECTION
00217 #define INIT_STAB_SECTION(seg) \
00218   ((void) (ECOFF_DEBUGGING ? 0 : (obj_elf_init_stab_section (seg), 0)))
00219 
00220 #undef OBJ_PROCESS_STAB
00221 #define OBJ_PROCESS_STAB(seg, what, string, type, other, desc)        \
00222   if (ECOFF_DEBUGGING)                                                \
00223     ecoff_stab ((seg), (what), (string), (type), (other), (desc))
00224 #endif /* ECOFF_DEBUGGING */
00225 
00226 #endif /* SEPARATE_STAB_SECTIONS not defined.  */
00227 
00228 extern void elf_frob_symbol (symbolS *, int *);
00229 #ifndef obj_frob_symbol
00230 #define obj_frob_symbol(symp, punt) elf_frob_symbol (symp, &punt)
00231 #endif
00232 
00233 extern void elf_pop_insert (void);
00234 #ifndef obj_pop_insert
00235 #define obj_pop_insert()    elf_pop_insert()
00236 #endif
00237 
00238 #ifndef OBJ_MAYBE_ELF
00239 #define obj_ecoff_set_ext elf_ecoff_set_ext
00240 struct ecoff_extr;
00241 extern void elf_ecoff_set_ext (symbolS *, struct ecoff_extr *);
00242 #endif
00243 extern asection *elf_com_section_ptr;
00244 extern symbolS * elf_common_parse (int ignore ATTRIBUTE_UNUSED, symbolS *symbolP,
00245                                addressT size);
00246 
00247 #endif /* _OBJ_ELF_H */