* symbols.c (copy_symbol_attributes): Convert local symbols to
[binutils.git] / gas / config / obj-elf.h
blob4380f1f7b9d77d7dfe0829a7228f33d586f735fb
1 /* ELF object file format.
2 Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999
3 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 1, or (at your option)
10 any later version.
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
23 /* HP PA-RISC support was contributed by the Center for Software Science
24 at the University of Utah. */
26 #ifndef _OBJ_ELF_H
27 #define _OBJ_ELF_H
29 #define OBJ_ELF 1
31 #define OUTPUT_FLAVOR bfd_target_elf_flavour
33 #include <bfd.h>
35 #define BYTES_IN_WORD 4 /* for now */
36 #include "bfd/elf-bfd.h"
38 #include "targ-cpu.h"
40 #ifdef TC_ALPHA
41 #define ECOFF_DEBUGGING alpha_flag_mdebug
42 extern int alpha_flag_mdebug;
43 #endif
45 /* For now, always set ECOFF_DEBUGGING for a MIPS target. */
46 #ifdef TC_MIPS
47 #ifdef MIPS_STABS_ELF
48 #define ECOFF_DEBUGGING 0
49 #else
50 #define ECOFF_DEBUGGING 1
51 #endif /* MIPS_STABS_ELF */
52 #endif /* TC_MIPS */
54 /* Additional information we keep for each symbol. */
56 /* FIXME: For some reason, this structure is needed both here and in
57 obj-multi.h. */
58 #ifndef OBJ_SYMFIELD_TYPE
59 struct elf_obj_sy
61 /* Whether the symbol has been marked as local. */
62 int local;
64 /* Use this to keep track of .size expressions that involve
65 differences that we can't compute yet. */
66 expressionS *size;
68 /* The name specified by the .symver directive. */
69 char *versioned_name;
71 #ifdef ECOFF_DEBUGGING
72 /* If we are generating ECOFF debugging information, we need some
73 additional fields for each symbol. */
74 struct efdr *ecoff_file;
75 struct localsym *ecoff_symbol;
76 valueT ecoff_extern_size;
77 #endif
79 #endif
81 #define OBJ_SYMFIELD_TYPE struct elf_obj_sy
83 #ifndef FALSE
84 #define FALSE 0
85 #define TRUE !FALSE
86 #endif
88 #define obj_begin() elf_begin ()
89 extern void elf_begin PARAMS ((void));
91 /* should be conditional on address size! */
92 #define elf_symbol(asymbol) ((elf_symbol_type *)(&(asymbol)->the_bfd))
94 #define S_GET_SIZE(S) \
95 (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size)
96 #define S_SET_SIZE(S,V) \
97 (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size = (V))
99 #define S_GET_ALIGN(S) \
100 (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value)
101 #define S_SET_ALIGN(S,V) \
102 (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value = (V))
104 #define S_GET_OTHER(S) \
105 (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_other)
106 #define S_SET_OTHER(S,V) \
107 (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_other = (V))
109 extern asection *gdb_section;
111 #define obj_frob_file elf_frob_file
112 extern void elf_frob_file PARAMS ((void));
114 #define obj_frob_file_after_relocs elf_frob_file_after_relocs
115 extern void elf_frob_file_after_relocs PARAMS ((void));
117 #define obj_app_file elf_file_symbol
118 extern void elf_file_symbol PARAMS ((char *));
120 extern void obj_elf_section_change_hook PARAMS ((void));
122 extern void obj_elf_section PARAMS ((int));
123 extern void obj_elf_previous PARAMS ((int));
124 extern void obj_elf_version PARAMS ((int));
126 /* BFD wants to write the udata field, which is a no-no for the
127 globally defined sections. */
128 #define obj_sec_sym_ok_for_reloc(SEC) ((SEC)->owner != 0)
130 /* When setting one symbol equal to another, by default we probably
131 want them to have the same "size", whatever it means in the current
132 context. */
133 #define OBJ_COPY_SYMBOL_ATTRIBUTES(DEST,SRC) \
134 do \
136 struct elf_obj_sy *srcelf = symbol_get_obj (SRC); \
137 struct elf_obj_sy *destelf = symbol_get_obj (DEST); \
138 if (srcelf->size) \
140 if (destelf->size == NULL) \
141 destelf->size = \
142 (expressionS *) xmalloc (sizeof (expressionS)); \
143 *destelf->size = *srcelf->size; \
145 else \
147 if (destelf->size != NULL) \
148 free (destelf->size); \
149 destelf->size = NULL; \
151 S_SET_SIZE ((DEST), S_GET_SIZE (SRC)); \
152 S_SET_OTHER ((DEST), S_GET_OTHER (SRC)); \
154 while (0)
156 /* Stabs go in a separate section. */
157 #define SEPARATE_STAB_SECTIONS 1
159 /* We need 12 bytes at the start of the section to hold some initial
160 information. */
161 extern void obj_elf_init_stab_section PARAMS ((segT));
162 #define INIT_STAB_SECTION(seg) obj_elf_init_stab_section (seg)
164 #ifdef ECOFF_DEBUGGING
165 /* We smuggle stabs in ECOFF rather than using a separate section.
166 The Irix linker can not handle a separate stabs section. */
168 #undef SEPARATE_STAB_SECTIONS
169 #define SEPARATE_STAB_SECTIONS (!ECOFF_DEBUGGING)
171 #undef INIT_STAB_SECTION
172 #define INIT_STAB_SECTION(seg) \
173 ((void)(ECOFF_DEBUGGING ? 0 : (obj_elf_init_stab_section (seg), 0)))
175 #define OBJ_PROCESS_STAB(seg, what, string, type, other, desc) \
176 if (ECOFF_DEBUGGING) \
177 ecoff_stab ((seg), (what), (string), (type), (other), (desc))
178 #endif /* ECOFF_DEBUGGING */
180 extern void elf_frob_symbol PARAMS ((symbolS *, int *));
181 #ifndef obj_frob_symbol
182 #define obj_frob_symbol(symp, punt) elf_frob_symbol (symp, &punt)
183 #endif
185 extern void elf_pop_insert PARAMS ((void));
186 #define obj_pop_insert() elf_pop_insert()
188 #ifndef OBJ_MAYBE_ELF
189 #define obj_ecoff_set_ext elf_ecoff_set_ext
190 #ifdef ANSI_PROTOTYPES
191 struct ecoff_extr;
192 #endif
193 extern void elf_ecoff_set_ext PARAMS ((symbolS *, struct ecoff_extr *));
194 #endif
196 #endif /* _OBJ_ELF_H */