Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* ELF object file format. |
4c63da97 | 2 | Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000 |
49309057 | 3 | Free Software Foundation, Inc. |
252b5132 RH |
4 | |
5 | This file is part of GAS, the GNU Assembler. | |
6 | ||
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. | |
11 | ||
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. | |
16 | ||
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. */ | |
21 | ||
22 | ||
23 | /* HP PA-RISC support was contributed by the Center for Software Science | |
24 | at the University of Utah. */ | |
25 | ||
26 | #ifndef _OBJ_ELF_H | |
27 | #define _OBJ_ELF_H | |
28 | ||
29 | #define OBJ_ELF 1 | |
30 | ||
4ca72d38 | 31 | #ifndef OUTPUT_FLAVOR |
252b5132 | 32 | #define OUTPUT_FLAVOR bfd_target_elf_flavour |
4ca72d38 | 33 | #endif |
252b5132 | 34 | |
3f9b03b5 | 35 | #include "bfd.h" |
252b5132 RH |
36 | |
37 | #define BYTES_IN_WORD 4 /* for now */ | |
38 | #include "bfd/elf-bfd.h" | |
39 | ||
49309057 ILT |
40 | #include "targ-cpu.h" |
41 | ||
42 | #ifdef TC_ALPHA | |
43 | #define ECOFF_DEBUGGING alpha_flag_mdebug | |
44 | extern int alpha_flag_mdebug; | |
45 | #endif | |
46 | ||
47 | /* For now, always set ECOFF_DEBUGGING for a MIPS target. */ | |
48 | #ifdef TC_MIPS | |
49 | #ifdef MIPS_STABS_ELF | |
50 | #define ECOFF_DEBUGGING 0 | |
51 | #else | |
52 | #define ECOFF_DEBUGGING 1 | |
53 | #endif /* MIPS_STABS_ELF */ | |
54 | #endif /* TC_MIPS */ | |
55 | ||
4c63da97 AM |
56 | #ifdef OBJ_MAYBE_ECOFF |
57 | #ifndef ECOFF_DEBUGGING | |
58 | #define ECOFF_DEBUGGING 1 | |
59 | #endif | |
60 | #endif | |
61 | ||
252b5132 | 62 | /* Additional information we keep for each symbol. */ |
252b5132 RH |
63 | struct elf_obj_sy |
64 | { | |
49309057 ILT |
65 | /* Whether the symbol has been marked as local. */ |
66 | int local; | |
67 | ||
252b5132 RH |
68 | /* Use this to keep track of .size expressions that involve |
69 | differences that we can't compute yet. */ | |
70 | expressionS *size; | |
71 | ||
72 | /* The name specified by the .symver directive. */ | |
73 | char *versioned_name; | |
49309057 ILT |
74 | |
75 | #ifdef ECOFF_DEBUGGING | |
76 | /* If we are generating ECOFF debugging information, we need some | |
77 | additional fields for each symbol. */ | |
78 | struct efdr *ecoff_file; | |
79 | struct localsym *ecoff_symbol; | |
80 | valueT ecoff_extern_size; | |
81 | #endif | |
252b5132 | 82 | }; |
252b5132 RH |
83 | |
84 | #define OBJ_SYMFIELD_TYPE struct elf_obj_sy | |
85 | ||
252b5132 RH |
86 | #ifndef FALSE |
87 | #define FALSE 0 | |
88 | #define TRUE !FALSE | |
89 | #endif | |
90 | ||
91 | #define obj_begin() elf_begin () | |
92 | extern void elf_begin PARAMS ((void)); | |
93 | ||
94 | /* should be conditional on address size! */ | |
95 | #define elf_symbol(asymbol) ((elf_symbol_type *)(&(asymbol)->the_bfd)) | |
96 | ||
4ca72d38 | 97 | #ifndef S_GET_SIZE |
49309057 ILT |
98 | #define S_GET_SIZE(S) \ |
99 | (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size) | |
4ca72d38 AM |
100 | #endif |
101 | #ifndef S_SET_SIZE | |
252b5132 | 102 | #define S_SET_SIZE(S,V) \ |
49309057 | 103 | (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_size = (V)) |
4ca72d38 | 104 | #endif |
252b5132 | 105 | |
4ca72d38 | 106 | #ifndef S_GET_ALIGN |
49309057 ILT |
107 | #define S_GET_ALIGN(S) \ |
108 | (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value) | |
4ca72d38 AM |
109 | #endif |
110 | #ifndef S_SET_ALIGN | |
252b5132 | 111 | #define S_SET_ALIGN(S,V) \ |
49309057 | 112 | (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_value = (V)) |
4ca72d38 | 113 | #endif |
252b5132 | 114 | |
4c63da97 AM |
115 | int elf_s_get_other PARAMS ((symbolS *)); |
116 | #ifndef S_GET_OTHER | |
117 | #define S_GET_OTHER(S) (elf_s_get_other (S)) | |
118 | #endif | |
119 | #ifndef S_SET_OTHER | |
252b5132 | 120 | #define S_SET_OTHER(S,V) \ |
49309057 | 121 | (elf_symbol (symbol_get_bfdsym (S))->internal_elf_sym.st_other = (V)) |
4c63da97 | 122 | #endif |
252b5132 RH |
123 | |
124 | extern asection *gdb_section; | |
125 | ||
4ca72d38 | 126 | #ifndef obj_frob_file |
252b5132 | 127 | #define obj_frob_file elf_frob_file |
4ca72d38 | 128 | #endif |
252b5132 RH |
129 | extern void elf_frob_file PARAMS ((void)); |
130 | ||
4ca72d38 | 131 | #ifndef obj_frob_file_after_relocs |
252b5132 | 132 | #define obj_frob_file_after_relocs elf_frob_file_after_relocs |
4ca72d38 | 133 | #endif |
252b5132 RH |
134 | extern void elf_frob_file_after_relocs PARAMS ((void)); |
135 | ||
136 | #define obj_app_file elf_file_symbol | |
137 | extern void elf_file_symbol PARAMS ((char *)); | |
138 | ||
139 | extern void obj_elf_section_change_hook PARAMS ((void)); | |
140 | ||
141 | extern void obj_elf_section PARAMS ((int)); | |
142 | extern void obj_elf_previous PARAMS ((int)); | |
143 | extern void obj_elf_version PARAMS ((int)); | |
40b10cc7 NC |
144 | extern void obj_elf_common PARAMS ((int)); |
145 | extern void obj_elf_data PARAMS ((int)); | |
146 | extern void obj_elf_text PARAMS ((int)); | |
252b5132 RH |
147 | |
148 | /* BFD wants to write the udata field, which is a no-no for the | |
149 | globally defined sections. */ | |
4ca72d38 | 150 | #ifndef obj_sec_sym_ok_for_reloc |
252b5132 | 151 | #define obj_sec_sym_ok_for_reloc(SEC) ((SEC)->owner != 0) |
4ca72d38 | 152 | #endif |
252b5132 | 153 | |
4c63da97 AM |
154 | void elf_obj_read_begin_hook PARAMS ((void)); |
155 | #ifndef obj_read_begin_hook | |
156 | #define obj_read_begin_hook elf_obj_read_begin_hook | |
157 | #endif | |
158 | ||
159 | void elf_obj_symbol_new_hook PARAMS ((symbolS *)); | |
160 | #ifndef obj_symbol_new_hook | |
161 | #define obj_symbol_new_hook elf_obj_symbol_new_hook | |
162 | #endif | |
163 | ||
252b5132 RH |
164 | /* When setting one symbol equal to another, by default we probably |
165 | want them to have the same "size", whatever it means in the current | |
166 | context. */ | |
4ca72d38 | 167 | #ifndef OBJ_COPY_SYMBOL_ATTRIBUTES |
252b5132 RH |
168 | #define OBJ_COPY_SYMBOL_ATTRIBUTES(DEST,SRC) \ |
169 | do \ | |
170 | { \ | |
49309057 ILT |
171 | struct elf_obj_sy *srcelf = symbol_get_obj (SRC); \ |
172 | struct elf_obj_sy *destelf = symbol_get_obj (DEST); \ | |
173 | if (srcelf->size) \ | |
252b5132 | 174 | { \ |
49309057 ILT |
175 | if (destelf->size == NULL) \ |
176 | destelf->size = \ | |
252b5132 | 177 | (expressionS *) xmalloc (sizeof (expressionS)); \ |
49309057 | 178 | *destelf->size = *srcelf->size; \ |
252b5132 RH |
179 | } \ |
180 | else \ | |
181 | { \ | |
49309057 ILT |
182 | if (destelf->size != NULL) \ |
183 | free (destelf->size); \ | |
184 | destelf->size = NULL; \ | |
252b5132 RH |
185 | } \ |
186 | S_SET_SIZE ((DEST), S_GET_SIZE (SRC)); \ | |
187 | S_SET_OTHER ((DEST), S_GET_OTHER (SRC)); \ | |
188 | } \ | |
189 | while (0) | |
4ca72d38 | 190 | #endif |
252b5132 RH |
191 | |
192 | /* Stabs go in a separate section. */ | |
193 | #define SEPARATE_STAB_SECTIONS 1 | |
194 | ||
195 | /* We need 12 bytes at the start of the section to hold some initial | |
196 | information. */ | |
197 | extern void obj_elf_init_stab_section PARAMS ((segT)); | |
198 | #define INIT_STAB_SECTION(seg) obj_elf_init_stab_section (seg) | |
199 | ||
252b5132 | 200 | #ifdef ECOFF_DEBUGGING |
252b5132 RH |
201 | /* We smuggle stabs in ECOFF rather than using a separate section. |
202 | The Irix linker can not handle a separate stabs section. */ | |
203 | ||
204 | #undef SEPARATE_STAB_SECTIONS | |
205 | #define SEPARATE_STAB_SECTIONS (!ECOFF_DEBUGGING) | |
206 | ||
207 | #undef INIT_STAB_SECTION | |
208 | #define INIT_STAB_SECTION(seg) \ | |
209 | ((void)(ECOFF_DEBUGGING ? 0 : (obj_elf_init_stab_section (seg), 0))) | |
210 | ||
4ca72d38 | 211 | #undef OBJ_PROCESS_STAB |
252b5132 RH |
212 | #define OBJ_PROCESS_STAB(seg, what, string, type, other, desc) \ |
213 | if (ECOFF_DEBUGGING) \ | |
214 | ecoff_stab ((seg), (what), (string), (type), (other), (desc)) | |
215 | #endif /* ECOFF_DEBUGGING */ | |
216 | ||
49309057 | 217 | extern void elf_frob_symbol PARAMS ((symbolS *, int *)); |
252b5132 RH |
218 | #ifndef obj_frob_symbol |
219 | #define obj_frob_symbol(symp, punt) elf_frob_symbol (symp, &punt) | |
220 | #endif | |
221 | ||
222 | extern void elf_pop_insert PARAMS ((void)); | |
4ca72d38 | 223 | #ifndef obj_pop_insert |
252b5132 | 224 | #define obj_pop_insert() elf_pop_insert() |
4ca72d38 | 225 | #endif |
252b5132 RH |
226 | |
227 | #ifndef OBJ_MAYBE_ELF | |
228 | #define obj_ecoff_set_ext elf_ecoff_set_ext | |
229 | #ifdef ANSI_PROTOTYPES | |
230 | struct ecoff_extr; | |
231 | #endif | |
49309057 | 232 | extern void elf_ecoff_set_ext PARAMS ((symbolS *, struct ecoff_extr *)); |
252b5132 RH |
233 | #endif |
234 | ||
235 | #endif /* _OBJ_ELF_H */ |