Commit | Line | Data |
---|---|---|
800eeca4 | 1 | /* IA-64 support for 64-bit ELF |
e5094212 | 2 | Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
800eeca4 JW |
3 | Contributed by David Mosberger-Tang <davidm@hpl.hp.com> |
4 | ||
5 | This file is part of BFD, the Binary File Descriptor library. | |
6 | ||
7 | This program 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 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program 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 this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
20 | ||
21 | #include "bfd.h" | |
22 | #include "sysdep.h" | |
23 | #include "libbfd.h" | |
24 | #include "elf-bfd.h" | |
25 | #include "opcode/ia64.h" | |
26 | #include "elf/ia64.h" | |
27 | ||
28 | /* | |
29 | * THE RULES for all the stuff the linker creates -- | |
30 | * | |
31 | * GOT Entries created in response to LTOFF or LTOFF_FPTR | |
32 | * relocations. Dynamic relocs created for dynamic | |
33 | * symbols in an application; REL relocs for locals | |
34 | * in a shared library. | |
35 | * | |
36 | * FPTR The canonical function descriptor. Created for local | |
37 | * symbols in applications. Descriptors for dynamic symbols | |
38 | * and local symbols in shared libraries are created by | |
39 | * ld.so. Thus there are no dynamic relocs against these | |
40 | * objects. The FPTR relocs for such _are_ passed through | |
41 | * to the dynamic relocation tables. | |
42 | * | |
43 | * FULL_PLT Created for a PCREL21B relocation against a dynamic symbol. | |
44 | * Requires the creation of a PLTOFF entry. This does not | |
45 | * require any dynamic relocations. | |
46 | * | |
47 | * PLTOFF Created by PLTOFF relocations. For local symbols, this | |
48 | * is an alternate function descriptor, and in shared libraries | |
49 | * requires two REL relocations. Note that this cannot be | |
50 | * transformed into an FPTR relocation, since it must be in | |
51 | * range of the GP. For dynamic symbols, this is a function | |
52 | * descriptor for a MIN_PLT entry, and requires one IPLT reloc. | |
53 | * | |
54 | * MIN_PLT Created by PLTOFF entries against dynamic symbols. This | |
55 | * does not reqire dynamic relocations. | |
56 | */ | |
57 | ||
58 | #define USE_RELA /* we want RELA relocs, not REL */ | |
59 | ||
60 | #define NELEMS(a) ((int) (sizeof (a) / sizeof ((a)[0]))) | |
61 | ||
62 | typedef struct bfd_hash_entry *(*new_hash_entry_func) | |
63 | PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); | |
64 | ||
65 | /* In dynamically (linker-) created sections, we generally need to keep track | |
66 | of the place a symbol or expression got allocated to. This is done via hash | |
67 | tables that store entries of the following type. */ | |
68 | ||
bbe66d08 | 69 | struct elfNN_ia64_dyn_sym_info |
800eeca4 JW |
70 | { |
71 | /* The addend for which this entry is relevant. */ | |
72 | bfd_vma addend; | |
73 | ||
74 | /* Next addend in the list. */ | |
bbe66d08 | 75 | struct elfNN_ia64_dyn_sym_info *next; |
800eeca4 JW |
76 | |
77 | bfd_vma got_offset; | |
78 | bfd_vma fptr_offset; | |
79 | bfd_vma pltoff_offset; | |
80 | bfd_vma plt_offset; | |
81 | bfd_vma plt2_offset; | |
82 | ||
83 | /* The symbol table entry, if any, that this was derrived from. */ | |
84 | struct elf_link_hash_entry *h; | |
3e932841 | 85 | |
800eeca4 JW |
86 | /* Used to count non-got, non-plt relocations for delayed sizing |
87 | of relocation sections. */ | |
bbe66d08 | 88 | struct elfNN_ia64_dyn_reloc_entry |
800eeca4 | 89 | { |
bbe66d08 | 90 | struct elfNN_ia64_dyn_reloc_entry *next; |
800eeca4 JW |
91 | asection *srel; |
92 | int type; | |
93 | int count; | |
94 | } *reloc_entries; | |
95 | ||
96 | /* True when the section contents have been updated. */ | |
97 | unsigned got_done : 1; | |
98 | unsigned fptr_done : 1; | |
99 | unsigned pltoff_done : 1; | |
100 | ||
101 | /* True for the different kinds of linker data we want created. */ | |
102 | unsigned want_got : 1; | |
103 | unsigned want_fptr : 1; | |
104 | unsigned want_ltoff_fptr : 1; | |
105 | unsigned want_plt : 1; | |
106 | unsigned want_plt2 : 1; | |
107 | unsigned want_pltoff : 1; | |
108 | }; | |
109 | ||
bbe66d08 | 110 | struct elfNN_ia64_local_hash_entry |
800eeca4 JW |
111 | { |
112 | struct bfd_hash_entry root; | |
bbe66d08 | 113 | struct elfNN_ia64_dyn_sym_info *info; |
f7460f5f JJ |
114 | |
115 | /* True if this hash entry's addends was translated for | |
116 | SHF_MERGE optimization. */ | |
117 | unsigned sec_merge_done : 1; | |
800eeca4 JW |
118 | }; |
119 | ||
bbe66d08 | 120 | struct elfNN_ia64_local_hash_table |
800eeca4 JW |
121 | { |
122 | struct bfd_hash_table root; | |
123 | /* No additional fields for now. */ | |
124 | }; | |
125 | ||
bbe66d08 | 126 | struct elfNN_ia64_link_hash_entry |
800eeca4 JW |
127 | { |
128 | struct elf_link_hash_entry root; | |
bbe66d08 | 129 | struct elfNN_ia64_dyn_sym_info *info; |
800eeca4 JW |
130 | }; |
131 | ||
bbe66d08 | 132 | struct elfNN_ia64_link_hash_table |
800eeca4 JW |
133 | { |
134 | /* The main hash table */ | |
135 | struct elf_link_hash_table root; | |
136 | ||
137 | asection *got_sec; /* the linkage table section (or NULL) */ | |
138 | asection *rel_got_sec; /* dynamic relocation section for same */ | |
139 | asection *fptr_sec; /* function descriptor table (or NULL) */ | |
140 | asection *plt_sec; /* the primary plt section (or NULL) */ | |
141 | asection *pltoff_sec; /* private descriptors for plt (or NULL) */ | |
142 | asection *rel_pltoff_sec; /* dynamic relocation section for same */ | |
143 | ||
144 | bfd_size_type minplt_entries; /* number of minplt entries */ | |
db6751f2 | 145 | unsigned reltext : 1; /* are there relocs against readonly sections? */ |
800eeca4 | 146 | |
bbe66d08 | 147 | struct elfNN_ia64_local_hash_table loc_hash_table; |
800eeca4 JW |
148 | }; |
149 | ||
bbe66d08 JW |
150 | #define elfNN_ia64_hash_table(p) \ |
151 | ((struct elfNN_ia64_link_hash_table *) ((p)->hash)) | |
800eeca4 | 152 | |
bbe66d08 | 153 | static bfd_reloc_status_type elfNN_ia64_reloc |
800eeca4 JW |
154 | PARAMS ((bfd *abfd, arelent *reloc, asymbol *sym, PTR data, |
155 | asection *input_section, bfd *output_bfd, char **error_message)); | |
156 | static reloc_howto_type * lookup_howto | |
157 | PARAMS ((unsigned int rtype)); | |
bbe66d08 | 158 | static reloc_howto_type *elfNN_ia64_reloc_type_lookup |
800eeca4 | 159 | PARAMS ((bfd *abfd, bfd_reloc_code_real_type bfd_code)); |
bbe66d08 JW |
160 | static void elfNN_ia64_info_to_howto |
161 | PARAMS ((bfd *abfd, arelent *bfd_reloc, ElfNN_Internal_Rela *elf_reloc)); | |
162 | static boolean elfNN_ia64_relax_section | |
748abff6 RH |
163 | PARAMS((bfd *abfd, asection *sec, struct bfd_link_info *link_info, |
164 | boolean *again)); | |
81545d45 | 165 | static boolean is_unwind_section_name |
d9cf1b54 | 166 | PARAMS ((bfd *abfd, const char *)); |
bbe66d08 JW |
167 | static boolean elfNN_ia64_section_from_shdr |
168 | PARAMS ((bfd *, ElfNN_Internal_Shdr *, char *)); | |
cea4409c AM |
169 | static boolean elfNN_ia64_section_flags |
170 | PARAMS ((flagword *, ElfNN_Internal_Shdr *)); | |
bbe66d08 JW |
171 | static boolean elfNN_ia64_fake_sections |
172 | PARAMS ((bfd *abfd, ElfNN_Internal_Shdr *hdr, asection *sec)); | |
81545d45 RH |
173 | static void elfNN_ia64_final_write_processing |
174 | PARAMS ((bfd *abfd, boolean linker)); | |
bbe66d08 | 175 | static boolean elfNN_ia64_add_symbol_hook |
800eeca4 JW |
176 | PARAMS ((bfd *abfd, struct bfd_link_info *info, const Elf_Internal_Sym *sym, |
177 | const char **namep, flagword *flagsp, asection **secp, | |
178 | bfd_vma *valp)); | |
dc810e39 | 179 | static boolean elfNN_ia64_aix_vec |
7b6dab7f TW |
180 | PARAMS ((const bfd_target *vec)); |
181 | static boolean elfNN_ia64_aix_add_symbol_hook | |
182 | PARAMS ((bfd *abfd, struct bfd_link_info *info, const Elf_Internal_Sym *sym, | |
183 | const char **namep, flagword *flagsp, asection **secp, | |
184 | bfd_vma *valp)); | |
185 | static boolean elfNN_ia64_aix_link_add_symbols | |
186 | PARAMS ((bfd *abfd, struct bfd_link_info *info)); | |
bbe66d08 | 187 | static int elfNN_ia64_additional_program_headers |
800eeca4 | 188 | PARAMS ((bfd *abfd)); |
cea4409c AM |
189 | static boolean elfNN_ia64_modify_segment_map |
190 | PARAMS ((bfd *)); | |
bbe66d08 | 191 | static boolean elfNN_ia64_is_local_label_name |
800eeca4 | 192 | PARAMS ((bfd *abfd, const char *name)); |
bbe66d08 | 193 | static boolean elfNN_ia64_dynamic_symbol_p |
800eeca4 | 194 | PARAMS ((struct elf_link_hash_entry *h, struct bfd_link_info *info)); |
bbe66d08 JW |
195 | static boolean elfNN_ia64_local_hash_table_init |
196 | PARAMS ((struct elfNN_ia64_local_hash_table *ht, bfd *abfd, | |
800eeca4 | 197 | new_hash_entry_func new)); |
bbe66d08 | 198 | static struct bfd_hash_entry *elfNN_ia64_new_loc_hash_entry |
800eeca4 JW |
199 | PARAMS ((struct bfd_hash_entry *entry, struct bfd_hash_table *table, |
200 | const char *string)); | |
bbe66d08 | 201 | static struct bfd_hash_entry *elfNN_ia64_new_elf_hash_entry |
800eeca4 JW |
202 | PARAMS ((struct bfd_hash_entry *entry, struct bfd_hash_table *table, |
203 | const char *string)); | |
cea4409c AM |
204 | static void elfNN_ia64_hash_copy_indirect |
205 | PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *)); | |
206 | static void elfNN_ia64_hash_hide_symbol | |
e5094212 | 207 | PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean)); |
bbe66d08 | 208 | static struct bfd_link_hash_table *elfNN_ia64_hash_table_create |
800eeca4 | 209 | PARAMS ((bfd *abfd)); |
bbe66d08 JW |
210 | static struct elfNN_ia64_local_hash_entry *elfNN_ia64_local_hash_lookup |
211 | PARAMS ((struct elfNN_ia64_local_hash_table *table, const char *string, | |
800eeca4 | 212 | boolean create, boolean copy)); |
cea4409c AM |
213 | static boolean elfNN_ia64_global_dyn_sym_thunk |
214 | PARAMS ((struct bfd_hash_entry *, PTR)); | |
215 | static boolean elfNN_ia64_local_dyn_sym_thunk | |
216 | PARAMS ((struct bfd_hash_entry *, PTR)); | |
bbe66d08 JW |
217 | static void elfNN_ia64_dyn_sym_traverse |
218 | PARAMS ((struct elfNN_ia64_link_hash_table *ia64_info, | |
3e932841 | 219 | boolean (*func) (struct elfNN_ia64_dyn_sym_info *, PTR), |
800eeca4 | 220 | PTR info)); |
bbe66d08 | 221 | static boolean elfNN_ia64_create_dynamic_sections |
800eeca4 | 222 | PARAMS ((bfd *abfd, struct bfd_link_info *info)); |
f7460f5f JJ |
223 | static struct elfNN_ia64_local_hash_entry * get_local_sym_hash |
224 | PARAMS ((struct elfNN_ia64_link_hash_table *ia64_info, | |
225 | bfd *abfd, const Elf_Internal_Rela *rel, boolean create)); | |
bbe66d08 JW |
226 | static struct elfNN_ia64_dyn_sym_info * get_dyn_sym_info |
227 | PARAMS ((struct elfNN_ia64_link_hash_table *ia64_info, | |
800eeca4 JW |
228 | struct elf_link_hash_entry *h, |
229 | bfd *abfd, const Elf_Internal_Rela *rel, boolean create)); | |
230 | static asection *get_got | |
231 | PARAMS ((bfd *abfd, struct bfd_link_info *info, | |
bbe66d08 | 232 | struct elfNN_ia64_link_hash_table *ia64_info)); |
800eeca4 JW |
233 | static asection *get_fptr |
234 | PARAMS ((bfd *abfd, struct bfd_link_info *info, | |
bbe66d08 | 235 | struct elfNN_ia64_link_hash_table *ia64_info)); |
800eeca4 JW |
236 | static asection *get_pltoff |
237 | PARAMS ((bfd *abfd, struct bfd_link_info *info, | |
bbe66d08 | 238 | struct elfNN_ia64_link_hash_table *ia64_info)); |
800eeca4 | 239 | static asection *get_reloc_section |
bbe66d08 | 240 | PARAMS ((bfd *abfd, struct elfNN_ia64_link_hash_table *ia64_info, |
800eeca4 JW |
241 | asection *sec, boolean create)); |
242 | static boolean count_dyn_reloc | |
bbe66d08 | 243 | PARAMS ((bfd *abfd, struct elfNN_ia64_dyn_sym_info *dyn_i, |
800eeca4 | 244 | asection *srel, int type)); |
bbe66d08 | 245 | static boolean elfNN_ia64_check_relocs |
800eeca4 JW |
246 | PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *sec, |
247 | const Elf_Internal_Rela *relocs)); | |
bbe66d08 | 248 | static boolean elfNN_ia64_adjust_dynamic_symbol |
800eeca4 | 249 | PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h)); |
dc810e39 | 250 | static long global_sym_index |
800eeca4 JW |
251 | PARAMS ((struct elf_link_hash_entry *h)); |
252 | static boolean allocate_fptr | |
bbe66d08 | 253 | PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)); |
800eeca4 | 254 | static boolean allocate_global_data_got |
bbe66d08 | 255 | PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)); |
800eeca4 | 256 | static boolean allocate_global_fptr_got |
bbe66d08 | 257 | PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)); |
800eeca4 | 258 | static boolean allocate_local_got |
bbe66d08 | 259 | PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)); |
800eeca4 | 260 | static boolean allocate_pltoff_entries |
bbe66d08 | 261 | PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)); |
800eeca4 | 262 | static boolean allocate_plt_entries |
bbe66d08 | 263 | PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)); |
800eeca4 | 264 | static boolean allocate_plt2_entries |
bbe66d08 | 265 | PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)); |
800eeca4 | 266 | static boolean allocate_dynrel_entries |
bbe66d08 JW |
267 | PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)); |
268 | static boolean elfNN_ia64_size_dynamic_sections | |
800eeca4 | 269 | PARAMS ((bfd *output_bfd, struct bfd_link_info *info)); |
bbe66d08 | 270 | static bfd_reloc_status_type elfNN_ia64_install_value |
800eeca4 | 271 | PARAMS ((bfd *abfd, bfd_byte *hit_addr, bfd_vma val, unsigned int r_type)); |
bbe66d08 | 272 | static void elfNN_ia64_install_dyn_reloc |
800eeca4 JW |
273 | PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *sec, |
274 | asection *srel, bfd_vma offset, unsigned int type, | |
275 | long dynindx, bfd_vma addend)); | |
276 | static bfd_vma set_got_entry | |
277 | PARAMS ((bfd *abfd, struct bfd_link_info *info, | |
bbe66d08 | 278 | struct elfNN_ia64_dyn_sym_info *dyn_i, long dynindx, |
800eeca4 JW |
279 | bfd_vma addend, bfd_vma value, unsigned int dyn_r_type)); |
280 | static bfd_vma set_fptr_entry | |
281 | PARAMS ((bfd *abfd, struct bfd_link_info *info, | |
bbe66d08 | 282 | struct elfNN_ia64_dyn_sym_info *dyn_i, |
800eeca4 JW |
283 | bfd_vma value)); |
284 | static bfd_vma set_pltoff_entry | |
285 | PARAMS ((bfd *abfd, struct bfd_link_info *info, | |
bbe66d08 | 286 | struct elfNN_ia64_dyn_sym_info *dyn_i, |
800eeca4 | 287 | bfd_vma value, boolean)); |
cea4409c AM |
288 | static int elfNN_ia64_unwind_entry_compare |
289 | PARAMS ((const PTR, const PTR)); | |
bbe66d08 | 290 | static boolean elfNN_ia64_final_link |
800eeca4 | 291 | PARAMS ((bfd *abfd, struct bfd_link_info *info)); |
bbe66d08 | 292 | static boolean elfNN_ia64_relocate_section |
800eeca4 JW |
293 | PARAMS ((bfd *output_bfd, struct bfd_link_info *info, bfd *input_bfd, |
294 | asection *input_section, bfd_byte *contents, | |
295 | Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms, | |
296 | asection **local_sections)); | |
bbe66d08 | 297 | static boolean elfNN_ia64_finish_dynamic_symbol |
800eeca4 JW |
298 | PARAMS ((bfd *output_bfd, struct bfd_link_info *info, |
299 | struct elf_link_hash_entry *h, Elf_Internal_Sym *sym)); | |
bbe66d08 | 300 | static boolean elfNN_ia64_finish_dynamic_sections |
800eeca4 | 301 | PARAMS ((bfd *abfd, struct bfd_link_info *info)); |
bbe66d08 | 302 | static boolean elfNN_ia64_set_private_flags |
800eeca4 | 303 | PARAMS ((bfd *abfd, flagword flags)); |
bbe66d08 | 304 | static boolean elfNN_ia64_merge_private_bfd_data |
800eeca4 | 305 | PARAMS ((bfd *ibfd, bfd *obfd)); |
bbe66d08 | 306 | static boolean elfNN_ia64_print_private_bfd_data |
800eeca4 | 307 | PARAMS ((bfd *abfd, PTR ptr)); |
db6751f2 | 308 | static enum elf_reloc_type_class elfNN_ia64_reloc_type_class |
f51e552e | 309 | PARAMS ((const Elf_Internal_Rela *)); |
d9cf1b54 AM |
310 | static boolean elfNN_ia64_hpux_vec |
311 | PARAMS ((const bfd_target *vec)); | |
fcf12726 AM |
312 | static void elfNN_hpux_post_process_headers |
313 | PARAMS ((bfd *abfd, struct bfd_link_info *info)); | |
d9cf1b54 | 314 | boolean elfNN_hpux_backend_section_from_bfd_section |
af746e92 | 315 | PARAMS ((bfd *abfd, asection *sec, int *retval)); |
800eeca4 JW |
316 | \f |
317 | /* ia64-specific relocation */ | |
318 | ||
319 | /* Perform a relocation. Not much to do here as all the hard work is | |
bbe66d08 | 320 | done in elfNN_ia64_final_link_relocate. */ |
800eeca4 | 321 | static bfd_reloc_status_type |
bbe66d08 | 322 | elfNN_ia64_reloc (abfd, reloc, sym, data, input_section, |
800eeca4 | 323 | output_bfd, error_message) |
64bf6ae6 | 324 | bfd *abfd ATTRIBUTE_UNUSED; |
800eeca4 | 325 | arelent *reloc; |
64bf6ae6 JW |
326 | asymbol *sym ATTRIBUTE_UNUSED; |
327 | PTR data ATTRIBUTE_UNUSED; | |
800eeca4 JW |
328 | asection *input_section; |
329 | bfd *output_bfd; | |
330 | char **error_message; | |
331 | { | |
332 | if (output_bfd) | |
333 | { | |
334 | reloc->address += input_section->output_offset; | |
335 | return bfd_reloc_ok; | |
336 | } | |
bbe66d08 | 337 | *error_message = "Unsupported call to elfNN_ia64_reloc"; |
800eeca4 JW |
338 | return bfd_reloc_notsupported; |
339 | } | |
340 | ||
341 | #define IA64_HOWTO(TYPE, NAME, SIZE, PCREL, IN) \ | |
342 | HOWTO (TYPE, 0, SIZE, 0, PCREL, 0, complain_overflow_signed, \ | |
bbe66d08 | 343 | elfNN_ia64_reloc, NAME, false, 0, 0, IN) |
800eeca4 JW |
344 | |
345 | /* This table has to be sorted according to increasing number of the | |
346 | TYPE field. */ | |
347 | static reloc_howto_type ia64_howto_table[] = | |
348 | { | |
349 | IA64_HOWTO (R_IA64_NONE, "NONE", 0, false, true), | |
350 | ||
351 | IA64_HOWTO (R_IA64_IMM14, "IMM14", 0, false, true), | |
352 | IA64_HOWTO (R_IA64_IMM22, "IMM22", 0, false, true), | |
353 | IA64_HOWTO (R_IA64_IMM64, "IMM64", 0, false, true), | |
354 | IA64_HOWTO (R_IA64_DIR32MSB, "DIR32MSB", 2, false, true), | |
355 | IA64_HOWTO (R_IA64_DIR32LSB, "DIR32LSB", 2, false, true), | |
356 | IA64_HOWTO (R_IA64_DIR64MSB, "DIR64MSB", 4, false, true), | |
357 | IA64_HOWTO (R_IA64_DIR64LSB, "DIR64LSB", 4, false, true), | |
358 | ||
359 | IA64_HOWTO (R_IA64_GPREL22, "GPREL22", 0, false, true), | |
360 | IA64_HOWTO (R_IA64_GPREL64I, "GPREL64I", 0, false, true), | |
361 | IA64_HOWTO (R_IA64_GPREL32MSB, "GPREL32MSB", 2, false, true), | |
362 | IA64_HOWTO (R_IA64_GPREL32LSB, "GPREL32LSB", 2, false, true), | |
363 | IA64_HOWTO (R_IA64_GPREL64MSB, "GPREL64MSB", 4, false, true), | |
364 | IA64_HOWTO (R_IA64_GPREL64LSB, "GPREL64LSB", 4, false, true), | |
365 | ||
366 | IA64_HOWTO (R_IA64_LTOFF22, "LTOFF22", 0, false, true), | |
367 | IA64_HOWTO (R_IA64_LTOFF64I, "LTOFF64I", 0, false, true), | |
368 | ||
369 | IA64_HOWTO (R_IA64_PLTOFF22, "PLTOFF22", 0, false, true), | |
370 | IA64_HOWTO (R_IA64_PLTOFF64I, "PLTOFF64I", 0, false, true), | |
371 | IA64_HOWTO (R_IA64_PLTOFF64MSB, "PLTOFF64MSB", 4, false, true), | |
372 | IA64_HOWTO (R_IA64_PLTOFF64LSB, "PLTOFF64LSB", 4, false, true), | |
373 | ||
748abff6 | 374 | IA64_HOWTO (R_IA64_FPTR64I, "FPTR64I", 0, false, true), |
800eeca4 JW |
375 | IA64_HOWTO (R_IA64_FPTR32MSB, "FPTR32MSB", 2, false, true), |
376 | IA64_HOWTO (R_IA64_FPTR32LSB, "FPTR32LSB", 2, false, true), | |
377 | IA64_HOWTO (R_IA64_FPTR64MSB, "FPTR64MSB", 4, false, true), | |
378 | IA64_HOWTO (R_IA64_FPTR64LSB, "FPTR64LSB", 4, false, true), | |
379 | ||
748abff6 | 380 | IA64_HOWTO (R_IA64_PCREL60B, "PCREL60B", 0, true, true), |
800eeca4 JW |
381 | IA64_HOWTO (R_IA64_PCREL21B, "PCREL21B", 0, true, true), |
382 | IA64_HOWTO (R_IA64_PCREL21M, "PCREL21M", 0, true, true), | |
383 | IA64_HOWTO (R_IA64_PCREL21F, "PCREL21F", 0, true, true), | |
384 | IA64_HOWTO (R_IA64_PCREL32MSB, "PCREL32MSB", 2, true, true), | |
385 | IA64_HOWTO (R_IA64_PCREL32LSB, "PCREL32LSB", 2, true, true), | |
386 | IA64_HOWTO (R_IA64_PCREL64MSB, "PCREL64MSB", 4, true, true), | |
387 | IA64_HOWTO (R_IA64_PCREL64LSB, "PCREL64LSB", 4, true, true), | |
388 | ||
748abff6 RH |
389 | IA64_HOWTO (R_IA64_LTOFF_FPTR22, "LTOFF_FPTR22", 0, false, true), |
390 | IA64_HOWTO (R_IA64_LTOFF_FPTR64I, "LTOFF_FPTR64I", 0, false, true), | |
a4bd8390 JW |
391 | IA64_HOWTO (R_IA64_LTOFF_FPTR32MSB, "LTOFF_FPTR32MSB", 2, false, true), |
392 | IA64_HOWTO (R_IA64_LTOFF_FPTR32LSB, "LTOFF_FPTR32LSB", 2, false, true), | |
800eeca4 JW |
393 | IA64_HOWTO (R_IA64_LTOFF_FPTR64MSB, "LTOFF_FPTR64MSB", 4, false, true), |
394 | IA64_HOWTO (R_IA64_LTOFF_FPTR64LSB, "LTOFF_FPTR64LSB", 4, false, true), | |
395 | ||
800eeca4 JW |
396 | IA64_HOWTO (R_IA64_SEGREL32MSB, "SEGREL32MSB", 2, false, true), |
397 | IA64_HOWTO (R_IA64_SEGREL32LSB, "SEGREL32LSB", 2, false, true), | |
398 | IA64_HOWTO (R_IA64_SEGREL64MSB, "SEGREL64MSB", 4, false, true), | |
399 | IA64_HOWTO (R_IA64_SEGREL64LSB, "SEGREL64LSB", 4, false, true), | |
400 | ||
401 | IA64_HOWTO (R_IA64_SECREL32MSB, "SECREL32MSB", 2, false, true), | |
402 | IA64_HOWTO (R_IA64_SECREL32LSB, "SECREL32LSB", 2, false, true), | |
403 | IA64_HOWTO (R_IA64_SECREL64MSB, "SECREL64MSB", 4, false, true), | |
404 | IA64_HOWTO (R_IA64_SECREL64LSB, "SECREL64LSB", 4, false, true), | |
405 | ||
406 | IA64_HOWTO (R_IA64_REL32MSB, "REL32MSB", 2, false, true), | |
407 | IA64_HOWTO (R_IA64_REL32LSB, "REL32LSB", 2, false, true), | |
408 | IA64_HOWTO (R_IA64_REL64MSB, "REL64MSB", 4, false, true), | |
409 | IA64_HOWTO (R_IA64_REL64LSB, "REL64LSB", 4, false, true), | |
410 | ||
411 | IA64_HOWTO (R_IA64_LTV32MSB, "LTV32MSB", 2, false, true), | |
412 | IA64_HOWTO (R_IA64_LTV32LSB, "LTV32LSB", 2, false, true), | |
413 | IA64_HOWTO (R_IA64_LTV64MSB, "LTV64MSB", 4, false, true), | |
414 | IA64_HOWTO (R_IA64_LTV64LSB, "LTV64LSB", 4, false, true), | |
415 | ||
748abff6 RH |
416 | IA64_HOWTO (R_IA64_PCREL21BI, "PCREL21BI", 0, true, true), |
417 | IA64_HOWTO (R_IA64_PCREL22, "PCREL22", 0, true, true), | |
418 | IA64_HOWTO (R_IA64_PCREL64I, "PCREL64I", 0, true, true), | |
419 | ||
800eeca4 JW |
420 | IA64_HOWTO (R_IA64_IPLTMSB, "IPLTMSB", 4, false, true), |
421 | IA64_HOWTO (R_IA64_IPLTLSB, "IPLTLSB", 4, false, true), | |
800eeca4 JW |
422 | IA64_HOWTO (R_IA64_COPY, "COPY", 4, false, true), |
423 | IA64_HOWTO (R_IA64_LTOFF22X, "LTOFF22X", 0, false, true), | |
424 | IA64_HOWTO (R_IA64_LDXMOV, "LDXMOV", 0, false, true), | |
425 | ||
748abff6 | 426 | IA64_HOWTO (R_IA64_TPREL22, "TPREL22", 0, false, false), |
800eeca4 JW |
427 | IA64_HOWTO (R_IA64_TPREL64MSB, "TPREL64MSB", 8, false, false), |
428 | IA64_HOWTO (R_IA64_TPREL64LSB, "TPREL64LSB", 8, false, false), | |
748abff6 | 429 | IA64_HOWTO (R_IA64_LTOFF_TP22, "LTOFF_TP22", 0, false, false), |
800eeca4 JW |
430 | }; |
431 | ||
432 | static unsigned char elf_code_to_howto_index[R_IA64_MAX_RELOC_CODE + 1]; | |
433 | ||
434 | /* Given a BFD reloc type, return the matching HOWTO structure. */ | |
435 | ||
436 | static reloc_howto_type* | |
437 | lookup_howto (rtype) | |
438 | unsigned int rtype; | |
439 | { | |
440 | static int inited = 0; | |
441 | int i; | |
442 | ||
443 | if (!inited) | |
444 | { | |
445 | inited = 1; | |
446 | ||
447 | memset (elf_code_to_howto_index, 0xff, sizeof (elf_code_to_howto_index)); | |
448 | for (i = 0; i < NELEMS (ia64_howto_table); ++i) | |
449 | elf_code_to_howto_index[ia64_howto_table[i].type] = i; | |
450 | } | |
451 | ||
452 | BFD_ASSERT (rtype <= R_IA64_MAX_RELOC_CODE); | |
453 | i = elf_code_to_howto_index[rtype]; | |
454 | if (i >= NELEMS (ia64_howto_table)) | |
455 | return 0; | |
456 | return ia64_howto_table + i; | |
457 | } | |
458 | ||
459 | static reloc_howto_type* | |
bbe66d08 | 460 | elfNN_ia64_reloc_type_lookup (abfd, bfd_code) |
64bf6ae6 | 461 | bfd *abfd ATTRIBUTE_UNUSED; |
800eeca4 JW |
462 | bfd_reloc_code_real_type bfd_code; |
463 | { | |
464 | unsigned int rtype; | |
465 | ||
466 | switch (bfd_code) | |
467 | { | |
468 | case BFD_RELOC_NONE: rtype = R_IA64_NONE; break; | |
469 | ||
470 | case BFD_RELOC_IA64_IMM14: rtype = R_IA64_IMM14; break; | |
471 | case BFD_RELOC_IA64_IMM22: rtype = R_IA64_IMM22; break; | |
472 | case BFD_RELOC_IA64_IMM64: rtype = R_IA64_IMM64; break; | |
473 | ||
474 | case BFD_RELOC_IA64_DIR32MSB: rtype = R_IA64_DIR32MSB; break; | |
475 | case BFD_RELOC_IA64_DIR32LSB: rtype = R_IA64_DIR32LSB; break; | |
476 | case BFD_RELOC_IA64_DIR64MSB: rtype = R_IA64_DIR64MSB; break; | |
477 | case BFD_RELOC_IA64_DIR64LSB: rtype = R_IA64_DIR64LSB; break; | |
478 | ||
479 | case BFD_RELOC_IA64_GPREL22: rtype = R_IA64_GPREL22; break; | |
480 | case BFD_RELOC_IA64_GPREL64I: rtype = R_IA64_GPREL64I; break; | |
481 | case BFD_RELOC_IA64_GPREL32MSB: rtype = R_IA64_GPREL32MSB; break; | |
482 | case BFD_RELOC_IA64_GPREL32LSB: rtype = R_IA64_GPREL32LSB; break; | |
483 | case BFD_RELOC_IA64_GPREL64MSB: rtype = R_IA64_GPREL64MSB; break; | |
484 | case BFD_RELOC_IA64_GPREL64LSB: rtype = R_IA64_GPREL64LSB; break; | |
485 | ||
486 | case BFD_RELOC_IA64_LTOFF22: rtype = R_IA64_LTOFF22; break; | |
487 | case BFD_RELOC_IA64_LTOFF64I: rtype = R_IA64_LTOFF64I; break; | |
488 | ||
489 | case BFD_RELOC_IA64_PLTOFF22: rtype = R_IA64_PLTOFF22; break; | |
490 | case BFD_RELOC_IA64_PLTOFF64I: rtype = R_IA64_PLTOFF64I; break; | |
491 | case BFD_RELOC_IA64_PLTOFF64MSB: rtype = R_IA64_PLTOFF64MSB; break; | |
492 | case BFD_RELOC_IA64_PLTOFF64LSB: rtype = R_IA64_PLTOFF64LSB; break; | |
493 | case BFD_RELOC_IA64_FPTR64I: rtype = R_IA64_FPTR64I; break; | |
494 | case BFD_RELOC_IA64_FPTR32MSB: rtype = R_IA64_FPTR32MSB; break; | |
495 | case BFD_RELOC_IA64_FPTR32LSB: rtype = R_IA64_FPTR32LSB; break; | |
496 | case BFD_RELOC_IA64_FPTR64MSB: rtype = R_IA64_FPTR64MSB; break; | |
497 | case BFD_RELOC_IA64_FPTR64LSB: rtype = R_IA64_FPTR64LSB; break; | |
498 | ||
499 | case BFD_RELOC_IA64_PCREL21B: rtype = R_IA64_PCREL21B; break; | |
748abff6 | 500 | case BFD_RELOC_IA64_PCREL21BI: rtype = R_IA64_PCREL21BI; break; |
800eeca4 JW |
501 | case BFD_RELOC_IA64_PCREL21M: rtype = R_IA64_PCREL21M; break; |
502 | case BFD_RELOC_IA64_PCREL21F: rtype = R_IA64_PCREL21F; break; | |
748abff6 RH |
503 | case BFD_RELOC_IA64_PCREL22: rtype = R_IA64_PCREL22; break; |
504 | case BFD_RELOC_IA64_PCREL60B: rtype = R_IA64_PCREL60B; break; | |
505 | case BFD_RELOC_IA64_PCREL64I: rtype = R_IA64_PCREL64I; break; | |
800eeca4 JW |
506 | case BFD_RELOC_IA64_PCREL32MSB: rtype = R_IA64_PCREL32MSB; break; |
507 | case BFD_RELOC_IA64_PCREL32LSB: rtype = R_IA64_PCREL32LSB; break; | |
508 | case BFD_RELOC_IA64_PCREL64MSB: rtype = R_IA64_PCREL64MSB; break; | |
509 | case BFD_RELOC_IA64_PCREL64LSB: rtype = R_IA64_PCREL64LSB; break; | |
510 | ||
511 | case BFD_RELOC_IA64_LTOFF_FPTR22: rtype = R_IA64_LTOFF_FPTR22; break; | |
512 | case BFD_RELOC_IA64_LTOFF_FPTR64I: rtype = R_IA64_LTOFF_FPTR64I; break; | |
a4bd8390 JW |
513 | case BFD_RELOC_IA64_LTOFF_FPTR32MSB: rtype = R_IA64_LTOFF_FPTR32MSB; break; |
514 | case BFD_RELOC_IA64_LTOFF_FPTR32LSB: rtype = R_IA64_LTOFF_FPTR32LSB; break; | |
800eeca4 JW |
515 | case BFD_RELOC_IA64_LTOFF_FPTR64MSB: rtype = R_IA64_LTOFF_FPTR64MSB; break; |
516 | case BFD_RELOC_IA64_LTOFF_FPTR64LSB: rtype = R_IA64_LTOFF_FPTR64LSB; break; | |
517 | ||
800eeca4 JW |
518 | case BFD_RELOC_IA64_SEGREL32MSB: rtype = R_IA64_SEGREL32MSB; break; |
519 | case BFD_RELOC_IA64_SEGREL32LSB: rtype = R_IA64_SEGREL32LSB; break; | |
520 | case BFD_RELOC_IA64_SEGREL64MSB: rtype = R_IA64_SEGREL64MSB; break; | |
521 | case BFD_RELOC_IA64_SEGREL64LSB: rtype = R_IA64_SEGREL64LSB; break; | |
522 | ||
523 | case BFD_RELOC_IA64_SECREL32MSB: rtype = R_IA64_SECREL32MSB; break; | |
524 | case BFD_RELOC_IA64_SECREL32LSB: rtype = R_IA64_SECREL32LSB; break; | |
525 | case BFD_RELOC_IA64_SECREL64MSB: rtype = R_IA64_SECREL64MSB; break; | |
526 | case BFD_RELOC_IA64_SECREL64LSB: rtype = R_IA64_SECREL64LSB; break; | |
527 | ||
528 | case BFD_RELOC_IA64_REL32MSB: rtype = R_IA64_REL32MSB; break; | |
529 | case BFD_RELOC_IA64_REL32LSB: rtype = R_IA64_REL32LSB; break; | |
530 | case BFD_RELOC_IA64_REL64MSB: rtype = R_IA64_REL64MSB; break; | |
531 | case BFD_RELOC_IA64_REL64LSB: rtype = R_IA64_REL64LSB; break; | |
532 | ||
533 | case BFD_RELOC_IA64_LTV32MSB: rtype = R_IA64_LTV32MSB; break; | |
534 | case BFD_RELOC_IA64_LTV32LSB: rtype = R_IA64_LTV32LSB; break; | |
535 | case BFD_RELOC_IA64_LTV64MSB: rtype = R_IA64_LTV64MSB; break; | |
536 | case BFD_RELOC_IA64_LTV64LSB: rtype = R_IA64_LTV64LSB; break; | |
537 | ||
538 | case BFD_RELOC_IA64_IPLTMSB: rtype = R_IA64_IPLTMSB; break; | |
539 | case BFD_RELOC_IA64_IPLTLSB: rtype = R_IA64_IPLTLSB; break; | |
800eeca4 JW |
540 | case BFD_RELOC_IA64_COPY: rtype = R_IA64_COPY; break; |
541 | case BFD_RELOC_IA64_LTOFF22X: rtype = R_IA64_LTOFF22X; break; | |
542 | case BFD_RELOC_IA64_LDXMOV: rtype = R_IA64_LDXMOV; break; | |
543 | ||
544 | case BFD_RELOC_IA64_TPREL22: rtype = R_IA64_TPREL22; break; | |
545 | case BFD_RELOC_IA64_TPREL64MSB: rtype = R_IA64_TPREL64MSB; break; | |
546 | case BFD_RELOC_IA64_TPREL64LSB: rtype = R_IA64_TPREL64LSB; break; | |
547 | case BFD_RELOC_IA64_LTOFF_TP22: rtype = R_IA64_LTOFF_TP22; break; | |
548 | ||
549 | default: return 0; | |
550 | } | |
551 | return lookup_howto (rtype); | |
552 | } | |
553 | ||
554 | /* Given a ELF reloc, return the matching HOWTO structure. */ | |
555 | ||
556 | static void | |
bbe66d08 | 557 | elfNN_ia64_info_to_howto (abfd, bfd_reloc, elf_reloc) |
64bf6ae6 | 558 | bfd *abfd ATTRIBUTE_UNUSED; |
800eeca4 | 559 | arelent *bfd_reloc; |
bbe66d08 | 560 | ElfNN_Internal_Rela *elf_reloc; |
800eeca4 | 561 | { |
dc810e39 AM |
562 | bfd_reloc->howto |
563 | = lookup_howto ((unsigned int) ELFNN_R_TYPE (elf_reloc->r_info)); | |
800eeca4 JW |
564 | } |
565 | \f | |
566 | #define PLT_HEADER_SIZE (3 * 16) | |
567 | #define PLT_MIN_ENTRY_SIZE (1 * 16) | |
568 | #define PLT_FULL_ENTRY_SIZE (2 * 16) | |
569 | #define PLT_RESERVED_WORDS 3 | |
570 | ||
571 | static const bfd_byte plt_header[PLT_HEADER_SIZE] = | |
572 | { | |
573 | 0x0b, 0x10, 0x00, 0x1c, 0x00, 0x21, /* [MMI] mov r2=r14;; */ | |
574 | 0xe0, 0x00, 0x08, 0x00, 0x48, 0x00, /* addl r14=0,r2 */ | |
575 | 0x00, 0x00, 0x04, 0x00, /* nop.i 0x0;; */ | |
576 | 0x0b, 0x80, 0x20, 0x1c, 0x18, 0x14, /* [MMI] ld8 r16=[r14],8;; */ | |
577 | 0x10, 0x41, 0x38, 0x30, 0x28, 0x00, /* ld8 r17=[r14],8 */ | |
578 | 0x00, 0x00, 0x04, 0x00, /* nop.i 0x0;; */ | |
579 | 0x11, 0x08, 0x00, 0x1c, 0x18, 0x10, /* [MIB] ld8 r1=[r14] */ | |
580 | 0x60, 0x88, 0x04, 0x80, 0x03, 0x00, /* mov b6=r17 */ | |
581 | 0x60, 0x00, 0x80, 0x00 /* br.few b6;; */ | |
582 | }; | |
583 | ||
584 | static const bfd_byte plt_min_entry[PLT_MIN_ENTRY_SIZE] = | |
585 | { | |
586 | 0x11, 0x78, 0x00, 0x00, 0x00, 0x24, /* [MIB] mov r15=0 */ | |
587 | 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, /* nop.i 0x0 */ | |
588 | 0x00, 0x00, 0x00, 0x40 /* br.few 0 <PLT0>;; */ | |
589 | }; | |
590 | ||
591 | static const bfd_byte plt_full_entry[PLT_FULL_ENTRY_SIZE] = | |
592 | { | |
593 | 0x0b, 0x78, 0x00, 0x02, 0x00, 0x24, /* [MMI] addl r15=0,r1;; */ | |
594 | 0x00, 0x41, 0x3c, 0x30, 0x28, 0xc0, /* ld8 r16=[r15],8 */ | |
595 | 0x01, 0x08, 0x00, 0x84, /* mov r14=r1;; */ | |
596 | 0x11, 0x08, 0x00, 0x1e, 0x18, 0x10, /* [MIB] ld8 r1=[r15] */ | |
597 | 0x60, 0x80, 0x04, 0x80, 0x03, 0x00, /* mov b6=r16 */ | |
598 | 0x60, 0x00, 0x80, 0x00 /* br.few b6;; */ | |
599 | }; | |
600 | ||
601 | #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" | |
7b6dab7f TW |
602 | #define AIX_DYNAMIC_INTERPRETER "/usr/lib/ia64l64/libc.so.1" |
603 | #define DYNAMIC_INTERPRETER(abfd) \ | |
604 | (elfNN_ia64_aix_vec (abfd->xvec) ? AIX_DYNAMIC_INTERPRETER : ELF_DYNAMIC_INTERPRETER) | |
748abff6 RH |
605 | |
606 | /* Select out of range branch fixup type. Note that Itanium does | |
607 | not support brl, and so it gets emulated by the kernel. */ | |
608 | #undef USE_BRL | |
609 | ||
610 | static const bfd_byte oor_brl[16] = | |
611 | { | |
612 | 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MLX] nop.m 0 */ | |
613 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* brl.sptk.few tgt;; */ | |
614 | 0x00, 0x00, 0x00, 0xc0 | |
615 | }; | |
616 | ||
617 | static const bfd_byte oor_ip[48] = | |
618 | { | |
619 | 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MLX] nop.m 0 */ | |
620 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, /* movl r15=0 */ | |
621 | 0x01, 0x00, 0x00, 0x60, | |
622 | 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MII] nop.m 0 */ | |
623 | 0x00, 0x01, 0x00, 0x60, 0x00, 0x00, /* mov r16=ip;; */ | |
624 | 0xf2, 0x80, 0x00, 0x80, /* add r16=r15,r16;; */ | |
625 | 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MIB] nop.m 0 */ | |
626 | 0x60, 0x80, 0x04, 0x80, 0x03, 0x00, /* mov b6=r16 */ | |
627 | 0x60, 0x00, 0x80, 0x00 /* br b6;; */ | |
628 | }; | |
629 | \f | |
630 | /* These functions do relaxation for IA-64 ELF. | |
631 | ||
632 | This is primarily to support branches to targets out of range; | |
633 | relaxation of R_IA64_LTOFF22X and R_IA64_LDXMOV not yet supported. */ | |
634 | ||
635 | static boolean | |
bbe66d08 | 636 | elfNN_ia64_relax_section (abfd, sec, link_info, again) |
748abff6 RH |
637 | bfd *abfd; |
638 | asection *sec; | |
639 | struct bfd_link_info *link_info; | |
640 | boolean *again; | |
641 | { | |
642 | struct one_fixup | |
643 | { | |
644 | struct one_fixup *next; | |
645 | asection *tsec; | |
646 | bfd_vma toff; | |
647 | bfd_vma trampoff; | |
648 | }; | |
649 | ||
650 | Elf_Internal_Shdr *symtab_hdr; | |
9ad5cbcf | 651 | Elf_Internal_Shdr *shndx_hdr; |
748abff6 | 652 | Elf_Internal_Rela *internal_relocs; |
64bf6ae6 | 653 | Elf_Internal_Rela *free_relocs = NULL; |
748abff6 RH |
654 | Elf_Internal_Rela *irel, *irelend; |
655 | bfd_byte *contents; | |
64bf6ae6 | 656 | bfd_byte *free_contents = NULL; |
bbe66d08 | 657 | ElfNN_External_Sym *extsyms; |
64bf6ae6 | 658 | ElfNN_External_Sym *free_extsyms = NULL; |
9ad5cbcf | 659 | Elf_External_Sym_Shndx *shndx_buf = NULL; |
bbe66d08 | 660 | struct elfNN_ia64_link_hash_table *ia64_info; |
748abff6 RH |
661 | struct one_fixup *fixups = NULL; |
662 | boolean changed_contents = false; | |
663 | boolean changed_relocs = false; | |
664 | ||
46f5aac8 KH |
665 | /* Assume we're not going to change any sizes, and we'll only need |
666 | one pass. */ | |
748abff6 RH |
667 | *again = false; |
668 | ||
669 | /* Nothing to do if there are no relocations. */ | |
670 | if ((sec->flags & SEC_RELOC) == 0 | |
671 | || sec->reloc_count == 0) | |
672 | return true; | |
673 | ||
674 | /* If this is the first time we have been called for this section, | |
675 | initialize the cooked size. */ | |
676 | if (sec->_cooked_size == 0) | |
677 | sec->_cooked_size = sec->_raw_size; | |
678 | ||
679 | symtab_hdr = &elf_tdata (abfd)->symtab_hdr; | |
680 | ||
681 | /* Load the relocations for this section. */ | |
bbe66d08 | 682 | internal_relocs = (_bfd_elfNN_link_read_relocs |
748abff6 RH |
683 | (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL, |
684 | link_info->keep_memory)); | |
685 | if (internal_relocs == NULL) | |
686 | goto error_return; | |
64bf6ae6 | 687 | |
748abff6 RH |
688 | if (! link_info->keep_memory) |
689 | free_relocs = internal_relocs; | |
690 | ||
bbe66d08 | 691 | ia64_info = elfNN_ia64_hash_table (link_info); |
748abff6 RH |
692 | irelend = internal_relocs + sec->reloc_count; |
693 | ||
694 | for (irel = internal_relocs; irel < irelend; irel++) | |
bbe66d08 | 695 | if (ELFNN_R_TYPE (irel->r_info) == (int) R_IA64_PCREL21B) |
748abff6 RH |
696 | break; |
697 | ||
698 | /* No branch-type relocations. */ | |
699 | if (irel == irelend) | |
700 | { | |
701 | if (free_relocs != NULL) | |
702 | free (free_relocs); | |
703 | return true; | |
704 | } | |
705 | ||
706 | /* Get the section contents. */ | |
748abff6 RH |
707 | if (elf_section_data (sec)->this_hdr.contents != NULL) |
708 | contents = elf_section_data (sec)->this_hdr.contents; | |
709 | else | |
710 | { | |
711 | contents = (bfd_byte *) bfd_malloc (sec->_raw_size); | |
712 | if (contents == NULL) | |
713 | goto error_return; | |
714 | free_contents = contents; | |
715 | ||
716 | if (! bfd_get_section_contents (abfd, sec, contents, | |
717 | (file_ptr) 0, sec->_raw_size)) | |
718 | goto error_return; | |
719 | } | |
720 | ||
9ad5cbcf | 721 | /* Read this BFD's local symbols. */ |
748abff6 | 722 | if (symtab_hdr->contents != NULL) |
bbe66d08 | 723 | extsyms = (ElfNN_External_Sym *) symtab_hdr->contents; |
748abff6 RH |
724 | else |
725 | { | |
9ad5cbcf AM |
726 | bfd_size_type amt; |
727 | ||
728 | amt = symtab_hdr->sh_info * sizeof (ElfNN_External_Sym); | |
729 | extsyms = (ElfNN_External_Sym *) bfd_malloc (amt); | |
748abff6 RH |
730 | if (extsyms == NULL) |
731 | goto error_return; | |
732 | free_extsyms = extsyms; | |
733 | if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0 | |
9ad5cbcf AM |
734 | || bfd_bread (extsyms, amt, abfd) != amt) |
735 | goto error_return; | |
736 | } | |
737 | ||
738 | shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr; | |
739 | if (shndx_hdr->sh_size != 0) | |
740 | { | |
741 | bfd_size_type amt; | |
742 | ||
743 | amt = symtab_hdr->sh_info * sizeof (Elf_External_Sym_Shndx); | |
744 | shndx_buf = (Elf_External_Sym_Shndx *) bfd_malloc (amt); | |
745 | if (shndx_buf == NULL) | |
746 | goto error_return; | |
747 | if (bfd_seek (abfd, shndx_hdr->sh_offset, SEEK_SET) != 0 | |
748 | || bfd_bread (shndx_buf, amt, abfd) != amt) | |
748abff6 RH |
749 | goto error_return; |
750 | } | |
751 | ||
752 | for (; irel < irelend; irel++) | |
753 | { | |
754 | bfd_vma symaddr, reladdr, trampoff, toff, roff; | |
755 | Elf_Internal_Sym isym; | |
756 | asection *tsec; | |
757 | struct one_fixup *f; | |
dc810e39 | 758 | bfd_size_type amt; |
748abff6 | 759 | |
bbe66d08 | 760 | if (ELFNN_R_TYPE (irel->r_info) != (int) R_IA64_PCREL21B) |
748abff6 RH |
761 | continue; |
762 | ||
763 | /* Get the value of the symbol referred to by the reloc. */ | |
bbe66d08 | 764 | if (ELFNN_R_SYM (irel->r_info) < symtab_hdr->sh_info) |
748abff6 | 765 | { |
9ad5cbcf AM |
766 | ElfNN_External_Sym *esym; |
767 | Elf_External_Sym_Shndx *shndx; | |
768 | ||
748abff6 | 769 | /* A local symbol. */ |
9ad5cbcf AM |
770 | esym = extsyms + ELFNN_R_SYM (irel->r_info); |
771 | shndx = shndx_buf + (shndx_buf ? ELFNN_R_SYM (irel->r_info) : 0); | |
772 | bfd_elfNN_swap_symbol_in (abfd, esym, shndx, &isym); | |
748abff6 RH |
773 | if (isym.st_shndx == SHN_UNDEF) |
774 | continue; /* We can't do anthing with undefined symbols. */ | |
775 | else if (isym.st_shndx == SHN_ABS) | |
776 | tsec = bfd_abs_section_ptr; | |
777 | else if (isym.st_shndx == SHN_COMMON) | |
778 | tsec = bfd_com_section_ptr; | |
d9cf1b54 AM |
779 | else if (isym.st_shndx == SHN_IA_64_ANSI_COMMON) |
780 | tsec = bfd_com_section_ptr; | |
3e932841 | 781 | else |
9ad5cbcf | 782 | tsec = bfd_section_from_elf_index (abfd, isym.st_shndx); |
748abff6 RH |
783 | |
784 | toff = isym.st_value; | |
785 | } | |
786 | else | |
787 | { | |
788 | unsigned long indx; | |
789 | struct elf_link_hash_entry *h; | |
bbe66d08 | 790 | struct elfNN_ia64_dyn_sym_info *dyn_i; |
748abff6 | 791 | |
bbe66d08 | 792 | indx = ELFNN_R_SYM (irel->r_info) - symtab_hdr->sh_info; |
748abff6 RH |
793 | h = elf_sym_hashes (abfd)[indx]; |
794 | BFD_ASSERT (h != NULL); | |
795 | ||
796 | while (h->root.type == bfd_link_hash_indirect | |
797 | || h->root.type == bfd_link_hash_warning) | |
798 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
799 | ||
800 | dyn_i = get_dyn_sym_info (ia64_info, h, abfd, irel, false); | |
801 | ||
802 | /* For branches to dynamic symbols, we're interested instead | |
803 | in a branch to the PLT entry. */ | |
804 | if (dyn_i && dyn_i->want_plt2) | |
805 | { | |
806 | tsec = ia64_info->plt_sec; | |
807 | toff = dyn_i->plt2_offset; | |
808 | } | |
809 | else | |
810 | { | |
811 | /* We can't do anthing with undefined symbols. */ | |
812 | if (h->root.type == bfd_link_hash_undefined | |
813 | || h->root.type == bfd_link_hash_undefweak) | |
814 | continue; | |
815 | ||
816 | tsec = h->root.u.def.section; | |
817 | toff = h->root.u.def.value; | |
818 | } | |
819 | } | |
820 | ||
821 | symaddr = (tsec->output_section->vma | |
822 | + tsec->output_offset | |
823 | + toff | |
824 | + irel->r_addend); | |
825 | ||
826 | roff = irel->r_offset; | |
827 | reladdr = (sec->output_section->vma | |
828 | + sec->output_offset | |
dc810e39 | 829 | + roff) & (bfd_vma) -4; |
748abff6 RH |
830 | |
831 | /* If the branch is in range, no need to do anything. */ | |
832 | if ((bfd_signed_vma) (symaddr - reladdr) >= -0x1000000 | |
833 | && (bfd_signed_vma) (symaddr - reladdr) <= 0x0FFFFF0) | |
834 | continue; | |
835 | ||
836 | /* If the branch and target are in the same section, you've | |
837 | got one honking big section and we can't help you. You'll | |
838 | get an error message later. */ | |
839 | if (tsec == sec) | |
840 | continue; | |
841 | ||
842 | /* Look for an existing fixup to this address. */ | |
843 | for (f = fixups; f ; f = f->next) | |
844 | if (f->tsec == tsec && f->toff == toff) | |
845 | break; | |
846 | ||
847 | if (f == NULL) | |
848 | { | |
849 | /* Two alternatives: If it's a branch to a PLT entry, we can | |
850 | make a copy of the FULL_PLT entry. Otherwise, we'll have | |
851 | to use a `brl' insn to get where we're going. */ | |
852 | ||
dc810e39 | 853 | size_t size; |
748abff6 RH |
854 | |
855 | if (tsec == ia64_info->plt_sec) | |
856 | size = sizeof (plt_full_entry); | |
857 | else | |
858 | { | |
859 | #ifdef USE_BRL | |
860 | size = sizeof (oor_brl); | |
861 | #else | |
862 | size = sizeof (oor_ip); | |
863 | #endif | |
864 | } | |
865 | ||
866 | /* Resize the current section to make room for the new branch. */ | |
dc810e39 AM |
867 | trampoff = (sec->_cooked_size + 15) & (bfd_vma) -16; |
868 | amt = trampoff + size; | |
869 | contents = (bfd_byte *) bfd_realloc (contents, amt); | |
748abff6 RH |
870 | if (contents == NULL) |
871 | goto error_return; | |
dc810e39 | 872 | sec->_cooked_size = amt; |
748abff6 RH |
873 | |
874 | if (tsec == ia64_info->plt_sec) | |
875 | { | |
876 | memcpy (contents + trampoff, plt_full_entry, size); | |
877 | ||
878 | /* Hijack the old relocation for use as the PLTOFF reloc. */ | |
bbe66d08 | 879 | irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info), |
748abff6 RH |
880 | R_IA64_PLTOFF22); |
881 | irel->r_offset = trampoff; | |
882 | } | |
883 | else | |
884 | { | |
885 | #ifdef USE_BRL | |
886 | memcpy (contents + trampoff, oor_brl, size); | |
bbe66d08 | 887 | irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info), |
748abff6 RH |
888 | R_IA64_PCREL60B); |
889 | irel->r_offset = trampoff + 2; | |
890 | #else | |
891 | memcpy (contents + trampoff, oor_ip, size); | |
bbe66d08 | 892 | irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info), |
748abff6 RH |
893 | R_IA64_PCREL64I); |
894 | irel->r_addend -= 16; | |
895 | irel->r_offset = trampoff + 2; | |
896 | #endif | |
897 | } | |
898 | ||
899 | /* Record the fixup so we don't do it again this section. */ | |
dc810e39 | 900 | f = (struct one_fixup *) bfd_malloc ((bfd_size_type) sizeof (*f)); |
748abff6 RH |
901 | f->next = fixups; |
902 | f->tsec = tsec; | |
903 | f->toff = toff; | |
904 | f->trampoff = trampoff; | |
905 | fixups = f; | |
906 | } | |
907 | else | |
908 | { | |
909 | /* Nop out the reloc, since we're finalizing things here. */ | |
bbe66d08 | 910 | irel->r_info = ELFNN_R_INFO (0, R_IA64_NONE); |
748abff6 RH |
911 | } |
912 | ||
913 | /* Fix up the existing branch to hit the trampoline. Hope like | |
914 | hell this doesn't overflow too. */ | |
bbe66d08 | 915 | if (elfNN_ia64_install_value (abfd, contents + roff, |
dc810e39 | 916 | f->trampoff - (roff & (bfd_vma) -4), |
748abff6 RH |
917 | R_IA64_PCREL21B) != bfd_reloc_ok) |
918 | goto error_return; | |
919 | ||
920 | changed_contents = true; | |
921 | changed_relocs = true; | |
922 | } | |
923 | ||
924 | /* Clean up and go home. */ | |
925 | while (fixups) | |
926 | { | |
927 | struct one_fixup *f = fixups; | |
928 | fixups = fixups->next; | |
929 | free (f); | |
930 | } | |
931 | ||
932 | if (changed_relocs) | |
933 | elf_section_data (sec)->relocs = internal_relocs; | |
934 | else if (free_relocs != NULL) | |
935 | free (free_relocs); | |
936 | ||
937 | if (changed_contents) | |
938 | elf_section_data (sec)->this_hdr.contents = contents; | |
939 | else if (free_contents != NULL) | |
940 | { | |
941 | if (! link_info->keep_memory) | |
942 | free (free_contents); | |
943 | else | |
944 | { | |
945 | /* Cache the section contents for elf_link_input_bfd. */ | |
946 | elf_section_data (sec)->this_hdr.contents = contents; | |
947 | } | |
948 | } | |
949 | ||
9ad5cbcf AM |
950 | if (shndx_buf != NULL) |
951 | free (shndx_buf); | |
952 | ||
748abff6 RH |
953 | if (free_extsyms != NULL) |
954 | { | |
955 | if (! link_info->keep_memory) | |
956 | free (free_extsyms); | |
957 | else | |
958 | { | |
959 | /* Cache the symbols for elf_link_input_bfd. */ | |
973ffd63 | 960 | symtab_hdr->contents = (unsigned char *) extsyms; |
748abff6 RH |
961 | } |
962 | } | |
963 | ||
964 | *again = changed_contents || changed_relocs; | |
965 | return true; | |
966 | ||
967 | error_return: | |
968 | if (free_relocs != NULL) | |
969 | free (free_relocs); | |
970 | if (free_contents != NULL) | |
971 | free (free_contents); | |
9ad5cbcf AM |
972 | if (shndx_buf != NULL) |
973 | free (shndx_buf); | |
748abff6 RH |
974 | if (free_extsyms != NULL) |
975 | free (free_extsyms); | |
976 | return false; | |
977 | } | |
800eeca4 | 978 | \f |
81545d45 RH |
979 | /* Return true if NAME is an unwind table section name. */ |
980 | ||
981 | static inline boolean | |
d9cf1b54 AM |
982 | is_unwind_section_name (abfd, name) |
983 | bfd *abfd; | |
81545d45 RH |
984 | const char *name; |
985 | { | |
579f31ac | 986 | size_t len1, len2, len3; |
81545d45 | 987 | |
d9cf1b54 AM |
988 | if (elfNN_ia64_hpux_vec (abfd->xvec) |
989 | && !strcmp (name, ELF_STRING_ia64_unwind_hdr)) | |
990 | return false; | |
991 | ||
81545d45 RH |
992 | len1 = sizeof (ELF_STRING_ia64_unwind) - 1; |
993 | len2 = sizeof (ELF_STRING_ia64_unwind_info) - 1; | |
579f31ac JJ |
994 | len3 = sizeof (ELF_STRING_ia64_unwind_once) - 1; |
995 | return ((strncmp (name, ELF_STRING_ia64_unwind, len1) == 0 | |
996 | && strncmp (name, ELF_STRING_ia64_unwind_info, len2) != 0) | |
997 | || strncmp (name, ELF_STRING_ia64_unwind_once, len3) == 0); | |
81545d45 RH |
998 | } |
999 | ||
800eeca4 JW |
1000 | /* Handle an IA-64 specific section when reading an object file. This |
1001 | is called when elfcode.h finds a section with an unknown type. */ | |
1002 | ||
1003 | static boolean | |
bbe66d08 | 1004 | elfNN_ia64_section_from_shdr (abfd, hdr, name) |
800eeca4 | 1005 | bfd *abfd; |
bbe66d08 | 1006 | ElfNN_Internal_Shdr *hdr; |
800eeca4 JW |
1007 | char *name; |
1008 | { | |
1009 | asection *newsect; | |
1010 | ||
1011 | /* There ought to be a place to keep ELF backend specific flags, but | |
1012 | at the moment there isn't one. We just keep track of the | |
1013 | sections by their name, instead. Fortunately, the ABI gives | |
1014 | suggested names for all the MIPS specific sections, so we will | |
1015 | probably get away with this. */ | |
1016 | switch (hdr->sh_type) | |
1017 | { | |
1018 | case SHT_IA_64_UNWIND: | |
d9cf1b54 | 1019 | case SHT_IA_64_HP_OPT_ANOT: |
800eeca4 JW |
1020 | break; |
1021 | ||
1022 | case SHT_IA_64_EXT: | |
1023 | if (strcmp (name, ELF_STRING_ia64_archext) != 0) | |
1024 | return false; | |
1025 | break; | |
1026 | ||
1027 | default: | |
1028 | return false; | |
1029 | } | |
1030 | ||
1031 | if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name)) | |
1032 | return false; | |
1033 | newsect = hdr->bfd_section; | |
1034 | ||
fa152c49 JW |
1035 | return true; |
1036 | } | |
1037 | ||
1038 | /* Convert IA-64 specific section flags to bfd internal section flags. */ | |
1039 | ||
1040 | /* ??? There is no bfd internal flag equivalent to the SHF_IA_64_NORECOV | |
1041 | flag. */ | |
1042 | ||
1043 | static boolean | |
bbe66d08 | 1044 | elfNN_ia64_section_flags (flags, hdr) |
fa152c49 | 1045 | flagword *flags; |
bbe66d08 | 1046 | ElfNN_Internal_Shdr *hdr; |
fa152c49 | 1047 | { |
800eeca4 | 1048 | if (hdr->sh_flags & SHF_IA_64_SHORT) |
fa152c49 | 1049 | *flags |= SEC_SMALL_DATA; |
800eeca4 JW |
1050 | |
1051 | return true; | |
1052 | } | |
1053 | ||
1054 | /* Set the correct type for an IA-64 ELF section. We do this by the | |
1055 | section name, which is a hack, but ought to work. */ | |
1056 | ||
1057 | static boolean | |
bbe66d08 | 1058 | elfNN_ia64_fake_sections (abfd, hdr, sec) |
64bf6ae6 | 1059 | bfd *abfd ATTRIBUTE_UNUSED; |
bbe66d08 | 1060 | ElfNN_Internal_Shdr *hdr; |
800eeca4 JW |
1061 | asection *sec; |
1062 | { | |
1063 | register const char *name; | |
1064 | ||
1065 | name = bfd_get_section_name (abfd, sec); | |
1066 | ||
d9cf1b54 | 1067 | if (is_unwind_section_name (abfd, name)) |
81545d45 RH |
1068 | { |
1069 | /* We don't have the sections numbered at this point, so sh_info | |
1070 | is set later, in elfNN_ia64_final_write_processing. */ | |
1071 | hdr->sh_type = SHT_IA_64_UNWIND; | |
1072 | hdr->sh_flags |= SHF_LINK_ORDER; | |
1073 | } | |
800eeca4 JW |
1074 | else if (strcmp (name, ELF_STRING_ia64_archext) == 0) |
1075 | hdr->sh_type = SHT_IA_64_EXT; | |
d9cf1b54 AM |
1076 | else if (strcmp (name, ".HP.opt_annot") == 0) |
1077 | hdr->sh_type = SHT_IA_64_HP_OPT_ANOT; | |
800eeca4 JW |
1078 | else if (strcmp (name, ".reloc") == 0) |
1079 | /* | |
1080 | * This is an ugly, but unfortunately necessary hack that is | |
1081 | * needed when producing EFI binaries on IA-64. It tells | |
1082 | * elf.c:elf_fake_sections() not to consider ".reloc" as a section | |
1083 | * containing ELF relocation info. We need this hack in order to | |
1084 | * be able to generate ELF binaries that can be translated into | |
1085 | * EFI applications (which are essentially COFF objects). Those | |
bbe66d08 | 1086 | * files contain a COFF ".reloc" section inside an ELFNN object, |
800eeca4 JW |
1087 | * which would normally cause BFD to segfault because it would |
1088 | * attempt to interpret this section as containing relocation | |
1089 | * entries for section "oc". With this hack enabled, ".reloc" | |
1090 | * will be treated as a normal data section, which will avoid the | |
bbe66d08 | 1091 | * segfault. However, you won't be able to create an ELFNN binary |
800eeca4 JW |
1092 | * with a section named "oc" that needs relocations, but that's |
1093 | * the kind of ugly side-effects you get when detecting section | |
1094 | * types based on their names... In practice, this limitation is | |
1095 | * unlikely to bite. | |
1096 | */ | |
1097 | hdr->sh_type = SHT_PROGBITS; | |
1098 | ||
1099 | if (sec->flags & SEC_SMALL_DATA) | |
1100 | hdr->sh_flags |= SHF_IA_64_SHORT; | |
1101 | ||
1102 | return true; | |
1103 | } | |
1104 | ||
81545d45 RH |
1105 | /* The final processing done just before writing out an IA-64 ELF |
1106 | object file. */ | |
1107 | ||
1108 | static void | |
1109 | elfNN_ia64_final_write_processing (abfd, linker) | |
1110 | bfd *abfd; | |
1111 | boolean linker ATTRIBUTE_UNUSED; | |
1112 | { | |
1113 | Elf_Internal_Shdr *hdr; | |
1114 | const char *sname; | |
1115 | asection *text_sect, *s; | |
1116 | size_t len; | |
1117 | ||
1118 | for (s = abfd->sections; s; s = s->next) | |
1119 | { | |
1120 | hdr = &elf_section_data (s)->this_hdr; | |
1121 | switch (hdr->sh_type) | |
1122 | { | |
1123 | case SHT_IA_64_UNWIND: | |
1124 | /* See comments in gas/config/tc-ia64.c:dot_endp on why we | |
1125 | have to do this. */ | |
1126 | sname = bfd_get_section_name (abfd, s); | |
1127 | len = sizeof (ELF_STRING_ia64_unwind) - 1; | |
1128 | if (sname && strncmp (sname, ELF_STRING_ia64_unwind, len) == 0) | |
1129 | { | |
1130 | sname += len; | |
1131 | ||
1132 | if (sname[0] == '\0') | |
1133 | /* .IA_64.unwind -> .text */ | |
1134 | text_sect = bfd_get_section_by_name (abfd, ".text"); | |
1135 | else | |
1136 | /* .IA_64.unwindFOO -> FOO */ | |
1137 | text_sect = bfd_get_section_by_name (abfd, sname); | |
1138 | } | |
579f31ac JJ |
1139 | else if (sname |
1140 | && (len = sizeof (ELF_STRING_ia64_unwind_once) - 1, | |
1141 | strncmp (sname, ELF_STRING_ia64_unwind_once, len)) == 0) | |
1142 | { | |
1143 | /* .gnu.linkonce.ia64unw.FOO -> .gnu.linkonce.t.FOO */ | |
1144 | size_t len2 = sizeof (".gnu.linkonce.t.") - 1; | |
fcf12726 | 1145 | char *once_name = bfd_malloc (len2 + strlen (sname + len) + 1); |
579f31ac | 1146 | |
fcf12726 AM |
1147 | if (once_name != NULL) |
1148 | { | |
1149 | memcpy (once_name, ".gnu.linkonce.t.", len2); | |
1150 | strcpy (once_name + len2, sname + len); | |
1151 | text_sect = bfd_get_section_by_name (abfd, once_name); | |
1152 | free (once_name); | |
1153 | } | |
1154 | else | |
1155 | /* Should only happen if we run out of memory, in | |
1156 | which case we're probably toast anyway. Try to | |
1157 | cope by finding the section the slow way. */ | |
1158 | for (text_sect = abfd->sections; | |
1159 | text_sect != NULL; | |
1160 | text_sect = text_sect->next) | |
1161 | { | |
1162 | if (strncmp (bfd_section_name (abfd, text_sect), | |
1163 | ".gnu.linkonce.t.", len2) == 0 | |
1164 | && strcmp (bfd_section_name (abfd, text_sect) + len2, | |
1165 | sname + len) == 0) | |
1166 | break; | |
1167 | } | |
579f31ac | 1168 | } |
81545d45 RH |
1169 | else |
1170 | /* last resort: fall back on .text */ | |
1171 | text_sect = bfd_get_section_by_name (abfd, ".text"); | |
1172 | ||
1173 | if (text_sect) | |
1174 | { | |
1175 | /* The IA-64 processor-specific ABI requires setting | |
1176 | sh_link to the unwind section, whereas HP-UX requires | |
1177 | sh_info to do so. For maximum compatibility, we'll | |
1178 | set both for now... */ | |
1179 | hdr->sh_link = elf_section_data (text_sect)->this_idx; | |
1180 | hdr->sh_info = elf_section_data (text_sect)->this_idx; | |
1181 | } | |
1182 | break; | |
1183 | } | |
1184 | } | |
1185 | } | |
1186 | ||
800eeca4 JW |
1187 | /* Hook called by the linker routine which adds symbols from an object |
1188 | file. We use it to put .comm items in .sbss, and not .bss. */ | |
1189 | ||
1190 | static boolean | |
bbe66d08 | 1191 | elfNN_ia64_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) |
800eeca4 JW |
1192 | bfd *abfd; |
1193 | struct bfd_link_info *info; | |
1194 | const Elf_Internal_Sym *sym; | |
64bf6ae6 JW |
1195 | const char **namep ATTRIBUTE_UNUSED; |
1196 | flagword *flagsp ATTRIBUTE_UNUSED; | |
800eeca4 JW |
1197 | asection **secp; |
1198 | bfd_vma *valp; | |
1199 | { | |
1200 | if (sym->st_shndx == SHN_COMMON | |
1201 | && !info->relocateable | |
c0846b23 | 1202 | && sym->st_size <= elf_gp_size (abfd)) |
800eeca4 JW |
1203 | { |
1204 | /* Common symbols less than or equal to -G nn bytes are | |
1205 | automatically put into .sbss. */ | |
1206 | ||
1207 | asection *scomm = bfd_get_section_by_name (abfd, ".scommon"); | |
1208 | ||
1209 | if (scomm == NULL) | |
1210 | { | |
1211 | scomm = bfd_make_section (abfd, ".scommon"); | |
1212 | if (scomm == NULL | |
1213 | || !bfd_set_section_flags (abfd, scomm, (SEC_ALLOC | |
1214 | | SEC_IS_COMMON | |
1215 | | SEC_LINKER_CREATED))) | |
1216 | return false; | |
1217 | } | |
1218 | ||
1219 | *secp = scomm; | |
1220 | *valp = sym->st_size; | |
1221 | } | |
1222 | ||
1223 | return true; | |
1224 | } | |
1225 | ||
7b6dab7f TW |
1226 | static boolean |
1227 | elfNN_ia64_aix_vec (const bfd_target *vec) | |
1228 | { | |
1229 | extern const bfd_target bfd_elfNN_ia64_aix_little_vec; | |
1230 | extern const bfd_target bfd_elfNN_ia64_aix_big_vec; | |
1231 | ||
dc810e39 | 1232 | return (/**/vec == & bfd_elfNN_ia64_aix_little_vec |
7b6dab7f TW |
1233 | || vec == & bfd_elfNN_ia64_aix_big_vec); |
1234 | } | |
1235 | ||
1236 | /* Hook called by the linker routine which adds symbols from an object | |
1237 | file. We use it to handle OS-specific symbols. */ | |
1238 | ||
1239 | static boolean | |
1240 | elfNN_ia64_aix_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) | |
1241 | bfd *abfd; | |
1242 | struct bfd_link_info *info; | |
1243 | const Elf_Internal_Sym *sym; | |
1244 | const char **namep; | |
1245 | flagword *flagsp; | |
1246 | asection **secp; | |
1247 | bfd_vma *valp; | |
1248 | { | |
1249 | if (strcmp (*namep, "__GLOB_DATA_PTR") == 0) | |
1250 | { | |
64e9ece0 TW |
1251 | /* Define __GLOB_DATA_PTR when it is encountered. This is expected to |
1252 | be a linker-defined symbol by the Aix C runtime startup code. IBM sez | |
1253 | no one else should use it b/c it is undocumented. */ | |
7b6dab7f TW |
1254 | struct elf_link_hash_entry *h; |
1255 | ||
0a991dfe AM |
1256 | h = elf_link_hash_lookup (elf_hash_table (info), *namep, |
1257 | false, false, false); | |
dc810e39 | 1258 | if (h == NULL) |
7b6dab7f TW |
1259 | { |
1260 | struct elf_backend_data *bed; | |
1261 | struct elfNN_ia64_link_hash_table *ia64_info; | |
1262 | ||
1263 | bed = get_elf_backend_data (abfd); | |
1264 | ia64_info = elfNN_ia64_hash_table (info); | |
dc810e39 | 1265 | |
7b6dab7f | 1266 | if (!(_bfd_generic_link_add_one_symbol |
dc810e39 | 1267 | (info, abfd, *namep, BSF_GLOBAL, |
64e9ece0 | 1268 | bfd_get_section_by_name (abfd, ".bss"), |
7b6dab7f TW |
1269 | bed->got_symbol_offset, (const char *) NULL, false, |
1270 | bed->collect, (struct bfd_link_hash_entry **) &h))) | |
1271 | return false; | |
dc810e39 | 1272 | |
7b6dab7f TW |
1273 | h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; |
1274 | h->type = STT_OBJECT; | |
dc810e39 | 1275 | |
64e9ece0 | 1276 | if (! _bfd_elf_link_record_dynamic_symbol (info, h)) |
7b6dab7f TW |
1277 | return false; |
1278 | } | |
1279 | ||
1280 | return true; | |
1281 | } | |
1282 | else if (sym->st_shndx == SHN_LOOS) | |
1283 | { | |
9ad5cbcf | 1284 | unsigned int i; |
dc810e39 | 1285 | |
10d1e03a TW |
1286 | /* SHN_AIX_SYSCALL: Treat this as any other symbol. The special symbol |
1287 | is only relevant when compiling code for extended system calls. | |
dc810e39 | 1288 | Replace the "special" section with .text, if possible. |
64e9ece0 | 1289 | Note that these symbols are always assumed to be in .text. */ |
9ad5cbcf | 1290 | for (i = 1; i < elf_numsections (abfd); i++) |
7b6dab7f | 1291 | { |
9ad5cbcf | 1292 | asection * sec = bfd_section_from_elf_index (abfd, i); |
dc810e39 | 1293 | |
7b6dab7f TW |
1294 | if (sec && strcmp (sec->name, ".text") == 0) |
1295 | { | |
1296 | *secp = sec; | |
1297 | break; | |
1298 | } | |
1299 | } | |
1300 | ||
7b6dab7f TW |
1301 | if (*secp == NULL) |
1302 | *secp = bfd_abs_section_ptr; | |
dc810e39 | 1303 | |
7b6dab7f | 1304 | *valp = sym->st_size; |
dc810e39 | 1305 | |
7b6dab7f TW |
1306 | return true; |
1307 | } | |
dc810e39 | 1308 | else |
7b6dab7f | 1309 | { |
dc810e39 | 1310 | return elfNN_ia64_add_symbol_hook (abfd, info, sym, |
7b6dab7f TW |
1311 | namep, flagsp, secp, valp); |
1312 | } | |
1313 | } | |
1314 | ||
1315 | boolean | |
1316 | elfNN_ia64_aix_link_add_symbols (abfd, info) | |
1317 | bfd *abfd; | |
1318 | struct bfd_link_info *info; | |
1319 | { | |
1320 | /* Make sure dynamic sections are always created. */ | |
1321 | if (! elf_hash_table (info)->dynamic_sections_created | |
1322 | && abfd->xvec == info->hash->creator) | |
1323 | { | |
1324 | if (! bfd_elfNN_link_create_dynamic_sections (abfd, info)) | |
1325 | return false; | |
1326 | } | |
1327 | ||
1328 | /* Now do the standard call. */ | |
1329 | return bfd_elfNN_bfd_link_add_symbols (abfd, info); | |
1330 | } | |
1331 | ||
800eeca4 JW |
1332 | /* Return the number of additional phdrs we will need. */ |
1333 | ||
1334 | static int | |
bbe66d08 | 1335 | elfNN_ia64_additional_program_headers (abfd) |
800eeca4 JW |
1336 | bfd *abfd; |
1337 | { | |
1338 | asection *s; | |
1339 | int ret = 0; | |
1340 | ||
1341 | /* See if we need a PT_IA_64_ARCHEXT segment. */ | |
1342 | s = bfd_get_section_by_name (abfd, ELF_STRING_ia64_archext); | |
1343 | if (s && (s->flags & SEC_LOAD)) | |
1344 | ++ret; | |
1345 | ||
81545d45 RH |
1346 | /* Count how many PT_IA_64_UNWIND segments we need. */ |
1347 | for (s = abfd->sections; s; s = s->next) | |
d9cf1b54 | 1348 | if (is_unwind_section_name (abfd, s->name) && (s->flags & SEC_LOAD)) |
81545d45 | 1349 | ++ret; |
800eeca4 JW |
1350 | |
1351 | return ret; | |
1352 | } | |
1353 | ||
1354 | static boolean | |
bbe66d08 | 1355 | elfNN_ia64_modify_segment_map (abfd) |
800eeca4 JW |
1356 | bfd *abfd; |
1357 | { | |
1358 | struct elf_segment_map *m, **pm; | |
81545d45 | 1359 | Elf_Internal_Shdr *hdr; |
800eeca4 | 1360 | asection *s; |
d9cf1b54 AM |
1361 | boolean unwind_found; |
1362 | asection *unwind_sec; | |
800eeca4 JW |
1363 | |
1364 | /* If we need a PT_IA_64_ARCHEXT segment, it must come before | |
1365 | all PT_LOAD segments. */ | |
1366 | s = bfd_get_section_by_name (abfd, ELF_STRING_ia64_archext); | |
1367 | if (s && (s->flags & SEC_LOAD)) | |
1368 | { | |
1369 | for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) | |
1370 | if (m->p_type == PT_IA_64_ARCHEXT) | |
1371 | break; | |
1372 | if (m == NULL) | |
1373 | { | |
dc810e39 AM |
1374 | m = ((struct elf_segment_map *) |
1375 | bfd_zalloc (abfd, (bfd_size_type) sizeof *m)); | |
800eeca4 JW |
1376 | if (m == NULL) |
1377 | return false; | |
1378 | ||
1379 | m->p_type = PT_IA_64_ARCHEXT; | |
1380 | m->count = 1; | |
1381 | m->sections[0] = s; | |
1382 | ||
1383 | /* We want to put it after the PHDR and INTERP segments. */ | |
1384 | pm = &elf_tdata (abfd)->segment_map; | |
1385 | while (*pm != NULL | |
1386 | && ((*pm)->p_type == PT_PHDR | |
1387 | || (*pm)->p_type == PT_INTERP)) | |
1388 | pm = &(*pm)->next; | |
1389 | ||
1390 | m->next = *pm; | |
1391 | *pm = m; | |
1392 | } | |
1393 | } | |
1394 | ||
81545d45 RH |
1395 | /* Install PT_IA_64_UNWIND segments, if needed. */ |
1396 | for (s = abfd->sections; s; s = s->next) | |
800eeca4 | 1397 | { |
81545d45 RH |
1398 | hdr = &elf_section_data (s)->this_hdr; |
1399 | if (hdr->sh_type != SHT_IA_64_UNWIND) | |
1400 | continue; | |
1401 | ||
1402 | if (s && (s->flags & SEC_LOAD)) | |
800eeca4 | 1403 | { |
81545d45 | 1404 | for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) |
d9cf1b54 AM |
1405 | if (m->p_type == PT_IA_64_UNWIND) |
1406 | { | |
1407 | /* Look through all sections in the unwind segment | |
1408 | for a match since there may be multiple sections | |
1409 | to a segment. */ | |
1410 | ||
1411 | unwind_sec = m->sections[0]; | |
1412 | unwind_found = false; | |
1413 | while (unwind_sec != NULL && !unwind_found) | |
1414 | { | |
1415 | if (unwind_sec == s) | |
1416 | unwind_found = true; | |
1417 | else | |
1418 | unwind_sec = unwind_sec -> next; | |
1419 | } | |
1420 | if (unwind_found) | |
1421 | break; | |
1422 | } | |
81545d45 | 1423 | |
800eeca4 | 1424 | if (m == NULL) |
81545d45 | 1425 | { |
dc810e39 AM |
1426 | m = ((struct elf_segment_map *) |
1427 | bfd_zalloc (abfd, (bfd_size_type) sizeof *m)); | |
81545d45 RH |
1428 | if (m == NULL) |
1429 | return false; | |
800eeca4 | 1430 | |
81545d45 RH |
1431 | m->p_type = PT_IA_64_UNWIND; |
1432 | m->count = 1; | |
1433 | m->sections[0] = s; | |
1434 | m->next = NULL; | |
800eeca4 | 1435 | |
81545d45 RH |
1436 | /* We want to put it last. */ |
1437 | pm = &elf_tdata (abfd)->segment_map; | |
1438 | while (*pm != NULL) | |
1439 | pm = &(*pm)->next; | |
1440 | *pm = m; | |
1441 | } | |
800eeca4 JW |
1442 | } |
1443 | } | |
1444 | ||
1445 | /* Turn on PF_IA_64_NORECOV if needed. This involves traversing all of | |
1446 | the input sections for each output section in the segment and testing | |
1447 | for SHF_IA_64_NORECOV on each. */ | |
1448 | for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next) | |
1449 | if (m->p_type == PT_LOAD) | |
1450 | { | |
1451 | int i; | |
1452 | for (i = m->count - 1; i >= 0; --i) | |
1453 | { | |
1454 | struct bfd_link_order *order = m->sections[i]->link_order_head; | |
1455 | while (order) | |
1456 | { | |
1457 | if (order->type == bfd_indirect_link_order) | |
1458 | { | |
1459 | asection *is = order->u.indirect.section; | |
1460 | bfd_vma flags = elf_section_data(is)->this_hdr.sh_flags; | |
1461 | if (flags & SHF_IA_64_NORECOV) | |
1462 | { | |
1463 | m->p_flags |= PF_IA_64_NORECOV; | |
1464 | goto found; | |
1465 | } | |
1466 | } | |
1467 | order = order->next; | |
1468 | } | |
1469 | } | |
1470 | found:; | |
1471 | } | |
1472 | ||
1473 | return true; | |
1474 | } | |
1475 | ||
800eeca4 JW |
1476 | /* According to the Tahoe assembler spec, all labels starting with a |
1477 | '.' are local. */ | |
1478 | ||
1479 | static boolean | |
bbe66d08 | 1480 | elfNN_ia64_is_local_label_name (abfd, name) |
64bf6ae6 | 1481 | bfd *abfd ATTRIBUTE_UNUSED; |
800eeca4 JW |
1482 | const char *name; |
1483 | { | |
1484 | return name[0] == '.'; | |
1485 | } | |
1486 | ||
1487 | /* Should we do dynamic things to this symbol? */ | |
1488 | ||
1489 | static boolean | |
bbe66d08 | 1490 | elfNN_ia64_dynamic_symbol_p (h, info) |
800eeca4 JW |
1491 | struct elf_link_hash_entry *h; |
1492 | struct bfd_link_info *info; | |
1493 | { | |
1494 | if (h == NULL) | |
1495 | return false; | |
1496 | ||
1497 | while (h->root.type == bfd_link_hash_indirect | |
1498 | || h->root.type == bfd_link_hash_warning) | |
1499 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
1500 | ||
1501 | if (h->dynindx == -1) | |
1502 | return false; | |
2719f880 L |
1503 | switch (ELF_ST_VISIBILITY (h->other)) |
1504 | { | |
1505 | case STV_INTERNAL: | |
1506 | case STV_HIDDEN: | |
1507 | return false; | |
1508 | } | |
800eeca4 JW |
1509 | |
1510 | if (h->root.type == bfd_link_hash_undefweak | |
1511 | || h->root.type == bfd_link_hash_defweak) | |
1512 | return true; | |
1513 | ||
671bae9c | 1514 | if ((info->shared && (!info->symbolic || info->allow_shlib_undefined)) |
800eeca4 JW |
1515 | || ((h->elf_link_hash_flags |
1516 | & (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR)) | |
1517 | == (ELF_LINK_HASH_DEF_DYNAMIC | ELF_LINK_HASH_REF_REGULAR))) | |
1518 | return true; | |
1519 | ||
1520 | return false; | |
1521 | } | |
1522 | \f | |
1523 | static boolean | |
bbe66d08 JW |
1524 | elfNN_ia64_local_hash_table_init (ht, abfd, new) |
1525 | struct elfNN_ia64_local_hash_table *ht; | |
64bf6ae6 | 1526 | bfd *abfd ATTRIBUTE_UNUSED; |
800eeca4 JW |
1527 | new_hash_entry_func new; |
1528 | { | |
3e932841 | 1529 | memset (ht, 0, sizeof (*ht)); |
800eeca4 JW |
1530 | return bfd_hash_table_init (&ht->root, new); |
1531 | } | |
1532 | ||
1533 | static struct bfd_hash_entry* | |
bbe66d08 | 1534 | elfNN_ia64_new_loc_hash_entry (entry, table, string) |
800eeca4 JW |
1535 | struct bfd_hash_entry *entry; |
1536 | struct bfd_hash_table *table; | |
1537 | const char *string; | |
1538 | { | |
bbe66d08 JW |
1539 | struct elfNN_ia64_local_hash_entry *ret; |
1540 | ret = (struct elfNN_ia64_local_hash_entry *) entry; | |
800eeca4 JW |
1541 | |
1542 | /* Allocate the structure if it has not already been allocated by a | |
1543 | subclass. */ | |
1544 | if (!ret) | |
1545 | ret = bfd_hash_allocate (table, sizeof (*ret)); | |
1546 | ||
1547 | if (!ret) | |
1548 | return 0; | |
1549 | ||
1550 | /* Initialize our local data. All zeros, and definitely easier | |
1551 | than setting a handful of bit fields. */ | |
3e932841 | 1552 | memset (ret, 0, sizeof (*ret)); |
800eeca4 JW |
1553 | |
1554 | /* Call the allocation method of the superclass. */ | |
bbe66d08 | 1555 | ret = ((struct elfNN_ia64_local_hash_entry *) |
800eeca4 JW |
1556 | bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string)); |
1557 | ||
1558 | return (struct bfd_hash_entry *) ret; | |
1559 | } | |
1560 | ||
1561 | static struct bfd_hash_entry* | |
bbe66d08 | 1562 | elfNN_ia64_new_elf_hash_entry (entry, table, string) |
800eeca4 JW |
1563 | struct bfd_hash_entry *entry; |
1564 | struct bfd_hash_table *table; | |
1565 | const char *string; | |
1566 | { | |
bbe66d08 JW |
1567 | struct elfNN_ia64_link_hash_entry *ret; |
1568 | ret = (struct elfNN_ia64_link_hash_entry *) entry; | |
800eeca4 JW |
1569 | |
1570 | /* Allocate the structure if it has not already been allocated by a | |
1571 | subclass. */ | |
1572 | if (!ret) | |
1573 | ret = bfd_hash_allocate (table, sizeof (*ret)); | |
1574 | ||
1575 | if (!ret) | |
1576 | return 0; | |
1577 | ||
1578 | /* Initialize our local data. All zeros, and definitely easier | |
1579 | than setting a handful of bit fields. */ | |
3e932841 | 1580 | memset (ret, 0, sizeof (*ret)); |
800eeca4 JW |
1581 | |
1582 | /* Call the allocation method of the superclass. */ | |
bbe66d08 | 1583 | ret = ((struct elfNN_ia64_link_hash_entry *) |
800eeca4 JW |
1584 | _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret, |
1585 | table, string)); | |
1586 | ||
1587 | return (struct bfd_hash_entry *) ret; | |
1588 | } | |
1589 | ||
1590 | static void | |
bbe66d08 | 1591 | elfNN_ia64_hash_copy_indirect (xdir, xind) |
800eeca4 JW |
1592 | struct elf_link_hash_entry *xdir, *xind; |
1593 | { | |
bbe66d08 | 1594 | struct elfNN_ia64_link_hash_entry *dir, *ind; |
800eeca4 | 1595 | |
57c7194e AM |
1596 | dir = (struct elfNN_ia64_link_hash_entry *) xdir; |
1597 | ind = (struct elfNN_ia64_link_hash_entry *) xind; | |
800eeca4 | 1598 | |
3e932841 | 1599 | /* Copy down any references that we may have already seen to the |
800eeca4 JW |
1600 | symbol which just became indirect. */ |
1601 | ||
1602 | dir->root.elf_link_hash_flags |= | |
1603 | (ind->root.elf_link_hash_flags | |
1604 | & (ELF_LINK_HASH_REF_DYNAMIC | |
1605 | | ELF_LINK_HASH_REF_REGULAR | |
1606 | | ELF_LINK_HASH_REF_REGULAR_NONWEAK)); | |
1607 | ||
1e370bd2 | 1608 | if (ind->root.root.type != bfd_link_hash_indirect) |
0a991dfe AM |
1609 | return; |
1610 | ||
800eeca4 JW |
1611 | /* Copy over the got and plt data. This would have been done |
1612 | by check_relocs. */ | |
1613 | ||
1614 | if (dir->info == NULL) | |
1615 | { | |
bbe66d08 | 1616 | struct elfNN_ia64_dyn_sym_info *dyn_i; |
800eeca4 JW |
1617 | |
1618 | dir->info = dyn_i = ind->info; | |
1619 | ind->info = NULL; | |
1620 | ||
1621 | /* Fix up the dyn_sym_info pointers to the global symbol. */ | |
1622 | for (; dyn_i; dyn_i = dyn_i->next) | |
1623 | dyn_i->h = &dir->root; | |
1624 | } | |
1625 | BFD_ASSERT (ind->info == NULL); | |
1626 | ||
1627 | /* Copy over the dynindx. */ | |
1628 | ||
1629 | if (dir->root.dynindx == -1) | |
1630 | { | |
1631 | dir->root.dynindx = ind->root.dynindx; | |
1632 | dir->root.dynstr_index = ind->root.dynstr_index; | |
1633 | ind->root.dynindx = -1; | |
1634 | ind->root.dynstr_index = 0; | |
1635 | } | |
1636 | BFD_ASSERT (ind->root.dynindx == -1); | |
1637 | } | |
1638 | ||
1639 | static void | |
e5094212 AM |
1640 | elfNN_ia64_hash_hide_symbol (info, xh, force_local) |
1641 | struct bfd_link_info *info; | |
800eeca4 | 1642 | struct elf_link_hash_entry *xh; |
e5094212 | 1643 | boolean force_local; |
800eeca4 | 1644 | { |
bbe66d08 JW |
1645 | struct elfNN_ia64_link_hash_entry *h; |
1646 | struct elfNN_ia64_dyn_sym_info *dyn_i; | |
800eeca4 | 1647 | |
bbe66d08 | 1648 | h = (struct elfNN_ia64_link_hash_entry *)xh; |
800eeca4 | 1649 | |
e5094212 | 1650 | _bfd_elf_link_hash_hide_symbol (info, &h->root, force_local); |
800eeca4 JW |
1651 | |
1652 | for (dyn_i = h->info; dyn_i; dyn_i = dyn_i->next) | |
1653 | dyn_i->want_plt2 = 0; | |
1654 | } | |
1655 | ||
1656 | /* Create the derived linker hash table. The IA-64 ELF port uses this | |
1657 | derived hash table to keep information specific to the IA-64 ElF | |
1658 | linker (without using static variables). */ | |
1659 | ||
1660 | static struct bfd_link_hash_table* | |
bbe66d08 | 1661 | elfNN_ia64_hash_table_create (abfd) |
800eeca4 JW |
1662 | bfd *abfd; |
1663 | { | |
bbe66d08 | 1664 | struct elfNN_ia64_link_hash_table *ret; |
800eeca4 | 1665 | |
dc810e39 | 1666 | ret = bfd_zalloc (abfd, (bfd_size_type) sizeof (*ret)); |
800eeca4 JW |
1667 | if (!ret) |
1668 | return 0; | |
1669 | if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, | |
bbe66d08 | 1670 | elfNN_ia64_new_elf_hash_entry)) |
800eeca4 JW |
1671 | { |
1672 | bfd_release (abfd, ret); | |
1673 | return 0; | |
1674 | } | |
1675 | ||
bbe66d08 JW |
1676 | if (!elfNN_ia64_local_hash_table_init (&ret->loc_hash_table, abfd, |
1677 | elfNN_ia64_new_loc_hash_entry)) | |
800eeca4 JW |
1678 | return 0; |
1679 | return &ret->root.root; | |
1680 | } | |
1681 | ||
1682 | /* Look up an entry in a Alpha ELF linker hash table. */ | |
1683 | ||
bbe66d08 JW |
1684 | static INLINE struct elfNN_ia64_local_hash_entry * |
1685 | elfNN_ia64_local_hash_lookup(table, string, create, copy) | |
1686 | struct elfNN_ia64_local_hash_table *table; | |
800eeca4 JW |
1687 | const char *string; |
1688 | boolean create, copy; | |
1689 | { | |
bbe66d08 | 1690 | return ((struct elfNN_ia64_local_hash_entry *) |
800eeca4 JW |
1691 | bfd_hash_lookup (&table->root, string, create, copy)); |
1692 | } | |
1693 | ||
1694 | /* Traverse both local and global hash tables. */ | |
1695 | ||
bbe66d08 | 1696 | struct elfNN_ia64_dyn_sym_traverse_data |
800eeca4 | 1697 | { |
bbe66d08 | 1698 | boolean (*func) PARAMS ((struct elfNN_ia64_dyn_sym_info *, PTR)); |
800eeca4 JW |
1699 | PTR data; |
1700 | }; | |
1701 | ||
1702 | static boolean | |
bbe66d08 | 1703 | elfNN_ia64_global_dyn_sym_thunk (xentry, xdata) |
800eeca4 JW |
1704 | struct bfd_hash_entry *xentry; |
1705 | PTR xdata; | |
1706 | { | |
bbe66d08 JW |
1707 | struct elfNN_ia64_link_hash_entry *entry |
1708 | = (struct elfNN_ia64_link_hash_entry *) xentry; | |
1709 | struct elfNN_ia64_dyn_sym_traverse_data *data | |
1710 | = (struct elfNN_ia64_dyn_sym_traverse_data *) xdata; | |
1711 | struct elfNN_ia64_dyn_sym_info *dyn_i; | |
800eeca4 | 1712 | |
e92d460e AM |
1713 | if (entry->root.root.type == bfd_link_hash_warning) |
1714 | entry = (struct elfNN_ia64_link_hash_entry *) entry->root.root.u.i.link; | |
1715 | ||
800eeca4 JW |
1716 | for (dyn_i = entry->info; dyn_i; dyn_i = dyn_i->next) |
1717 | if (! (*data->func) (dyn_i, data->data)) | |
1718 | return false; | |
1719 | return true; | |
1720 | } | |
1721 | ||
1722 | static boolean | |
bbe66d08 | 1723 | elfNN_ia64_local_dyn_sym_thunk (xentry, xdata) |
800eeca4 JW |
1724 | struct bfd_hash_entry *xentry; |
1725 | PTR xdata; | |
1726 | { | |
bbe66d08 JW |
1727 | struct elfNN_ia64_local_hash_entry *entry |
1728 | = (struct elfNN_ia64_local_hash_entry *) xentry; | |
1729 | struct elfNN_ia64_dyn_sym_traverse_data *data | |
1730 | = (struct elfNN_ia64_dyn_sym_traverse_data *) xdata; | |
1731 | struct elfNN_ia64_dyn_sym_info *dyn_i; | |
800eeca4 JW |
1732 | |
1733 | for (dyn_i = entry->info; dyn_i; dyn_i = dyn_i->next) | |
1734 | if (! (*data->func) (dyn_i, data->data)) | |
1735 | return false; | |
1736 | return true; | |
1737 | } | |
1738 | ||
1739 | static void | |
bbe66d08 JW |
1740 | elfNN_ia64_dyn_sym_traverse (ia64_info, func, data) |
1741 | struct elfNN_ia64_link_hash_table *ia64_info; | |
1742 | boolean (*func) PARAMS ((struct elfNN_ia64_dyn_sym_info *, PTR)); | |
800eeca4 JW |
1743 | PTR data; |
1744 | { | |
bbe66d08 | 1745 | struct elfNN_ia64_dyn_sym_traverse_data xdata; |
800eeca4 JW |
1746 | |
1747 | xdata.func = func; | |
1748 | xdata.data = data; | |
1749 | ||
1750 | elf_link_hash_traverse (&ia64_info->root, | |
bbe66d08 | 1751 | elfNN_ia64_global_dyn_sym_thunk, &xdata); |
800eeca4 | 1752 | bfd_hash_traverse (&ia64_info->loc_hash_table.root, |
bbe66d08 | 1753 | elfNN_ia64_local_dyn_sym_thunk, &xdata); |
800eeca4 JW |
1754 | } |
1755 | \f | |
1756 | static boolean | |
bbe66d08 | 1757 | elfNN_ia64_create_dynamic_sections (abfd, info) |
800eeca4 JW |
1758 | bfd *abfd; |
1759 | struct bfd_link_info *info; | |
1760 | { | |
bbe66d08 | 1761 | struct elfNN_ia64_link_hash_table *ia64_info; |
800eeca4 JW |
1762 | asection *s; |
1763 | ||
1764 | if (! _bfd_elf_create_dynamic_sections (abfd, info)) | |
1765 | return false; | |
1766 | ||
bbe66d08 | 1767 | ia64_info = elfNN_ia64_hash_table (info); |
800eeca4 JW |
1768 | |
1769 | ia64_info->plt_sec = bfd_get_section_by_name (abfd, ".plt"); | |
1770 | ia64_info->got_sec = bfd_get_section_by_name (abfd, ".got"); | |
1771 | ||
1772 | { | |
1773 | flagword flags = bfd_get_section_flags (abfd, ia64_info->got_sec); | |
1774 | bfd_set_section_flags (abfd, ia64_info->got_sec, SEC_SMALL_DATA | flags); | |
1775 | } | |
1776 | ||
1777 | if (!get_pltoff (abfd, info, ia64_info)) | |
1778 | return false; | |
1779 | ||
1780 | s = bfd_make_section(abfd, ".rela.IA_64.pltoff"); | |
1781 | if (s == NULL | |
1782 | || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD | |
1783 | | SEC_HAS_CONTENTS | |
1784 | | SEC_IN_MEMORY | |
1785 | | SEC_LINKER_CREATED | |
1786 | | SEC_READONLY)) | |
1787 | || !bfd_set_section_alignment (abfd, s, 3)) | |
1788 | return false; | |
1789 | ia64_info->rel_pltoff_sec = s; | |
1790 | ||
1791 | s = bfd_make_section(abfd, ".rela.got"); | |
1792 | if (s == NULL | |
1793 | || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD | |
1794 | | SEC_HAS_CONTENTS | |
1795 | | SEC_IN_MEMORY | |
1796 | | SEC_LINKER_CREATED | |
1797 | | SEC_READONLY)) | |
1798 | || !bfd_set_section_alignment (abfd, s, 3)) | |
1799 | return false; | |
1800 | ia64_info->rel_got_sec = s; | |
1801 | ||
1802 | return true; | |
1803 | } | |
1804 | ||
f7460f5f JJ |
1805 | /* Find and/or create a hash entry for local symbol. */ |
1806 | static struct elfNN_ia64_local_hash_entry * | |
1807 | get_local_sym_hash (ia64_info, abfd, rel, create) | |
1808 | struct elfNN_ia64_link_hash_table *ia64_info; | |
1809 | bfd *abfd; | |
1810 | const Elf_Internal_Rela *rel; | |
1811 | boolean create; | |
1812 | { | |
1813 | char *addr_name; | |
1814 | size_t len; | |
fcf12726 | 1815 | struct elfNN_ia64_local_hash_entry *ret; |
f7460f5f JJ |
1816 | |
1817 | /* Construct a string for use in the elfNN_ia64_local_hash_table. | |
1818 | name describes what was once anonymous memory. */ | |
1819 | ||
1820 | len = sizeof (void*)*2 + 1 + sizeof (bfd_vma)*4 + 1 + 1; | |
1821 | len += 10; /* %p slop */ | |
1822 | ||
fcf12726 AM |
1823 | addr_name = bfd_malloc (len); |
1824 | if (addr_name == NULL) | |
1825 | return 0; | |
f7460f5f JJ |
1826 | sprintf (addr_name, "%p:%lx", |
1827 | (void *) abfd, (unsigned long) ELFNN_R_SYM (rel->r_info)); | |
1828 | ||
1829 | /* Collect the canonical entry data for this address. */ | |
fcf12726 AM |
1830 | ret = elfNN_ia64_local_hash_lookup (&ia64_info->loc_hash_table, |
1831 | addr_name, create, create); | |
1832 | free (addr_name); | |
1833 | return ret; | |
f7460f5f JJ |
1834 | } |
1835 | ||
800eeca4 JW |
1836 | /* Find and/or create a descriptor for dynamic symbol info. This will |
1837 | vary based on global or local symbol, and the addend to the reloc. */ | |
1838 | ||
bbe66d08 | 1839 | static struct elfNN_ia64_dyn_sym_info * |
800eeca4 | 1840 | get_dyn_sym_info (ia64_info, h, abfd, rel, create) |
bbe66d08 | 1841 | struct elfNN_ia64_link_hash_table *ia64_info; |
800eeca4 JW |
1842 | struct elf_link_hash_entry *h; |
1843 | bfd *abfd; | |
1844 | const Elf_Internal_Rela *rel; | |
1845 | boolean create; | |
1846 | { | |
bbe66d08 JW |
1847 | struct elfNN_ia64_dyn_sym_info **pp; |
1848 | struct elfNN_ia64_dyn_sym_info *dyn_i; | |
800eeca4 | 1849 | bfd_vma addend = rel ? rel->r_addend : 0; |
3e932841 | 1850 | |
800eeca4 | 1851 | if (h) |
bbe66d08 | 1852 | pp = &((struct elfNN_ia64_link_hash_entry *)h)->info; |
800eeca4 JW |
1853 | else |
1854 | { | |
bbe66d08 | 1855 | struct elfNN_ia64_local_hash_entry *loc_h; |
800eeca4 | 1856 | |
f7460f5f | 1857 | loc_h = get_local_sym_hash (ia64_info, abfd, rel, create); |
800eeca4 JW |
1858 | BFD_ASSERT (loc_h); |
1859 | ||
1860 | pp = &loc_h->info; | |
3e932841 | 1861 | } |
800eeca4 JW |
1862 | |
1863 | for (dyn_i = *pp; dyn_i && dyn_i->addend != addend; dyn_i = *pp) | |
1864 | pp = &dyn_i->next; | |
1865 | ||
1866 | if (dyn_i == NULL && create) | |
1867 | { | |
dc810e39 AM |
1868 | dyn_i = ((struct elfNN_ia64_dyn_sym_info *) |
1869 | bfd_zalloc (abfd, (bfd_size_type) sizeof *dyn_i)); | |
800eeca4 JW |
1870 | *pp = dyn_i; |
1871 | dyn_i->addend = addend; | |
1872 | } | |
1873 | ||
1874 | return dyn_i; | |
1875 | } | |
1876 | ||
1877 | static asection * | |
1878 | get_got (abfd, info, ia64_info) | |
1879 | bfd *abfd; | |
1880 | struct bfd_link_info *info; | |
bbe66d08 | 1881 | struct elfNN_ia64_link_hash_table *ia64_info; |
800eeca4 | 1882 | { |
64bf6ae6 | 1883 | asection *got; |
800eeca4 JW |
1884 | bfd *dynobj; |
1885 | ||
1886 | got = ia64_info->got_sec; | |
1887 | if (!got) | |
1888 | { | |
1889 | flagword flags; | |
1890 | ||
1891 | dynobj = ia64_info->root.dynobj; | |
1892 | if (!dynobj) | |
1893 | ia64_info->root.dynobj = dynobj = abfd; | |
1894 | if (!_bfd_elf_create_got_section (dynobj, info)) | |
1895 | return 0; | |
1896 | ||
1897 | got = bfd_get_section_by_name (dynobj, ".got"); | |
1898 | BFD_ASSERT (got); | |
1899 | ia64_info->got_sec = got; | |
1900 | ||
1901 | flags = bfd_get_section_flags (abfd, got); | |
1902 | bfd_set_section_flags (abfd, got, SEC_SMALL_DATA | flags); | |
1903 | } | |
1904 | ||
1905 | return got; | |
1906 | } | |
1907 | ||
1908 | /* Create function descriptor section (.opd). This section is called .opd | |
1909 | because it contains "official prodecure descriptors". The "official" | |
1910 | refers to the fact that these descriptors are used when taking the address | |
1911 | of a procedure, thus ensuring a unique address for each procedure. */ | |
1912 | ||
1913 | static asection * | |
1914 | get_fptr (abfd, info, ia64_info) | |
1915 | bfd *abfd; | |
64bf6ae6 | 1916 | struct bfd_link_info *info ATTRIBUTE_UNUSED; |
bbe66d08 | 1917 | struct elfNN_ia64_link_hash_table *ia64_info; |
800eeca4 JW |
1918 | { |
1919 | asection *fptr; | |
1920 | bfd *dynobj; | |
1921 | ||
1922 | fptr = ia64_info->fptr_sec; | |
1923 | if (!fptr) | |
1924 | { | |
1925 | dynobj = ia64_info->root.dynobj; | |
1926 | if (!dynobj) | |
1927 | ia64_info->root.dynobj = dynobj = abfd; | |
1928 | ||
1929 | fptr = bfd_make_section (dynobj, ".opd"); | |
1930 | if (!fptr | |
1931 | || !bfd_set_section_flags (dynobj, fptr, | |
1932 | (SEC_ALLOC | |
1933 | | SEC_LOAD | |
1934 | | SEC_HAS_CONTENTS | |
1935 | | SEC_IN_MEMORY | |
1936 | | SEC_READONLY | |
1937 | | SEC_LINKER_CREATED)) | |
1938 | || !bfd_set_section_alignment (abfd, fptr, 4)) | |
1939 | { | |
1940 | BFD_ASSERT (0); | |
1941 | return NULL; | |
1942 | } | |
1943 | ||
1944 | ia64_info->fptr_sec = fptr; | |
1945 | } | |
1946 | ||
1947 | return fptr; | |
1948 | } | |
1949 | ||
1950 | static asection * | |
1951 | get_pltoff (abfd, info, ia64_info) | |
1952 | bfd *abfd; | |
64bf6ae6 | 1953 | struct bfd_link_info *info ATTRIBUTE_UNUSED; |
bbe66d08 | 1954 | struct elfNN_ia64_link_hash_table *ia64_info; |
800eeca4 JW |
1955 | { |
1956 | asection *pltoff; | |
1957 | bfd *dynobj; | |
1958 | ||
1959 | pltoff = ia64_info->pltoff_sec; | |
1960 | if (!pltoff) | |
1961 | { | |
1962 | dynobj = ia64_info->root.dynobj; | |
1963 | if (!dynobj) | |
1964 | ia64_info->root.dynobj = dynobj = abfd; | |
1965 | ||
1966 | pltoff = bfd_make_section (dynobj, ELF_STRING_ia64_pltoff); | |
1967 | if (!pltoff | |
1968 | || !bfd_set_section_flags (dynobj, pltoff, | |
1969 | (SEC_ALLOC | |
1970 | | SEC_LOAD | |
1971 | | SEC_HAS_CONTENTS | |
1972 | | SEC_IN_MEMORY | |
1973 | | SEC_SMALL_DATA | |
1974 | | SEC_LINKER_CREATED)) | |
1975 | || !bfd_set_section_alignment (abfd, pltoff, 4)) | |
1976 | { | |
1977 | BFD_ASSERT (0); | |
1978 | return NULL; | |
1979 | } | |
1980 | ||
1981 | ia64_info->pltoff_sec = pltoff; | |
1982 | } | |
1983 | ||
1984 | return pltoff; | |
1985 | } | |
1986 | ||
1987 | static asection * | |
1988 | get_reloc_section (abfd, ia64_info, sec, create) | |
1989 | bfd *abfd; | |
bbe66d08 | 1990 | struct elfNN_ia64_link_hash_table *ia64_info; |
800eeca4 JW |
1991 | asection *sec; |
1992 | boolean create; | |
1993 | { | |
1994 | const char *srel_name; | |
1995 | asection *srel; | |
1996 | bfd *dynobj; | |
1997 | ||
1998 | srel_name = (bfd_elf_string_from_elf_section | |
1999 | (abfd, elf_elfheader(abfd)->e_shstrndx, | |
2000 | elf_section_data(sec)->rel_hdr.sh_name)); | |
2001 | if (srel_name == NULL) | |
2002 | return NULL; | |
2003 | ||
2004 | BFD_ASSERT ((strncmp (srel_name, ".rela", 5) == 0 | |
2005 | && strcmp (bfd_get_section_name (abfd, sec), | |
2006 | srel_name+5) == 0) | |
2007 | || (strncmp (srel_name, ".rel", 4) == 0 | |
2008 | && strcmp (bfd_get_section_name (abfd, sec), | |
2009 | srel_name+4) == 0)); | |
2010 | ||
2011 | dynobj = ia64_info->root.dynobj; | |
2012 | if (!dynobj) | |
2013 | ia64_info->root.dynobj = dynobj = abfd; | |
2014 | ||
2015 | srel = bfd_get_section_by_name (dynobj, srel_name); | |
2016 | if (srel == NULL && create) | |
2017 | { | |
2018 | srel = bfd_make_section (dynobj, srel_name); | |
2019 | if (srel == NULL | |
2020 | || !bfd_set_section_flags (dynobj, srel, | |
2021 | (SEC_ALLOC | |
2022 | | SEC_LOAD | |
2023 | | SEC_HAS_CONTENTS | |
2024 | | SEC_IN_MEMORY | |
2025 | | SEC_LINKER_CREATED | |
2026 | | SEC_READONLY)) | |
2027 | || !bfd_set_section_alignment (dynobj, srel, 3)) | |
2028 | return NULL; | |
2029 | } | |
2030 | ||
db6751f2 JJ |
2031 | if (sec->flags & SEC_READONLY) |
2032 | ia64_info->reltext = 1; | |
2033 | ||
800eeca4 JW |
2034 | return srel; |
2035 | } | |
2036 | ||
2037 | static boolean | |
2038 | count_dyn_reloc (abfd, dyn_i, srel, type) | |
2039 | bfd *abfd; | |
bbe66d08 | 2040 | struct elfNN_ia64_dyn_sym_info *dyn_i; |
800eeca4 JW |
2041 | asection *srel; |
2042 | int type; | |
2043 | { | |
bbe66d08 | 2044 | struct elfNN_ia64_dyn_reloc_entry *rent; |
800eeca4 JW |
2045 | |
2046 | for (rent = dyn_i->reloc_entries; rent; rent = rent->next) | |
2047 | if (rent->srel == srel && rent->type == type) | |
2048 | break; | |
2049 | ||
2050 | if (!rent) | |
2051 | { | |
dc810e39 AM |
2052 | rent = ((struct elfNN_ia64_dyn_reloc_entry *) |
2053 | bfd_alloc (abfd, (bfd_size_type) sizeof (*rent))); | |
800eeca4 JW |
2054 | if (!rent) |
2055 | return false; | |
2056 | ||
2057 | rent->next = dyn_i->reloc_entries; | |
2058 | rent->srel = srel; | |
2059 | rent->type = type; | |
2060 | rent->count = 0; | |
2061 | dyn_i->reloc_entries = rent; | |
2062 | } | |
2063 | rent->count++; | |
2064 | ||
2065 | return true; | |
2066 | } | |
2067 | ||
2068 | static boolean | |
bbe66d08 | 2069 | elfNN_ia64_check_relocs (abfd, info, sec, relocs) |
800eeca4 JW |
2070 | bfd *abfd; |
2071 | struct bfd_link_info *info; | |
2072 | asection *sec; | |
2073 | const Elf_Internal_Rela *relocs; | |
2074 | { | |
bbe66d08 | 2075 | struct elfNN_ia64_link_hash_table *ia64_info; |
800eeca4 JW |
2076 | const Elf_Internal_Rela *relend; |
2077 | Elf_Internal_Shdr *symtab_hdr; | |
2078 | const Elf_Internal_Rela *rel; | |
2079 | asection *got, *fptr, *srel; | |
2080 | ||
2081 | if (info->relocateable) | |
2082 | return true; | |
2083 | ||
2084 | symtab_hdr = &elf_tdata (abfd)->symtab_hdr; | |
bbe66d08 | 2085 | ia64_info = elfNN_ia64_hash_table (info); |
800eeca4 JW |
2086 | |
2087 | got = fptr = srel = NULL; | |
2088 | ||
2089 | relend = relocs + sec->reloc_count; | |
2090 | for (rel = relocs; rel < relend; ++rel) | |
2091 | { | |
2092 | enum { | |
2093 | NEED_GOT = 1, | |
2094 | NEED_FPTR = 2, | |
2095 | NEED_PLTOFF = 4, | |
2096 | NEED_MIN_PLT = 8, | |
2097 | NEED_FULL_PLT = 16, | |
2098 | NEED_DYNREL = 32, | |
2099 | NEED_LTOFF_FPTR = 64, | |
2100 | }; | |
2101 | ||
2102 | struct elf_link_hash_entry *h = NULL; | |
bbe66d08 JW |
2103 | unsigned long r_symndx = ELFNN_R_SYM (rel->r_info); |
2104 | struct elfNN_ia64_dyn_sym_info *dyn_i; | |
800eeca4 JW |
2105 | int need_entry; |
2106 | boolean maybe_dynamic; | |
64bf6ae6 | 2107 | int dynrel_type = R_IA64_NONE; |
800eeca4 JW |
2108 | |
2109 | if (r_symndx >= symtab_hdr->sh_info) | |
2110 | { | |
2111 | /* We're dealing with a global symbol -- find its hash entry | |
2112 | and mark it as being referenced. */ | |
2113 | long indx = r_symndx - symtab_hdr->sh_info; | |
2114 | h = elf_sym_hashes (abfd)[indx]; | |
2115 | while (h->root.type == bfd_link_hash_indirect | |
2116 | || h->root.type == bfd_link_hash_warning) | |
2117 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
2118 | ||
2119 | h->elf_link_hash_flags |= ELF_LINK_HASH_REF_REGULAR; | |
2120 | } | |
2121 | ||
2122 | /* We can only get preliminary data on whether a symbol is | |
2123 | locally or externally defined, as not all of the input files | |
2124 | have yet been processed. Do something with what we know, as | |
2125 | this may help reduce memory usage and processing time later. */ | |
2126 | maybe_dynamic = false; | |
671bae9c NC |
2127 | if (h && ((info->shared |
2128 | && (!info->symbolic || info->allow_shlib_undefined)) | |
800eeca4 | 2129 | || ! (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) |
7b6dab7f TW |
2130 | || h->root.type == bfd_link_hash_defweak |
2131 | || elfNN_ia64_aix_vec (abfd->xvec))) | |
800eeca4 JW |
2132 | maybe_dynamic = true; |
2133 | ||
2134 | need_entry = 0; | |
bbe66d08 | 2135 | switch (ELFNN_R_TYPE (rel->r_info)) |
800eeca4 JW |
2136 | { |
2137 | case R_IA64_TPREL22: | |
2138 | case R_IA64_TPREL64MSB: | |
2139 | case R_IA64_TPREL64LSB: | |
2140 | case R_IA64_LTOFF_TP22: | |
2141 | return false; | |
2142 | ||
2143 | case R_IA64_LTOFF_FPTR22: | |
2144 | case R_IA64_LTOFF_FPTR64I: | |
a4bd8390 JW |
2145 | case R_IA64_LTOFF_FPTR32MSB: |
2146 | case R_IA64_LTOFF_FPTR32LSB: | |
800eeca4 JW |
2147 | case R_IA64_LTOFF_FPTR64MSB: |
2148 | case R_IA64_LTOFF_FPTR64LSB: | |
2149 | need_entry = NEED_FPTR | NEED_GOT | NEED_LTOFF_FPTR; | |
2150 | break; | |
2151 | ||
2152 | case R_IA64_FPTR64I: | |
2153 | case R_IA64_FPTR32MSB: | |
2154 | case R_IA64_FPTR32LSB: | |
2155 | case R_IA64_FPTR64MSB: | |
2156 | case R_IA64_FPTR64LSB: | |
64e9ece0 | 2157 | if (info->shared || h || elfNN_ia64_aix_vec (abfd->xvec)) |
800eeca4 JW |
2158 | need_entry = NEED_FPTR | NEED_DYNREL; |
2159 | else | |
2160 | need_entry = NEED_FPTR; | |
2161 | dynrel_type = R_IA64_FPTR64LSB; | |
2162 | break; | |
2163 | ||
2164 | case R_IA64_LTOFF22: | |
2165 | case R_IA64_LTOFF22X: | |
2166 | case R_IA64_LTOFF64I: | |
2167 | need_entry = NEED_GOT; | |
2168 | break; | |
2169 | ||
2170 | case R_IA64_PLTOFF22: | |
2171 | case R_IA64_PLTOFF64I: | |
2172 | case R_IA64_PLTOFF64MSB: | |
2173 | case R_IA64_PLTOFF64LSB: | |
2174 | need_entry = NEED_PLTOFF; | |
2175 | if (h) | |
2176 | { | |
2177 | if (maybe_dynamic) | |
2178 | need_entry |= NEED_MIN_PLT; | |
2179 | } | |
2180 | else | |
2181 | { | |
2182 | (*info->callbacks->warning) | |
2183 | (info, _("@pltoff reloc against local symbol"), 0, | |
dc810e39 | 2184 | abfd, 0, (bfd_vma) 0); |
800eeca4 JW |
2185 | } |
2186 | break; | |
2187 | ||
2188 | case R_IA64_PCREL21B: | |
748abff6 | 2189 | case R_IA64_PCREL60B: |
800eeca4 JW |
2190 | /* Depending on where this symbol is defined, we may or may not |
2191 | need a full plt entry. Only skip if we know we'll not need | |
2192 | the entry -- static or symbolic, and the symbol definition | |
2193 | has already been seen. */ | |
2194 | if (maybe_dynamic && rel->r_addend == 0) | |
2195 | need_entry = NEED_FULL_PLT; | |
2196 | break; | |
2197 | ||
2198 | case R_IA64_IMM14: | |
2199 | case R_IA64_IMM22: | |
2200 | case R_IA64_IMM64: | |
2201 | case R_IA64_DIR32MSB: | |
2202 | case R_IA64_DIR32LSB: | |
2203 | case R_IA64_DIR64MSB: | |
2204 | case R_IA64_DIR64LSB: | |
2205 | /* Shared objects will always need at least a REL relocation. */ | |
7b6dab7f | 2206 | if (info->shared || maybe_dynamic |
7b6dab7f | 2207 | || (elfNN_ia64_aix_vec (abfd->xvec) |
64e9ece0 | 2208 | && (!h || strcmp (h->root.root.string, |
7b6dab7f | 2209 | "__GLOB_DATA_PTR") != 0))) |
800eeca4 JW |
2210 | need_entry = NEED_DYNREL; |
2211 | dynrel_type = R_IA64_DIR64LSB; | |
2212 | break; | |
2213 | ||
18b27f17 RH |
2214 | case R_IA64_IPLTMSB: |
2215 | case R_IA64_IPLTLSB: | |
2216 | /* Shared objects will always need at least a REL relocation. */ | |
2217 | if (info->shared || maybe_dynamic) | |
2218 | need_entry = NEED_DYNREL; | |
2219 | dynrel_type = R_IA64_IPLTLSB; | |
2220 | break; | |
2221 | ||
748abff6 RH |
2222 | case R_IA64_PCREL22: |
2223 | case R_IA64_PCREL64I: | |
800eeca4 JW |
2224 | case R_IA64_PCREL32MSB: |
2225 | case R_IA64_PCREL32LSB: | |
2226 | case R_IA64_PCREL64MSB: | |
2227 | case R_IA64_PCREL64LSB: | |
2228 | if (maybe_dynamic) | |
2229 | need_entry = NEED_DYNREL; | |
2230 | dynrel_type = R_IA64_PCREL64LSB; | |
2231 | break; | |
2232 | } | |
2233 | ||
2234 | if (!need_entry) | |
2235 | continue; | |
2236 | ||
2237 | if ((need_entry & NEED_FPTR) != 0 | |
2238 | && rel->r_addend) | |
2239 | { | |
2240 | (*info->callbacks->warning) | |
2241 | (info, _("non-zero addend in @fptr reloc"), 0, | |
dc810e39 | 2242 | abfd, 0, (bfd_vma) 0); |
800eeca4 JW |
2243 | } |
2244 | ||
2245 | dyn_i = get_dyn_sym_info (ia64_info, h, abfd, rel, true); | |
2246 | ||
2247 | /* Record whether or not this is a local symbol. */ | |
2248 | dyn_i->h = h; | |
2249 | ||
2250 | /* Create what's needed. */ | |
2251 | if (need_entry & NEED_GOT) | |
2252 | { | |
2253 | if (!got) | |
2254 | { | |
2255 | got = get_got (abfd, info, ia64_info); | |
2256 | if (!got) | |
2257 | return false; | |
2258 | } | |
2259 | dyn_i->want_got = 1; | |
2260 | } | |
2261 | if (need_entry & NEED_FPTR) | |
2262 | { | |
2263 | if (!fptr) | |
2264 | { | |
2265 | fptr = get_fptr (abfd, info, ia64_info); | |
2266 | if (!fptr) | |
2267 | return false; | |
2268 | } | |
2269 | ||
2270 | /* FPTRs for shared libraries are allocated by the dynamic | |
2271 | linker. Make sure this local symbol will appear in the | |
2272 | dynamic symbol table. */ | |
7b6dab7f TW |
2273 | if (!h && (info->shared |
2274 | /* AIX also needs one */ | |
2275 | || elfNN_ia64_aix_vec (abfd->xvec))) | |
800eeca4 | 2276 | { |
bbe66d08 | 2277 | if (! (_bfd_elfNN_link_record_local_dynamic_symbol |
dc810e39 | 2278 | (info, abfd, (long) r_symndx))) |
800eeca4 JW |
2279 | return false; |
2280 | } | |
2281 | ||
2282 | dyn_i->want_fptr = 1; | |
2283 | } | |
2284 | if (need_entry & NEED_LTOFF_FPTR) | |
2285 | dyn_i->want_ltoff_fptr = 1; | |
2286 | if (need_entry & (NEED_MIN_PLT | NEED_FULL_PLT)) | |
2287 | { | |
2288 | if (!ia64_info->root.dynobj) | |
2289 | ia64_info->root.dynobj = abfd; | |
2290 | h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; | |
2291 | dyn_i->want_plt = 1; | |
2292 | } | |
2293 | if (need_entry & NEED_FULL_PLT) | |
2294 | dyn_i->want_plt2 = 1; | |
2295 | if (need_entry & NEED_PLTOFF) | |
2296 | dyn_i->want_pltoff = 1; | |
2297 | if ((need_entry & NEED_DYNREL) && (sec->flags & SEC_ALLOC)) | |
2298 | { | |
2299 | if (!srel) | |
2300 | { | |
2301 | srel = get_reloc_section (abfd, ia64_info, sec, true); | |
2302 | if (!srel) | |
2303 | return false; | |
2304 | } | |
2305 | if (!count_dyn_reloc (abfd, dyn_i, srel, dynrel_type)) | |
2306 | return false; | |
2307 | } | |
2308 | } | |
2309 | ||
2310 | return true; | |
2311 | } | |
2312 | ||
bbe66d08 | 2313 | struct elfNN_ia64_allocate_data |
800eeca4 JW |
2314 | { |
2315 | struct bfd_link_info *info; | |
2316 | bfd_size_type ofs; | |
2317 | }; | |
2318 | ||
2319 | /* For cleanliness, and potentially faster dynamic loading, allocate | |
2320 | external GOT entries first. */ | |
2321 | ||
2322 | static boolean | |
2323 | allocate_global_data_got (dyn_i, data) | |
bbe66d08 | 2324 | struct elfNN_ia64_dyn_sym_info *dyn_i; |
800eeca4 JW |
2325 | PTR data; |
2326 | { | |
bbe66d08 | 2327 | struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data; |
800eeca4 JW |
2328 | |
2329 | if (dyn_i->want_got | |
2330 | && ! dyn_i->want_fptr | |
7b6dab7f | 2331 | && (elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info) |
64e9ece0 TW |
2332 | || (elfNN_ia64_aix_vec (x->info->hash->creator) |
2333 | && (!dyn_i->h || strcmp (dyn_i->h->root.root.string, | |
2334 | "__GLOB_DATA_PTR") != 0)))) | |
800eeca4 JW |
2335 | { |
2336 | dyn_i->got_offset = x->ofs; | |
2337 | x->ofs += 8; | |
2338 | } | |
2339 | return true; | |
2340 | } | |
2341 | ||
2342 | /* Next, allocate all the GOT entries used by LTOFF_FPTR relocs. */ | |
2343 | ||
2344 | static boolean | |
2345 | allocate_global_fptr_got (dyn_i, data) | |
bbe66d08 | 2346 | struct elfNN_ia64_dyn_sym_info *dyn_i; |
800eeca4 JW |
2347 | PTR data; |
2348 | { | |
bbe66d08 | 2349 | struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data; |
800eeca4 JW |
2350 | |
2351 | if (dyn_i->want_got | |
2352 | && dyn_i->want_fptr | |
7b6dab7f TW |
2353 | && (elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info) |
2354 | || elfNN_ia64_aix_vec (x->info->hash->creator))) | |
800eeca4 JW |
2355 | { |
2356 | dyn_i->got_offset = x->ofs; | |
2357 | x->ofs += 8; | |
2358 | } | |
2359 | return true; | |
2360 | } | |
2361 | ||
2362 | /* Lastly, allocate all the GOT entries for local data. */ | |
2363 | ||
2364 | static boolean | |
2365 | allocate_local_got (dyn_i, data) | |
bbe66d08 | 2366 | struct elfNN_ia64_dyn_sym_info *dyn_i; |
800eeca4 JW |
2367 | PTR data; |
2368 | { | |
bbe66d08 | 2369 | struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data; |
800eeca4 JW |
2370 | |
2371 | if (dyn_i->want_got | |
7b6dab7f TW |
2372 | && ! (elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info) |
2373 | || elfNN_ia64_aix_vec (x->info->hash->creator))) | |
800eeca4 JW |
2374 | { |
2375 | dyn_i->got_offset = x->ofs; | |
2376 | x->ofs += 8; | |
2377 | } | |
2378 | return true; | |
2379 | } | |
2380 | ||
2381 | /* Search for the index of a global symbol in it's defining object file. */ | |
2382 | ||
dc810e39 | 2383 | static long |
800eeca4 JW |
2384 | global_sym_index (h) |
2385 | struct elf_link_hash_entry *h; | |
2386 | { | |
2387 | struct elf_link_hash_entry **p; | |
2388 | bfd *obj; | |
2389 | ||
2390 | BFD_ASSERT (h->root.type == bfd_link_hash_defined | |
2391 | || h->root.type == bfd_link_hash_defweak); | |
2392 | ||
2393 | obj = h->root.u.def.section->owner; | |
2394 | for (p = elf_sym_hashes (obj); *p != h; ++p) | |
2395 | continue; | |
2396 | ||
2397 | return p - elf_sym_hashes (obj) + elf_tdata (obj)->symtab_hdr.sh_info; | |
2398 | } | |
2399 | ||
2400 | /* Allocate function descriptors. We can do these for every function | |
2401 | in a main executable that is not exported. */ | |
2402 | ||
2403 | static boolean | |
2404 | allocate_fptr (dyn_i, data) | |
bbe66d08 | 2405 | struct elfNN_ia64_dyn_sym_info *dyn_i; |
800eeca4 JW |
2406 | PTR data; |
2407 | { | |
bbe66d08 | 2408 | struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data; |
800eeca4 JW |
2409 | |
2410 | if (dyn_i->want_fptr) | |
2411 | { | |
2412 | struct elf_link_hash_entry *h = dyn_i->h; | |
3e932841 | 2413 | |
800eeca4 JW |
2414 | if (h) |
2415 | while (h->root.type == bfd_link_hash_indirect | |
2416 | || h->root.type == bfd_link_hash_warning) | |
2417 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
2418 | ||
7b6dab7f TW |
2419 | if (x->info->shared |
2420 | /* AIX needs an FPTR in this case. */ | |
2421 | || (elfNN_ia64_aix_vec (x->info->hash->creator) | |
2422 | && (!h | |
2423 | || h->root.type == bfd_link_hash_defined | |
2424 | || h->root.type == bfd_link_hash_defweak))) | |
800eeca4 JW |
2425 | { |
2426 | if (h && h->dynindx == -1) | |
2427 | { | |
2428 | BFD_ASSERT ((h->root.type == bfd_link_hash_defined) | |
2429 | || (h->root.type == bfd_link_hash_defweak)); | |
2430 | ||
bbe66d08 | 2431 | if (!_bfd_elfNN_link_record_local_dynamic_symbol |
800eeca4 JW |
2432 | (x->info, h->root.u.def.section->owner, |
2433 | global_sym_index (h))) | |
2434 | return false; | |
2435 | } | |
2436 | ||
2437 | dyn_i->want_fptr = 0; | |
2438 | } | |
2439 | else if (h == NULL || h->dynindx == -1) | |
2440 | { | |
2441 | dyn_i->fptr_offset = x->ofs; | |
2442 | x->ofs += 16; | |
2443 | } | |
2444 | else | |
2445 | dyn_i->want_fptr = 0; | |
2446 | } | |
2447 | return true; | |
2448 | } | |
2449 | ||
2450 | /* Allocate all the minimal PLT entries. */ | |
2451 | ||
2452 | static boolean | |
2453 | allocate_plt_entries (dyn_i, data) | |
bbe66d08 | 2454 | struct elfNN_ia64_dyn_sym_info *dyn_i; |
800eeca4 JW |
2455 | PTR data; |
2456 | { | |
bbe66d08 | 2457 | struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data; |
800eeca4 JW |
2458 | |
2459 | if (dyn_i->want_plt) | |
2460 | { | |
2461 | struct elf_link_hash_entry *h = dyn_i->h; | |
2462 | ||
2463 | if (h) | |
2464 | while (h->root.type == bfd_link_hash_indirect | |
2465 | || h->root.type == bfd_link_hash_warning) | |
2466 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
2467 | ||
2468 | /* ??? Versioned symbols seem to lose ELF_LINK_HASH_NEEDS_PLT. */ | |
bbe66d08 | 2469 | if (elfNN_ia64_dynamic_symbol_p (h, x->info)) |
800eeca4 JW |
2470 | { |
2471 | bfd_size_type offset = x->ofs; | |
2472 | if (offset == 0) | |
2473 | offset = PLT_HEADER_SIZE; | |
2474 | dyn_i->plt_offset = offset; | |
2475 | x->ofs = offset + PLT_MIN_ENTRY_SIZE; | |
2476 | ||
2477 | dyn_i->want_pltoff = 1; | |
2478 | } | |
2479 | else | |
2480 | { | |
2481 | dyn_i->want_plt = 0; | |
2482 | dyn_i->want_plt2 = 0; | |
2483 | } | |
2484 | } | |
2485 | return true; | |
2486 | } | |
2487 | ||
2488 | /* Allocate all the full PLT entries. */ | |
2489 | ||
2490 | static boolean | |
2491 | allocate_plt2_entries (dyn_i, data) | |
bbe66d08 | 2492 | struct elfNN_ia64_dyn_sym_info *dyn_i; |
800eeca4 JW |
2493 | PTR data; |
2494 | { | |
bbe66d08 | 2495 | struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data; |
800eeca4 JW |
2496 | |
2497 | if (dyn_i->want_plt2) | |
2498 | { | |
2499 | struct elf_link_hash_entry *h = dyn_i->h; | |
2500 | bfd_size_type ofs = x->ofs; | |
2501 | ||
2502 | dyn_i->plt2_offset = ofs; | |
2503 | x->ofs = ofs + PLT_FULL_ENTRY_SIZE; | |
2504 | ||
2505 | while (h->root.type == bfd_link_hash_indirect | |
2506 | || h->root.type == bfd_link_hash_warning) | |
2507 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
2508 | dyn_i->h->plt.offset = ofs; | |
2509 | } | |
2510 | return true; | |
2511 | } | |
2512 | ||
2513 | /* Allocate all the PLTOFF entries requested by relocations and | |
2514 | plt entries. We can't share space with allocated FPTR entries, | |
2515 | because the latter are not necessarily addressable by the GP. | |
2516 | ??? Relaxation might be able to determine that they are. */ | |
2517 | ||
2518 | static boolean | |
2519 | allocate_pltoff_entries (dyn_i, data) | |
bbe66d08 | 2520 | struct elfNN_ia64_dyn_sym_info *dyn_i; |
800eeca4 JW |
2521 | PTR data; |
2522 | { | |
bbe66d08 | 2523 | struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data; |
800eeca4 JW |
2524 | |
2525 | if (dyn_i->want_pltoff) | |
2526 | { | |
2527 | dyn_i->pltoff_offset = x->ofs; | |
2528 | x->ofs += 16; | |
2529 | } | |
2530 | return true; | |
2531 | } | |
2532 | ||
2533 | /* Allocate dynamic relocations for those symbols that turned out | |
2534 | to be dynamic. */ | |
2535 | ||
2536 | static boolean | |
2537 | allocate_dynrel_entries (dyn_i, data) | |
bbe66d08 | 2538 | struct elfNN_ia64_dyn_sym_info *dyn_i; |
800eeca4 JW |
2539 | PTR data; |
2540 | { | |
bbe66d08 JW |
2541 | struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data; |
2542 | struct elfNN_ia64_link_hash_table *ia64_info; | |
2543 | struct elfNN_ia64_dyn_reloc_entry *rent; | |
800eeca4 JW |
2544 | boolean dynamic_symbol, shared; |
2545 | ||
bbe66d08 | 2546 | ia64_info = elfNN_ia64_hash_table (x->info); |
7b6dab7f | 2547 | dynamic_symbol = elfNN_ia64_dynamic_symbol_p (dyn_i->h, x->info) |
64e9ece0 TW |
2548 | || (elfNN_ia64_aix_vec (x->info->hash->creator) |
2549 | /* Don't allocate an entry for __GLOB_DATA_PTR */ | |
2550 | && (!dyn_i->h || strcmp (dyn_i->h->root.root.string, | |
2551 | "__GLOB_DATA_PTR") != 0)); | |
800eeca4 JW |
2552 | shared = x->info->shared; |
2553 | ||
2554 | /* Take care of the normal data relocations. */ | |
2555 | ||
2556 | for (rent = dyn_i->reloc_entries; rent; rent = rent->next) | |
2557 | { | |
18b27f17 RH |
2558 | int count = rent->count; |
2559 | ||
800eeca4 JW |
2560 | switch (rent->type) |
2561 | { | |
2562 | case R_IA64_FPTR64LSB: | |
2563 | /* Allocate one iff !want_fptr, which by this point will | |
2564 | be true only if we're actually allocating one statically | |
2565 | in the main executable. */ | |
2566 | if (dyn_i->want_fptr) | |
2567 | continue; | |
2568 | break; | |
2569 | case R_IA64_PCREL64LSB: | |
2570 | if (!dynamic_symbol) | |
2571 | continue; | |
2572 | break; | |
2573 | case R_IA64_DIR64LSB: | |
2574 | if (!dynamic_symbol && !shared) | |
2575 | continue; | |
2576 | break; | |
18b27f17 RH |
2577 | case R_IA64_IPLTLSB: |
2578 | if (!dynamic_symbol && !shared) | |
2579 | continue; | |
2580 | /* Use two REL relocations for IPLT relocations | |
2581 | against local symbols. */ | |
2582 | if (!dynamic_symbol) | |
2583 | count *= 2; | |
2584 | break; | |
2585 | default: | |
2586 | abort (); | |
800eeca4 | 2587 | } |
18b27f17 | 2588 | rent->srel->_raw_size += sizeof (ElfNN_External_Rela) * count; |
800eeca4 JW |
2589 | } |
2590 | ||
2591 | /* Take care of the GOT and PLT relocations. */ | |
2592 | ||
2593 | if (((dynamic_symbol || shared) && dyn_i->want_got) | |
2594 | || (dyn_i->want_ltoff_fptr && dyn_i->h && dyn_i->h->dynindx != -1)) | |
bbe66d08 | 2595 | ia64_info->rel_got_sec->_raw_size += sizeof (ElfNN_External_Rela); |
800eeca4 JW |
2596 | |
2597 | if (dyn_i->want_pltoff) | |
2598 | { | |
2599 | bfd_size_type t = 0; | |
2600 | ||
2601 | /* Dynamic symbols get one IPLT relocation. Local symbols in | |
2602 | shared libraries get two REL relocations. Local symbols in | |
2603 | main applications get nothing. */ | |
2604 | if (dynamic_symbol) | |
bbe66d08 | 2605 | t = sizeof (ElfNN_External_Rela); |
800eeca4 | 2606 | else if (shared) |
bbe66d08 | 2607 | t = 2 * sizeof (ElfNN_External_Rela); |
800eeca4 JW |
2608 | |
2609 | ia64_info->rel_pltoff_sec->_raw_size += t; | |
2610 | } | |
2611 | ||
2612 | return true; | |
2613 | } | |
2614 | ||
2615 | static boolean | |
bbe66d08 | 2616 | elfNN_ia64_adjust_dynamic_symbol (info, h) |
64bf6ae6 | 2617 | struct bfd_link_info *info ATTRIBUTE_UNUSED; |
800eeca4 JW |
2618 | struct elf_link_hash_entry *h; |
2619 | { | |
2620 | /* ??? Undefined symbols with PLT entries should be re-defined | |
2621 | to be the PLT entry. */ | |
2622 | ||
2623 | /* If this is a weak symbol, and there is a real definition, the | |
2624 | processor independent code will have arranged for us to see the | |
2625 | real definition first, and we can just use the same value. */ | |
2626 | if (h->weakdef != NULL) | |
2627 | { | |
2628 | BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined | |
2629 | || h->weakdef->root.type == bfd_link_hash_defweak); | |
2630 | h->root.u.def.section = h->weakdef->root.u.def.section; | |
2631 | h->root.u.def.value = h->weakdef->root.u.def.value; | |
2632 | return true; | |
2633 | } | |
2634 | ||
2635 | /* If this is a reference to a symbol defined by a dynamic object which | |
2636 | is not a function, we might allocate the symbol in our .dynbss section | |
2637 | and allocate a COPY dynamic relocation. | |
2638 | ||
2639 | But IA-64 code is canonically PIC, so as a rule we can avoid this sort | |
2640 | of hackery. */ | |
2641 | ||
2642 | return true; | |
2643 | } | |
2644 | ||
2645 | static boolean | |
bbe66d08 | 2646 | elfNN_ia64_size_dynamic_sections (output_bfd, info) |
800eeca4 JW |
2647 | bfd *output_bfd; |
2648 | struct bfd_link_info *info; | |
2649 | { | |
bbe66d08 JW |
2650 | struct elfNN_ia64_allocate_data data; |
2651 | struct elfNN_ia64_link_hash_table *ia64_info; | |
800eeca4 JW |
2652 | asection *sec; |
2653 | bfd *dynobj; | |
800eeca4 JW |
2654 | boolean relplt = false; |
2655 | ||
2656 | dynobj = elf_hash_table(info)->dynobj; | |
bbe66d08 | 2657 | ia64_info = elfNN_ia64_hash_table (info); |
800eeca4 JW |
2658 | BFD_ASSERT(dynobj != NULL); |
2659 | data.info = info; | |
2660 | ||
2661 | /* Set the contents of the .interp section to the interpreter. */ | |
2662 | if (ia64_info->root.dynamic_sections_created | |
2663 | && !info->shared) | |
2664 | { | |
2665 | sec = bfd_get_section_by_name (dynobj, ".interp"); | |
2666 | BFD_ASSERT (sec != NULL); | |
7b6dab7f TW |
2667 | sec->contents = (bfd_byte *) DYNAMIC_INTERPRETER (output_bfd); |
2668 | sec->_raw_size = strlen (DYNAMIC_INTERPRETER (output_bfd)) + 1; | |
800eeca4 JW |
2669 | } |
2670 | ||
800eeca4 JW |
2671 | /* Allocate the GOT entries. */ |
2672 | ||
2673 | if (ia64_info->got_sec) | |
2674 | { | |
2675 | data.ofs = 0; | |
bbe66d08 JW |
2676 | elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_global_data_got, &data); |
2677 | elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_global_fptr_got, &data); | |
2678 | elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_local_got, &data); | |
800eeca4 JW |
2679 | ia64_info->got_sec->_raw_size = data.ofs; |
2680 | } | |
2681 | ||
2682 | /* Allocate the FPTR entries. */ | |
2683 | ||
2684 | if (ia64_info->fptr_sec) | |
2685 | { | |
2686 | data.ofs = 0; | |
bbe66d08 | 2687 | elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_fptr, &data); |
800eeca4 JW |
2688 | ia64_info->fptr_sec->_raw_size = data.ofs; |
2689 | } | |
2690 | ||
2691 | /* Now that we've seen all of the input files, we can decide which | |
2692 | symbols need plt entries. Allocate the minimal PLT entries first. | |
2693 | We do this even though dynamic_sections_created may be false, because | |
2694 | this has the side-effect of clearing want_plt and want_plt2. */ | |
2695 | ||
2696 | data.ofs = 0; | |
bbe66d08 | 2697 | elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_plt_entries, &data); |
800eeca4 JW |
2698 | |
2699 | ia64_info->minplt_entries = 0; | |
2700 | if (data.ofs) | |
2701 | { | |
2702 | ia64_info->minplt_entries | |
2703 | = (data.ofs - PLT_HEADER_SIZE) / PLT_MIN_ENTRY_SIZE; | |
2704 | } | |
2705 | ||
2706 | /* Align the pointer for the plt2 entries. */ | |
dc810e39 | 2707 | data.ofs = (data.ofs + 31) & (bfd_vma) -32; |
800eeca4 | 2708 | |
bbe66d08 | 2709 | elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_plt2_entries, &data); |
800eeca4 JW |
2710 | if (data.ofs != 0) |
2711 | { | |
2712 | BFD_ASSERT (ia64_info->root.dynamic_sections_created); | |
2713 | ||
2714 | ia64_info->plt_sec->_raw_size = data.ofs; | |
2715 | ||
2716 | /* If we've got a .plt, we need some extra memory for the dynamic | |
2717 | linker. We stuff these in .got.plt. */ | |
2718 | sec = bfd_get_section_by_name (dynobj, ".got.plt"); | |
2719 | sec->_raw_size = 8 * PLT_RESERVED_WORDS; | |
2720 | } | |
2721 | ||
2722 | /* Allocate the PLTOFF entries. */ | |
2723 | ||
2724 | if (ia64_info->pltoff_sec) | |
2725 | { | |
2726 | data.ofs = 0; | |
bbe66d08 | 2727 | elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_pltoff_entries, &data); |
800eeca4 JW |
2728 | ia64_info->pltoff_sec->_raw_size = data.ofs; |
2729 | } | |
2730 | ||
2731 | if (ia64_info->root.dynamic_sections_created) | |
2732 | { | |
2733 | /* Allocate space for the dynamic relocations that turned out to be | |
2734 | required. */ | |
2735 | ||
bbe66d08 | 2736 | elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_dynrel_entries, &data); |
800eeca4 JW |
2737 | } |
2738 | ||
2739 | /* We have now determined the sizes of the various dynamic sections. | |
2740 | Allocate memory for them. */ | |
2741 | for (sec = dynobj->sections; sec != NULL; sec = sec->next) | |
2742 | { | |
2743 | boolean strip; | |
2744 | ||
2745 | if (!(sec->flags & SEC_LINKER_CREATED)) | |
2746 | continue; | |
2747 | ||
2748 | /* If we don't need this section, strip it from the output file. | |
2749 | There were several sections primarily related to dynamic | |
2750 | linking that must be create before the linker maps input | |
2751 | sections to output sections. The linker does that before | |
2752 | bfd_elf_size_dynamic_sections is called, and it is that | |
2753 | function which decides whether anything needs to go into | |
2754 | these sections. */ | |
2755 | ||
2756 | strip = (sec->_raw_size == 0); | |
2757 | ||
2758 | if (sec == ia64_info->got_sec) | |
2759 | strip = false; | |
2760 | else if (sec == ia64_info->rel_got_sec) | |
2761 | { | |
2762 | if (strip) | |
2763 | ia64_info->rel_got_sec = NULL; | |
2764 | else | |
2765 | /* We use the reloc_count field as a counter if we need to | |
2766 | copy relocs into the output file. */ | |
2767 | sec->reloc_count = 0; | |
2768 | } | |
2769 | else if (sec == ia64_info->fptr_sec) | |
2770 | { | |
2771 | if (strip) | |
2772 | ia64_info->fptr_sec = NULL; | |
2773 | } | |
2774 | else if (sec == ia64_info->plt_sec) | |
2775 | { | |
2776 | if (strip) | |
2777 | ia64_info->plt_sec = NULL; | |
2778 | } | |
2779 | else if (sec == ia64_info->pltoff_sec) | |
2780 | { | |
2781 | if (strip) | |
2782 | ia64_info->pltoff_sec = NULL; | |
2783 | } | |
2784 | else if (sec == ia64_info->rel_pltoff_sec) | |
2785 | { | |
2786 | if (strip) | |
2787 | ia64_info->rel_pltoff_sec = NULL; | |
2788 | else | |
2789 | { | |
2790 | relplt = true; | |
2791 | /* We use the reloc_count field as a counter if we need to | |
2792 | copy relocs into the output file. */ | |
2793 | sec->reloc_count = 0; | |
2794 | } | |
2795 | } | |
2796 | else | |
2797 | { | |
2798 | const char *name; | |
2799 | ||
2800 | /* It's OK to base decisions on the section name, because none | |
2801 | of the dynobj section names depend upon the input files. */ | |
2802 | name = bfd_get_section_name (dynobj, sec); | |
2803 | ||
2804 | if (strcmp (name, ".got.plt") == 0) | |
2805 | strip = false; | |
2806 | else if (strncmp (name, ".rel", 4) == 0) | |
2807 | { | |
2808 | if (!strip) | |
2809 | { | |
800eeca4 JW |
2810 | /* We use the reloc_count field as a counter if we need to |
2811 | copy relocs into the output file. */ | |
2812 | sec->reloc_count = 0; | |
2813 | } | |
2814 | } | |
2815 | else | |
2816 | continue; | |
2817 | } | |
2818 | ||
2819 | if (strip) | |
2820 | _bfd_strip_section_from_output (info, sec); | |
2821 | else | |
2822 | { | |
2823 | /* Allocate memory for the section contents. */ | |
dc810e39 | 2824 | sec->contents = (bfd_byte *) bfd_zalloc (dynobj, sec->_raw_size); |
800eeca4 JW |
2825 | if (sec->contents == NULL && sec->_raw_size != 0) |
2826 | return false; | |
2827 | } | |
2828 | } | |
2829 | ||
2830 | if (elf_hash_table (info)->dynamic_sections_created) | |
2831 | { | |
2832 | /* Add some entries to the .dynamic section. We fill in the values | |
2833 | later (in finish_dynamic_sections) but we must add the entries now | |
2834 | so that we get the correct size for the .dynamic section. */ | |
2835 | ||
2836 | if (!info->shared) | |
2837 | { | |
2838 | /* The DT_DEBUG entry is filled in by the dynamic linker and used | |
2839 | by the debugger. */ | |
dc810e39 AM |
2840 | #define add_dynamic_entry(TAG, VAL) \ |
2841 | bfd_elfNN_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) | |
2842 | ||
2843 | if (!add_dynamic_entry (DT_DEBUG, 0)) | |
800eeca4 JW |
2844 | return false; |
2845 | } | |
2846 | ||
dc810e39 | 2847 | if (!add_dynamic_entry (DT_IA_64_PLT_RESERVE, 0)) |
800eeca4 | 2848 | return false; |
dc810e39 | 2849 | if (!add_dynamic_entry (DT_PLTGOT, 0)) |
800eeca4 JW |
2850 | return false; |
2851 | ||
2852 | if (relplt) | |
2853 | { | |
dc810e39 AM |
2854 | if (!add_dynamic_entry (DT_PLTRELSZ, 0) |
2855 | || !add_dynamic_entry (DT_PLTREL, DT_RELA) | |
2856 | || !add_dynamic_entry (DT_JMPREL, 0)) | |
800eeca4 JW |
2857 | return false; |
2858 | } | |
2859 | ||
dc810e39 AM |
2860 | if (!add_dynamic_entry (DT_RELA, 0) |
2861 | || !add_dynamic_entry (DT_RELASZ, 0) | |
2862 | || !add_dynamic_entry (DT_RELAENT, sizeof (ElfNN_External_Rela))) | |
800eeca4 JW |
2863 | return false; |
2864 | ||
db6751f2 | 2865 | if (ia64_info->reltext) |
800eeca4 | 2866 | { |
dc810e39 | 2867 | if (!add_dynamic_entry (DT_TEXTREL, 0)) |
800eeca4 | 2868 | return false; |
d6cf2879 | 2869 | info->flags |= DF_TEXTREL; |
800eeca4 JW |
2870 | } |
2871 | } | |
2872 | ||
2873 | /* ??? Perhaps force __gp local. */ | |
2874 | ||
2875 | return true; | |
2876 | } | |
2877 | ||
2878 | static bfd_reloc_status_type | |
1e738b87 | 2879 | elfNN_ia64_install_value (abfd, hit_addr, v, r_type) |
800eeca4 JW |
2880 | bfd *abfd; |
2881 | bfd_byte *hit_addr; | |
1e738b87 | 2882 | bfd_vma v; |
800eeca4 JW |
2883 | unsigned int r_type; |
2884 | { | |
2885 | const struct ia64_operand *op; | |
2886 | int bigendian = 0, shift = 0; | |
2887 | bfd_vma t0, t1, insn, dword; | |
2888 | enum ia64_opnd opnd; | |
2889 | const char *err; | |
2890 | size_t size = 8; | |
1e738b87 NC |
2891 | #ifdef BFD_HOST_U_64_BIT |
2892 | BFD_HOST_U_64_BIT val = (BFD_HOST_U_64_BIT) v; | |
2893 | #else | |
2894 | bfd_vma val = v; | |
2895 | #endif | |
800eeca4 JW |
2896 | |
2897 | opnd = IA64_OPND_NIL; | |
2898 | switch (r_type) | |
2899 | { | |
2900 | case R_IA64_NONE: | |
2901 | case R_IA64_LDXMOV: | |
2902 | return bfd_reloc_ok; | |
2903 | ||
3e932841 | 2904 | /* Instruction relocations. */ |
800eeca4 JW |
2905 | |
2906 | case R_IA64_IMM14: opnd = IA64_OPND_IMM14; break; | |
748abff6 | 2907 | |
800eeca4 JW |
2908 | case R_IA64_PCREL21F: opnd = IA64_OPND_TGT25; break; |
2909 | case R_IA64_PCREL21M: opnd = IA64_OPND_TGT25b; break; | |
748abff6 RH |
2910 | case R_IA64_PCREL60B: opnd = IA64_OPND_TGT64; break; |
2911 | case R_IA64_PCREL21B: | |
2912 | case R_IA64_PCREL21BI: | |
2913 | opnd = IA64_OPND_TGT25c; | |
2914 | break; | |
800eeca4 JW |
2915 | |
2916 | case R_IA64_IMM22: | |
2917 | case R_IA64_GPREL22: | |
2918 | case R_IA64_LTOFF22: | |
2919 | case R_IA64_LTOFF22X: | |
2920 | case R_IA64_PLTOFF22: | |
748abff6 | 2921 | case R_IA64_PCREL22: |
800eeca4 JW |
2922 | case R_IA64_LTOFF_FPTR22: |
2923 | opnd = IA64_OPND_IMM22; | |
2924 | break; | |
2925 | ||
2926 | case R_IA64_IMM64: | |
2927 | case R_IA64_GPREL64I: | |
2928 | case R_IA64_LTOFF64I: | |
2929 | case R_IA64_PLTOFF64I: | |
748abff6 | 2930 | case R_IA64_PCREL64I: |
800eeca4 JW |
2931 | case R_IA64_FPTR64I: |
2932 | case R_IA64_LTOFF_FPTR64I: | |
2933 | opnd = IA64_OPND_IMMU64; | |
2934 | break; | |
2935 | ||
2936 | /* Data relocations. */ | |
2937 | ||
2938 | case R_IA64_DIR32MSB: | |
2939 | case R_IA64_GPREL32MSB: | |
2940 | case R_IA64_FPTR32MSB: | |
2941 | case R_IA64_PCREL32MSB: | |
a4bd8390 | 2942 | case R_IA64_LTOFF_FPTR32MSB: |
800eeca4 JW |
2943 | case R_IA64_SEGREL32MSB: |
2944 | case R_IA64_SECREL32MSB: | |
2945 | case R_IA64_LTV32MSB: | |
2946 | size = 4; bigendian = 1; | |
2947 | break; | |
2948 | ||
2949 | case R_IA64_DIR32LSB: | |
2950 | case R_IA64_GPREL32LSB: | |
2951 | case R_IA64_FPTR32LSB: | |
2952 | case R_IA64_PCREL32LSB: | |
a4bd8390 | 2953 | case R_IA64_LTOFF_FPTR32LSB: |
800eeca4 JW |
2954 | case R_IA64_SEGREL32LSB: |
2955 | case R_IA64_SECREL32LSB: | |
2956 | case R_IA64_LTV32LSB: | |
2957 | size = 4; bigendian = 0; | |
2958 | break; | |
2959 | ||
2960 | case R_IA64_DIR64MSB: | |
2961 | case R_IA64_GPREL64MSB: | |
2962 | case R_IA64_PLTOFF64MSB: | |
2963 | case R_IA64_FPTR64MSB: | |
2964 | case R_IA64_PCREL64MSB: | |
2965 | case R_IA64_LTOFF_FPTR64MSB: | |
2966 | case R_IA64_SEGREL64MSB: | |
2967 | case R_IA64_SECREL64MSB: | |
2968 | case R_IA64_LTV64MSB: | |
2969 | size = 8; bigendian = 1; | |
2970 | break; | |
2971 | ||
2972 | case R_IA64_DIR64LSB: | |
2973 | case R_IA64_GPREL64LSB: | |
2974 | case R_IA64_PLTOFF64LSB: | |
2975 | case R_IA64_FPTR64LSB: | |
2976 | case R_IA64_PCREL64LSB: | |
2977 | case R_IA64_LTOFF_FPTR64LSB: | |
2978 | case R_IA64_SEGREL64LSB: | |
2979 | case R_IA64_SECREL64LSB: | |
2980 | case R_IA64_LTV64LSB: | |
2981 | size = 8; bigendian = 0; | |
2982 | break; | |
2983 | ||
2984 | /* Unsupported / Dynamic relocations. */ | |
800eeca4 JW |
2985 | default: |
2986 | return bfd_reloc_notsupported; | |
2987 | } | |
2988 | ||
2989 | switch (opnd) | |
2990 | { | |
2991 | case IA64_OPND_IMMU64: | |
2992 | hit_addr -= (long) hit_addr & 0x3; | |
2993 | t0 = bfd_get_64 (abfd, hit_addr); | |
2994 | t1 = bfd_get_64 (abfd, hit_addr + 8); | |
2995 | ||
2996 | /* tmpl/s: bits 0.. 5 in t0 | |
2997 | slot 0: bits 5..45 in t0 | |
2998 | slot 1: bits 46..63 in t0, bits 0..22 in t1 | |
2999 | slot 2: bits 23..63 in t1 */ | |
3000 | ||
3001 | /* First, clear the bits that form the 64 bit constant. */ | |
3002 | t0 &= ~(0x3ffffLL << 46); | |
3003 | t1 &= ~(0x7fffffLL | |
3004 | | (( (0x07fLL << 13) | (0x1ffLL << 27) | |
3005 | | (0x01fLL << 22) | (0x001LL << 21) | |
3006 | | (0x001LL << 36)) << 23)); | |
3007 | ||
3008 | t0 |= ((val >> 22) & 0x03ffffLL) << 46; /* 18 lsbs of imm41 */ | |
3009 | t1 |= ((val >> 40) & 0x7fffffLL) << 0; /* 23 msbs of imm41 */ | |
3010 | t1 |= ( (((val >> 0) & 0x07f) << 13) /* imm7b */ | |
3011 | | (((val >> 7) & 0x1ff) << 27) /* imm9d */ | |
3012 | | (((val >> 16) & 0x01f) << 22) /* imm5c */ | |
3013 | | (((val >> 21) & 0x001) << 21) /* ic */ | |
3014 | | (((val >> 63) & 0x001) << 36)) << 23; /* i */ | |
3015 | ||
3016 | bfd_put_64 (abfd, t0, hit_addr); | |
3017 | bfd_put_64 (abfd, t1, hit_addr + 8); | |
3018 | break; | |
3019 | ||
748abff6 RH |
3020 | case IA64_OPND_TGT64: |
3021 | hit_addr -= (long) hit_addr & 0x3; | |
3022 | t0 = bfd_get_64 (abfd, hit_addr); | |
3023 | t1 = bfd_get_64 (abfd, hit_addr + 8); | |
3024 | ||
3025 | /* tmpl/s: bits 0.. 5 in t0 | |
3026 | slot 0: bits 5..45 in t0 | |
3027 | slot 1: bits 46..63 in t0, bits 0..22 in t1 | |
3028 | slot 2: bits 23..63 in t1 */ | |
3029 | ||
3030 | /* First, clear the bits that form the 64 bit constant. */ | |
3031 | t0 &= ~(0x3ffffLL << 46); | |
3032 | t1 &= ~(0x7fffffLL | |
3033 | | ((1LL << 36 | 0xfffffLL << 13) << 23)); | |
3034 | ||
3035 | val >>= 4; | |
3036 | t0 |= ((val >> 20) & 0xffffLL) << 2 << 46; /* 16 lsbs of imm39 */ | |
3037 | t1 |= ((val >> 36) & 0x7fffffLL) << 0; /* 23 msbs of imm39 */ | |
3038 | t1 |= ((((val >> 0) & 0xfffffLL) << 13) /* imm20b */ | |
3039 | | (((val >> 59) & 0x1LL) << 36)) << 23; /* i */ | |
3040 | ||
3041 | bfd_put_64 (abfd, t0, hit_addr); | |
3042 | bfd_put_64 (abfd, t1, hit_addr + 8); | |
3043 | break; | |
3044 | ||
800eeca4 JW |
3045 | default: |
3046 | switch ((long) hit_addr & 0x3) | |
3047 | { | |
3048 | case 0: shift = 5; break; | |
3049 | case 1: shift = 14; hit_addr += 3; break; | |
3050 | case 2: shift = 23; hit_addr += 6; break; | |
3e932841 | 3051 | case 3: return bfd_reloc_notsupported; /* shouldn't happen... */ |
800eeca4 JW |
3052 | } |
3053 | dword = bfd_get_64 (abfd, hit_addr); | |
3054 | insn = (dword >> shift) & 0x1ffffffffffLL; | |
3055 | ||
3056 | op = elf64_ia64_operands + opnd; | |
1e738b87 | 3057 | err = (*op->insert) (op, val, (ia64_insn *)& insn); |
800eeca4 JW |
3058 | if (err) |
3059 | return bfd_reloc_overflow; | |
3060 | ||
3061 | dword &= ~(0x1ffffffffffLL << shift); | |
3062 | dword |= (insn << shift); | |
3063 | bfd_put_64 (abfd, dword, hit_addr); | |
3064 | break; | |
3065 | ||
3066 | case IA64_OPND_NIL: | |
3067 | /* A data relocation. */ | |
3068 | if (bigendian) | |
3069 | if (size == 4) | |
3070 | bfd_putb32 (val, hit_addr); | |
3071 | else | |
3072 | bfd_putb64 (val, hit_addr); | |
3073 | else | |
3074 | if (size == 4) | |
3075 | bfd_putl32 (val, hit_addr); | |
3076 | else | |
3077 | bfd_putl64 (val, hit_addr); | |
3078 | break; | |
3079 | } | |
3080 | ||
3081 | return bfd_reloc_ok; | |
3082 | } | |
3083 | ||
3084 | static void | |
bbe66d08 | 3085 | elfNN_ia64_install_dyn_reloc (abfd, info, sec, srel, offset, type, |
800eeca4 JW |
3086 | dynindx, addend) |
3087 | bfd *abfd; | |
3088 | struct bfd_link_info *info; | |
3089 | asection *sec; | |
3090 | asection *srel; | |
3091 | bfd_vma offset; | |
3092 | unsigned int type; | |
3093 | long dynindx; | |
3094 | bfd_vma addend; | |
3095 | { | |
3096 | Elf_Internal_Rela outrel; | |
3097 | ||
c629eae0 | 3098 | offset += sec->output_section->vma + sec->output_offset; |
800eeca4 JW |
3099 | |
3100 | BFD_ASSERT (dynindx != -1); | |
bbe66d08 | 3101 | outrel.r_info = ELFNN_R_INFO (dynindx, type); |
800eeca4 | 3102 | outrel.r_addend = addend; |
c629eae0 | 3103 | outrel.r_offset = _bfd_elf_section_offset (abfd, info, sec, offset); |
0bb2d96a | 3104 | if ((outrel.r_offset | 1) == (bfd_vma) -1) |
800eeca4 | 3105 | { |
c629eae0 JJ |
3106 | /* Run for the hills. We shouldn't be outputting a relocation |
3107 | for this. So do what everyone else does and output a no-op. */ | |
3108 | outrel.r_info = ELFNN_R_INFO (0, R_IA64_NONE); | |
3109 | outrel.r_addend = 0; | |
3110 | outrel.r_offset = 0; | |
800eeca4 JW |
3111 | } |
3112 | ||
bbe66d08 JW |
3113 | bfd_elfNN_swap_reloca_out (abfd, &outrel, |
3114 | ((ElfNN_External_Rela *) srel->contents | |
800eeca4 | 3115 | + srel->reloc_count++)); |
3e932841 | 3116 | BFD_ASSERT (sizeof (ElfNN_External_Rela) * srel->reloc_count |
800eeca4 JW |
3117 | <= srel->_cooked_size); |
3118 | } | |
3119 | ||
3120 | /* Store an entry for target address TARGET_ADDR in the linkage table | |
3121 | and return the gp-relative address of the linkage table entry. */ | |
3122 | ||
3123 | static bfd_vma | |
3124 | set_got_entry (abfd, info, dyn_i, dynindx, addend, value, dyn_r_type) | |
3125 | bfd *abfd; | |
3126 | struct bfd_link_info *info; | |
bbe66d08 | 3127 | struct elfNN_ia64_dyn_sym_info *dyn_i; |
800eeca4 JW |
3128 | long dynindx; |
3129 | bfd_vma addend; | |
3130 | bfd_vma value; | |
3131 | unsigned int dyn_r_type; | |
3132 | { | |
bbe66d08 | 3133 | struct elfNN_ia64_link_hash_table *ia64_info; |
800eeca4 JW |
3134 | asection *got_sec; |
3135 | ||
bbe66d08 | 3136 | ia64_info = elfNN_ia64_hash_table (info); |
800eeca4 JW |
3137 | got_sec = ia64_info->got_sec; |
3138 | ||
3139 | BFD_ASSERT ((dyn_i->got_offset & 7) == 0); | |
3140 | ||
3141 | if (! dyn_i->got_done) | |
3142 | { | |
3143 | dyn_i->got_done = true; | |
3144 | ||
3145 | /* Store the target address in the linkage table entry. */ | |
3146 | bfd_put_64 (abfd, value, got_sec->contents + dyn_i->got_offset); | |
3147 | ||
3148 | /* Install a dynamic relocation if needed. */ | |
3149 | if (info->shared | |
bbe66d08 | 3150 | || elfNN_ia64_dynamic_symbol_p (dyn_i->h, info) |
7b6dab7f | 3151 | || elfNN_ia64_aix_vec (abfd->xvec) |
800eeca4 JW |
3152 | || (dynindx != -1 && dyn_r_type == R_IA64_FPTR64LSB)) |
3153 | { | |
3154 | if (dynindx == -1) | |
3155 | { | |
3156 | dyn_r_type = R_IA64_REL64LSB; | |
3157 | dynindx = 0; | |
3158 | addend = value; | |
3159 | } | |
3160 | ||
3161 | if (bfd_big_endian (abfd)) | |
3162 | { | |
3163 | switch (dyn_r_type) | |
3164 | { | |
3165 | case R_IA64_REL64LSB: | |
3166 | dyn_r_type = R_IA64_REL64MSB; | |
3167 | break; | |
3168 | case R_IA64_DIR64LSB: | |
3169 | dyn_r_type = R_IA64_DIR64MSB; | |
3170 | break; | |
3171 | case R_IA64_FPTR64LSB: | |
3172 | dyn_r_type = R_IA64_FPTR64MSB; | |
3173 | break; | |
3174 | default: | |
3175 | BFD_ASSERT (false); | |
3176 | break; | |
3177 | } | |
3178 | } | |
3179 | ||
bbe66d08 | 3180 | elfNN_ia64_install_dyn_reloc (abfd, NULL, got_sec, |
800eeca4 JW |
3181 | ia64_info->rel_got_sec, |
3182 | dyn_i->got_offset, dyn_r_type, | |
3183 | dynindx, addend); | |
3184 | } | |
3185 | } | |
3186 | ||
3187 | /* Return the address of the linkage table entry. */ | |
3188 | value = (got_sec->output_section->vma | |
3189 | + got_sec->output_offset | |
3190 | + dyn_i->got_offset); | |
3191 | ||
3192 | return value; | |
3193 | } | |
3194 | ||
3195 | /* Fill in a function descriptor consisting of the function's code | |
3196 | address and its global pointer. Return the descriptor's address. */ | |
3197 | ||
3198 | static bfd_vma | |
3199 | set_fptr_entry (abfd, info, dyn_i, value) | |
3200 | bfd *abfd; | |
3201 | struct bfd_link_info *info; | |
bbe66d08 | 3202 | struct elfNN_ia64_dyn_sym_info *dyn_i; |
800eeca4 JW |
3203 | bfd_vma value; |
3204 | { | |
bbe66d08 | 3205 | struct elfNN_ia64_link_hash_table *ia64_info; |
800eeca4 JW |
3206 | asection *fptr_sec; |
3207 | ||
bbe66d08 | 3208 | ia64_info = elfNN_ia64_hash_table (info); |
800eeca4 JW |
3209 | fptr_sec = ia64_info->fptr_sec; |
3210 | ||
3211 | if (!dyn_i->fptr_done) | |
3212 | { | |
3213 | dyn_i->fptr_done = 1; | |
3214 | ||
3215 | /* Fill in the function descriptor. */ | |
3216 | bfd_put_64 (abfd, value, fptr_sec->contents + dyn_i->fptr_offset); | |
3217 | bfd_put_64 (abfd, _bfd_get_gp_value (abfd), | |
3218 | fptr_sec->contents + dyn_i->fptr_offset + 8); | |
3219 | } | |
3220 | ||
3221 | /* Return the descriptor's address. */ | |
3222 | value = (fptr_sec->output_section->vma | |
3223 | + fptr_sec->output_offset | |
3224 | + dyn_i->fptr_offset); | |
3225 | ||
3226 | return value; | |
3227 | } | |
3228 | ||
3229 | /* Fill in a PLTOFF entry consisting of the function's code address | |
3230 | and its global pointer. Return the descriptor's address. */ | |
3231 | ||
3232 | static bfd_vma | |
3233 | set_pltoff_entry (abfd, info, dyn_i, value, is_plt) | |
3234 | bfd *abfd; | |
3235 | struct bfd_link_info *info; | |
bbe66d08 | 3236 | struct elfNN_ia64_dyn_sym_info *dyn_i; |
800eeca4 JW |
3237 | bfd_vma value; |
3238 | boolean is_plt; | |
3239 | { | |
bbe66d08 | 3240 | struct elfNN_ia64_link_hash_table *ia64_info; |
800eeca4 JW |
3241 | asection *pltoff_sec; |
3242 | ||
bbe66d08 | 3243 | ia64_info = elfNN_ia64_hash_table (info); |
800eeca4 JW |
3244 | pltoff_sec = ia64_info->pltoff_sec; |
3245 | ||
3246 | /* Don't do anything if this symbol uses a real PLT entry. In | |
3247 | that case, we'll fill this in during finish_dynamic_symbol. */ | |
3248 | if ((! dyn_i->want_plt || is_plt) | |
3249 | && !dyn_i->pltoff_done) | |
3250 | { | |
18b27f17 RH |
3251 | bfd_vma gp = _bfd_get_gp_value (abfd); |
3252 | ||
800eeca4 JW |
3253 | /* Fill in the function descriptor. */ |
3254 | bfd_put_64 (abfd, value, pltoff_sec->contents + dyn_i->pltoff_offset); | |
18b27f17 | 3255 | bfd_put_64 (abfd, gp, pltoff_sec->contents + dyn_i->pltoff_offset + 8); |
800eeca4 JW |
3256 | |
3257 | /* Install dynamic relocations if needed. */ | |
3258 | if (!is_plt && info->shared) | |
3259 | { | |
3260 | unsigned int dyn_r_type; | |
3261 | ||
3262 | if (bfd_big_endian (abfd)) | |
3263 | dyn_r_type = R_IA64_REL64MSB; | |
3264 | else | |
3265 | dyn_r_type = R_IA64_REL64LSB; | |
3266 | ||
bbe66d08 | 3267 | elfNN_ia64_install_dyn_reloc (abfd, NULL, pltoff_sec, |
800eeca4 JW |
3268 | ia64_info->rel_pltoff_sec, |
3269 | dyn_i->pltoff_offset, | |
18b27f17 | 3270 | dyn_r_type, 0, value); |
bbe66d08 | 3271 | elfNN_ia64_install_dyn_reloc (abfd, NULL, pltoff_sec, |
800eeca4 JW |
3272 | ia64_info->rel_pltoff_sec, |
3273 | dyn_i->pltoff_offset + 8, | |
18b27f17 | 3274 | dyn_r_type, 0, gp); |
800eeca4 JW |
3275 | } |
3276 | ||
3277 | dyn_i->pltoff_done = 1; | |
3278 | } | |
3279 | ||
3280 | /* Return the descriptor's address. */ | |
3281 | value = (pltoff_sec->output_section->vma | |
3282 | + pltoff_sec->output_offset | |
3283 | + dyn_i->pltoff_offset); | |
3284 | ||
3285 | return value; | |
3286 | } | |
3287 | ||
f3b6f7c3 | 3288 | /* Called through qsort to sort the .IA_64.unwind section during a |
bbe66d08 | 3289 | non-relocatable link. Set elfNN_ia64_unwind_entry_compare_bfd |
f3b6f7c3 RH |
3290 | to the output bfd so we can do proper endianness frobbing. */ |
3291 | ||
bbe66d08 | 3292 | static bfd *elfNN_ia64_unwind_entry_compare_bfd; |
f3b6f7c3 RH |
3293 | |
3294 | static int | |
bbe66d08 | 3295 | elfNN_ia64_unwind_entry_compare (a, b) |
cea4409c AM |
3296 | const PTR a; |
3297 | const PTR b; | |
f3b6f7c3 RH |
3298 | { |
3299 | bfd_vma av, bv; | |
3300 | ||
bbe66d08 JW |
3301 | av = bfd_get_64 (elfNN_ia64_unwind_entry_compare_bfd, a); |
3302 | bv = bfd_get_64 (elfNN_ia64_unwind_entry_compare_bfd, b); | |
f3b6f7c3 RH |
3303 | |
3304 | return (av < bv ? -1 : av > bv ? 1 : 0); | |
3305 | } | |
3306 | ||
800eeca4 | 3307 | static boolean |
bbe66d08 | 3308 | elfNN_ia64_final_link (abfd, info) |
800eeca4 JW |
3309 | bfd *abfd; |
3310 | struct bfd_link_info *info; | |
3311 | { | |
bbe66d08 | 3312 | struct elfNN_ia64_link_hash_table *ia64_info; |
9a951beb RH |
3313 | asection *unwind_output_sec; |
3314 | ||
bbe66d08 | 3315 | ia64_info = elfNN_ia64_hash_table (info); |
800eeca4 JW |
3316 | |
3317 | /* Make sure we've got ourselves a nice fat __gp value. */ | |
3318 | if (!info->relocateable) | |
3319 | { | |
3320 | bfd_vma min_vma = (bfd_vma) -1, max_vma = 0; | |
3321 | bfd_vma min_short_vma = min_vma, max_short_vma = 0; | |
3322 | struct elf_link_hash_entry *gp; | |
3323 | bfd_vma gp_val; | |
3324 | asection *os; | |
3325 | ||
3326 | /* Find the min and max vma of all sections marked short. Also | |
3327 | collect min and max vma of any type, for use in selecting a | |
3328 | nice gp. */ | |
3329 | for (os = abfd->sections; os ; os = os->next) | |
3330 | { | |
3331 | bfd_vma lo, hi; | |
3332 | ||
3333 | if ((os->flags & SEC_ALLOC) == 0) | |
3334 | continue; | |
3335 | ||
3336 | lo = os->vma; | |
3337 | hi = os->vma + os->_raw_size; | |
3338 | if (hi < lo) | |
3339 | hi = (bfd_vma) -1; | |
3340 | ||
3341 | if (min_vma > lo) | |
3342 | min_vma = lo; | |
3343 | if (max_vma < hi) | |
3344 | max_vma = hi; | |
3345 | if (os->flags & SEC_SMALL_DATA) | |
3346 | { | |
3347 | if (min_short_vma > lo) | |
3348 | min_short_vma = lo; | |
3349 | if (max_short_vma < hi) | |
3350 | max_short_vma = hi; | |
3351 | } | |
3352 | } | |
3353 | ||
3354 | /* See if the user wants to force a value. */ | |
3355 | gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", false, | |
3356 | false, false); | |
3357 | ||
3358 | if (gp | |
3359 | && (gp->root.type == bfd_link_hash_defined | |
3360 | || gp->root.type == bfd_link_hash_defweak)) | |
3361 | { | |
3362 | asection *gp_sec = gp->root.u.def.section; | |
3363 | gp_val = (gp->root.u.def.value | |
3364 | + gp_sec->output_section->vma | |
3365 | + gp_sec->output_offset); | |
3366 | } | |
3367 | else | |
3368 | { | |
3369 | /* Pick a sensible value. */ | |
3370 | ||
3371 | asection *got_sec = ia64_info->got_sec; | |
3372 | ||
3373 | /* Start with just the address of the .got. */ | |
3374 | if (got_sec) | |
3375 | gp_val = got_sec->output_section->vma; | |
3376 | else if (max_short_vma != 0) | |
3377 | gp_val = min_short_vma; | |
3378 | else | |
3379 | gp_val = min_vma; | |
3380 | ||
3381 | /* If it is possible to address the entire image, but we | |
3382 | don't with the choice above, adjust. */ | |
3383 | if (max_vma - min_vma < 0x400000 | |
3384 | && max_vma - gp_val <= 0x200000 | |
3385 | && gp_val - min_vma > 0x200000) | |
3386 | gp_val = min_vma + 0x200000; | |
3387 | else if (max_short_vma != 0) | |
3388 | { | |
3389 | /* If we don't cover all the short data, adjust. */ | |
3390 | if (max_short_vma - gp_val >= 0x200000) | |
3391 | gp_val = min_short_vma + 0x200000; | |
3392 | ||
3393 | /* If we're addressing stuff past the end, adjust back. */ | |
3394 | if (gp_val > max_vma) | |
3395 | gp_val = max_vma - 0x200000 + 8; | |
3396 | } | |
3397 | } | |
3398 | ||
3399 | /* Validate whether all SHF_IA_64_SHORT sections are within | |
3400 | range of the chosen GP. */ | |
3401 | ||
3402 | if (max_short_vma != 0) | |
3403 | { | |
3404 | if (max_short_vma - min_short_vma >= 0x400000) | |
3405 | { | |
3406 | (*_bfd_error_handler) | |
3407 | (_("%s: short data segment overflowed (0x%lx >= 0x400000)"), | |
3408 | bfd_get_filename (abfd), | |
3e932841 | 3409 | (unsigned long) (max_short_vma - min_short_vma)); |
800eeca4 JW |
3410 | return false; |
3411 | } | |
3412 | else if ((gp_val > min_short_vma | |
3413 | && gp_val - min_short_vma > 0x200000) | |
3414 | || (gp_val < max_short_vma | |
3415 | && max_short_vma - gp_val >= 0x200000)) | |
3416 | { | |
3417 | (*_bfd_error_handler) | |
3418 | (_("%s: __gp does not cover short data segment"), | |
3419 | bfd_get_filename (abfd)); | |
3420 | return false; | |
3421 | } | |
3422 | } | |
3423 | ||
3424 | _bfd_set_gp_value (abfd, gp_val); | |
b4adccfd RH |
3425 | |
3426 | if (gp) | |
3427 | { | |
3428 | gp->root.type = bfd_link_hash_defined; | |
3429 | gp->root.u.def.value = gp_val; | |
3430 | gp->root.u.def.section = bfd_abs_section_ptr; | |
3431 | } | |
800eeca4 JW |
3432 | } |
3433 | ||
f3b6f7c3 | 3434 | /* If we're producing a final executable, we need to sort the contents |
9a951beb RH |
3435 | of the .IA_64.unwind section. Force this section to be relocated |
3436 | into memory rather than written immediately to the output file. */ | |
3437 | unwind_output_sec = NULL; | |
f3b6f7c3 RH |
3438 | if (!info->relocateable) |
3439 | { | |
3440 | asection *s = bfd_get_section_by_name (abfd, ELF_STRING_ia64_unwind); | |
3441 | if (s) | |
3442 | { | |
9a951beb RH |
3443 | unwind_output_sec = s->output_section; |
3444 | unwind_output_sec->contents | |
3445 | = bfd_malloc (unwind_output_sec->_raw_size); | |
3446 | if (unwind_output_sec->contents == NULL) | |
f3b6f7c3 | 3447 | return false; |
9a951beb RH |
3448 | } |
3449 | } | |
f3b6f7c3 | 3450 | |
9a951beb RH |
3451 | /* Invoke the regular ELF backend linker to do all the work. */ |
3452 | if (!bfd_elfNN_bfd_final_link (abfd, info)) | |
3453 | return false; | |
f3b6f7c3 | 3454 | |
9a951beb RH |
3455 | if (unwind_output_sec) |
3456 | { | |
3457 | elfNN_ia64_unwind_entry_compare_bfd = abfd; | |
dc810e39 AM |
3458 | qsort (unwind_output_sec->contents, |
3459 | (size_t) (unwind_output_sec->_raw_size / 24), | |
3460 | 24, | |
3461 | elfNN_ia64_unwind_entry_compare); | |
9a951beb RH |
3462 | |
3463 | if (! bfd_set_section_contents (abfd, unwind_output_sec, | |
dc810e39 | 3464 | unwind_output_sec->contents, (bfd_vma) 0, |
9a951beb RH |
3465 | unwind_output_sec->_raw_size)) |
3466 | return false; | |
f3b6f7c3 RH |
3467 | } |
3468 | ||
3469 | return true; | |
800eeca4 JW |
3470 | } |
3471 | ||
3472 | static boolean | |
bbe66d08 | 3473 | elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section, |
800eeca4 JW |
3474 | contents, relocs, local_syms, local_sections) |
3475 | bfd *output_bfd; | |
3476 | struct bfd_link_info *info; | |
3477 | bfd *input_bfd; | |
3478 | asection *input_section; | |
3479 | bfd_byte *contents; | |
3480 | Elf_Internal_Rela *relocs; | |
3481 | Elf_Internal_Sym *local_syms; | |
3482 | asection **local_sections; | |
3483 | { | |
bbe66d08 | 3484 | struct elfNN_ia64_link_hash_table *ia64_info; |
800eeca4 JW |
3485 | Elf_Internal_Shdr *symtab_hdr; |
3486 | Elf_Internal_Rela *rel; | |
3487 | Elf_Internal_Rela *relend; | |
3488 | asection *srel; | |
3489 | boolean ret_val = true; /* for non-fatal errors */ | |
3490 | bfd_vma gp_val; | |
3491 | ||
3492 | symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; | |
bbe66d08 | 3493 | ia64_info = elfNN_ia64_hash_table (info); |
800eeca4 JW |
3494 | |
3495 | /* Infect various flags from the input section to the output section. */ | |
3496 | if (info->relocateable) | |
3497 | { | |
3498 | bfd_vma flags; | |
3499 | ||
3500 | flags = elf_section_data(input_section)->this_hdr.sh_flags; | |
3501 | flags &= SHF_IA_64_NORECOV; | |
3502 | ||
3503 | elf_section_data(input_section->output_section) | |
3504 | ->this_hdr.sh_flags |= flags; | |
3505 | } | |
3506 | ||
3507 | gp_val = _bfd_get_gp_value (output_bfd); | |
3508 | srel = get_reloc_section (input_bfd, ia64_info, input_section, false); | |
3509 | ||
3510 | rel = relocs; | |
3511 | relend = relocs + input_section->reloc_count; | |
3512 | for (; rel < relend; ++rel) | |
3513 | { | |
3514 | struct elf_link_hash_entry *h; | |
bbe66d08 | 3515 | struct elfNN_ia64_dyn_sym_info *dyn_i; |
800eeca4 JW |
3516 | bfd_reloc_status_type r; |
3517 | reloc_howto_type *howto; | |
3518 | unsigned long r_symndx; | |
3519 | Elf_Internal_Sym *sym; | |
3520 | unsigned int r_type; | |
3521 | bfd_vma value; | |
3522 | asection *sym_sec; | |
3523 | bfd_byte *hit_addr; | |
3524 | boolean dynamic_symbol_p; | |
3525 | boolean undef_weak_ref; | |
3526 | ||
bbe66d08 | 3527 | r_type = ELFNN_R_TYPE (rel->r_info); |
800eeca4 JW |
3528 | if (r_type > R_IA64_MAX_RELOC_CODE) |
3529 | { | |
3530 | (*_bfd_error_handler) | |
3531 | (_("%s: unknown relocation type %d"), | |
8f615d07 | 3532 | bfd_archive_filename (input_bfd), (int)r_type); |
800eeca4 JW |
3533 | bfd_set_error (bfd_error_bad_value); |
3534 | ret_val = false; | |
3535 | continue; | |
3536 | } | |
3537 | howto = lookup_howto (r_type); | |
bbe66d08 | 3538 | r_symndx = ELFNN_R_SYM (rel->r_info); |
800eeca4 JW |
3539 | |
3540 | if (info->relocateable) | |
3541 | { | |
3542 | /* This is a relocateable link. We don't have to change | |
3543 | anything, unless the reloc is against a section symbol, | |
3544 | in which case we have to adjust according to where the | |
3545 | section symbol winds up in the output section. */ | |
3546 | if (r_symndx < symtab_hdr->sh_info) | |
3547 | { | |
3548 | sym = local_syms + r_symndx; | |
3549 | if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) | |
3550 | { | |
3551 | sym_sec = local_sections[r_symndx]; | |
3552 | rel->r_addend += sym_sec->output_offset; | |
3553 | } | |
3554 | } | |
3555 | continue; | |
3556 | } | |
3557 | ||
3558 | /* This is a final link. */ | |
3559 | ||
3560 | h = NULL; | |
3561 | sym = NULL; | |
3562 | sym_sec = NULL; | |
3563 | undef_weak_ref = false; | |
3564 | ||
3565 | if (r_symndx < symtab_hdr->sh_info) | |
3566 | { | |
3567 | /* Reloc against local symbol. */ | |
3568 | sym = local_syms + r_symndx; | |
3569 | sym_sec = local_sections[r_symndx]; | |
f8df10f4 | 3570 | value = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel); |
f7460f5f JJ |
3571 | if ((sym_sec->flags & SEC_MERGE) |
3572 | && ELF_ST_TYPE (sym->st_info) == STT_SECTION | |
65765700 JJ |
3573 | && (elf_section_data (sym_sec)->sec_info_type |
3574 | == ELF_INFO_TYPE_MERGE)) | |
f7460f5f JJ |
3575 | { |
3576 | struct elfNN_ia64_local_hash_entry *loc_h; | |
3577 | ||
3578 | loc_h = get_local_sym_hash (ia64_info, input_bfd, rel, false); | |
3579 | if (loc_h && ! loc_h->sec_merge_done) | |
3580 | { | |
3581 | struct elfNN_ia64_dyn_sym_info *dynent; | |
3582 | asection *msec; | |
3583 | ||
3584 | for (dynent = loc_h->info; dynent; dynent = dynent->next) | |
3585 | { | |
3586 | msec = sym_sec; | |
3587 | dynent->addend = | |
3588 | _bfd_merged_section_offset (output_bfd, &msec, | |
3589 | elf_section_data (msec)-> | |
65765700 | 3590 | sec_info, |
f7460f5f JJ |
3591 | sym->st_value |
3592 | + dynent->addend, | |
3593 | (bfd_vma) 0); | |
3594 | dynent->addend -= sym->st_value; | |
3595 | dynent->addend += msec->output_section->vma | |
3596 | + msec->output_offset | |
3597 | - sym_sec->output_section->vma | |
3598 | - sym_sec->output_offset; | |
3599 | } | |
3600 | loc_h->sec_merge_done = 1; | |
3601 | } | |
3602 | } | |
800eeca4 JW |
3603 | } |
3604 | else | |
3605 | { | |
3606 | long indx; | |
3607 | ||
3608 | /* Reloc against global symbol. */ | |
3609 | indx = r_symndx - symtab_hdr->sh_info; | |
3610 | h = elf_sym_hashes (input_bfd)[indx]; | |
3611 | while (h->root.type == bfd_link_hash_indirect | |
3612 | || h->root.type == bfd_link_hash_warning) | |
3613 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
3614 | ||
3615 | value = 0; | |
3616 | if (h->root.type == bfd_link_hash_defined | |
3617 | || h->root.type == bfd_link_hash_defweak) | |
3618 | { | |
3619 | sym_sec = h->root.u.def.section; | |
3620 | ||
3621 | /* Detect the cases that sym_sec->output_section is | |
3622 | expected to be NULL -- all cases in which the symbol | |
3623 | is defined in another shared module. This includes | |
3624 | PLT relocs for which we've created a PLT entry and | |
3625 | other relocs for which we're prepared to create | |
3626 | dynamic relocations. */ | |
3627 | /* ??? Just accept it NULL and continue. */ | |
3628 | ||
3629 | if (sym_sec->output_section != NULL) | |
3630 | { | |
3631 | value = (h->root.u.def.value | |
3632 | + sym_sec->output_section->vma | |
3633 | + sym_sec->output_offset); | |
3634 | } | |
3635 | } | |
3636 | else if (h->root.type == bfd_link_hash_undefweak) | |
3637 | undef_weak_ref = true; | |
671bae9c NC |
3638 | else if (info->shared |
3639 | && (!info->symbolic || info->allow_shlib_undefined) | |
3a27a730 L |
3640 | && !info->no_undefined |
3641 | && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) | |
800eeca4 JW |
3642 | ; |
3643 | else | |
3644 | { | |
3645 | if (! ((*info->callbacks->undefined_symbol) | |
3646 | (info, h->root.root.string, input_bfd, | |
3647 | input_section, rel->r_offset, | |
3a27a730 L |
3648 | (!info->shared || info->no_undefined |
3649 | || ELF_ST_VISIBILITY (h->other))))) | |
800eeca4 JW |
3650 | return false; |
3651 | ret_val = false; | |
3652 | continue; | |
3653 | } | |
3654 | } | |
3655 | ||
3656 | hit_addr = contents + rel->r_offset; | |
3657 | value += rel->r_addend; | |
bbe66d08 | 3658 | dynamic_symbol_p = elfNN_ia64_dynamic_symbol_p (h, info); |
800eeca4 JW |
3659 | |
3660 | switch (r_type) | |
3661 | { | |
3662 | case R_IA64_NONE: | |
3663 | case R_IA64_LDXMOV: | |
3664 | continue; | |
3665 | ||
3666 | case R_IA64_IMM14: | |
3667 | case R_IA64_IMM22: | |
3668 | case R_IA64_IMM64: | |
3669 | case R_IA64_DIR32MSB: | |
3670 | case R_IA64_DIR32LSB: | |
3671 | case R_IA64_DIR64MSB: | |
3672 | case R_IA64_DIR64LSB: | |
3673 | /* Install a dynamic relocation for this reloc. */ | |
7b6dab7f TW |
3674 | if ((dynamic_symbol_p || info->shared |
3675 | || (elfNN_ia64_aix_vec (info->hash->creator) | |
64e9ece0 | 3676 | /* Don't emit relocs for __GLOB_DATA_PTR on AIX. */ |
dc810e39 | 3677 | && (!h || strcmp (h->root.root.string, |
64e9ece0 | 3678 | "__GLOB_DATA_PTR") != 0))) |
ec338859 | 3679 | && r_symndx != 0 |
800eeca4 JW |
3680 | && (input_section->flags & SEC_ALLOC) != 0) |
3681 | { | |
3682 | unsigned int dyn_r_type; | |
3683 | long dynindx; | |
18b27f17 | 3684 | bfd_vma addend; |
800eeca4 JW |
3685 | |
3686 | BFD_ASSERT (srel != NULL); | |
3687 | ||
3688 | /* If we don't need dynamic symbol lookup, find a | |
3689 | matching RELATIVE relocation. */ | |
3690 | dyn_r_type = r_type; | |
3691 | if (dynamic_symbol_p) | |
18b27f17 RH |
3692 | { |
3693 | dynindx = h->dynindx; | |
3694 | addend = rel->r_addend; | |
3695 | value = 0; | |
3696 | } | |
800eeca4 JW |
3697 | else |
3698 | { | |
3699 | switch (r_type) | |
3700 | { | |
3701 | case R_IA64_DIR32MSB: | |
3702 | dyn_r_type = R_IA64_REL32MSB; | |
3703 | break; | |
3704 | case R_IA64_DIR32LSB: | |
3705 | dyn_r_type = R_IA64_REL32LSB; | |
3706 | break; | |
3707 | case R_IA64_DIR64MSB: | |
3708 | dyn_r_type = R_IA64_REL64MSB; | |
3709 | break; | |
3710 | case R_IA64_DIR64LSB: | |
3711 | dyn_r_type = R_IA64_REL64LSB; | |
3712 | break; | |
3713 | ||
3714 | default: | |
3715 | /* We can't represent this without a dynamic symbol. | |
3716 | Adjust the relocation to be against an output | |
3717 | section symbol, which are always present in the | |
3718 | dynamic symbol table. */ | |
3719 | /* ??? People shouldn't be doing non-pic code in | |
3720 | shared libraries. Hork. */ | |
3721 | (*_bfd_error_handler) | |
3722 | (_("%s: linking non-pic code in a shared library"), | |
8f615d07 | 3723 | bfd_archive_filename (input_bfd)); |
800eeca4 JW |
3724 | ret_val = false; |
3725 | continue; | |
3726 | } | |
3727 | dynindx = 0; | |
18b27f17 | 3728 | addend = value; |
800eeca4 JW |
3729 | } |
3730 | ||
7b6dab7f TW |
3731 | if (elfNN_ia64_aix_vec (info->hash->creator)) |
3732 | rel->r_addend = value; | |
bbe66d08 | 3733 | elfNN_ia64_install_dyn_reloc (output_bfd, info, input_section, |
800eeca4 | 3734 | srel, rel->r_offset, dyn_r_type, |
18b27f17 | 3735 | dynindx, addend); |
800eeca4 JW |
3736 | } |
3737 | /* FALLTHRU */ | |
3738 | ||
3739 | case R_IA64_LTV32MSB: | |
3740 | case R_IA64_LTV32LSB: | |
3741 | case R_IA64_LTV64MSB: | |
3742 | case R_IA64_LTV64LSB: | |
bbe66d08 | 3743 | r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type); |
800eeca4 JW |
3744 | break; |
3745 | ||
3746 | case R_IA64_GPREL22: | |
3747 | case R_IA64_GPREL64I: | |
3748 | case R_IA64_GPREL32MSB: | |
3749 | case R_IA64_GPREL32LSB: | |
3750 | case R_IA64_GPREL64MSB: | |
3751 | case R_IA64_GPREL64LSB: | |
3752 | if (dynamic_symbol_p) | |
3753 | { | |
3754 | (*_bfd_error_handler) | |
3755 | (_("%s: @gprel relocation against dynamic symbol %s"), | |
8f615d07 | 3756 | bfd_archive_filename (input_bfd), h->root.root.string); |
800eeca4 JW |
3757 | ret_val = false; |
3758 | continue; | |
3759 | } | |
3760 | value -= gp_val; | |
bbe66d08 | 3761 | r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type); |
800eeca4 JW |
3762 | break; |
3763 | ||
3764 | case R_IA64_LTOFF22: | |
3765 | case R_IA64_LTOFF22X: | |
3766 | case R_IA64_LTOFF64I: | |
3767 | dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, false); | |
3768 | value = set_got_entry (input_bfd, info, dyn_i, (h ? h->dynindx : -1), | |
3769 | rel->r_addend, value, R_IA64_DIR64LSB); | |
3770 | value -= gp_val; | |
bbe66d08 | 3771 | r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type); |
800eeca4 JW |
3772 | break; |
3773 | ||
3774 | case R_IA64_PLTOFF22: | |
3775 | case R_IA64_PLTOFF64I: | |
3776 | case R_IA64_PLTOFF64MSB: | |
3777 | case R_IA64_PLTOFF64LSB: | |
3778 | dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, false); | |
3779 | value = set_pltoff_entry (output_bfd, info, dyn_i, value, false); | |
3780 | value -= gp_val; | |
bbe66d08 | 3781 | r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type); |
800eeca4 JW |
3782 | break; |
3783 | ||
3784 | case R_IA64_FPTR64I: | |
3785 | case R_IA64_FPTR32MSB: | |
3786 | case R_IA64_FPTR32LSB: | |
3787 | case R_IA64_FPTR64MSB: | |
3788 | case R_IA64_FPTR64LSB: | |
3789 | dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, false); | |
3790 | if (dyn_i->want_fptr) | |
3791 | { | |
3792 | if (!undef_weak_ref) | |
3793 | value = set_fptr_entry (output_bfd, info, dyn_i, value); | |
3794 | } | |
3795 | else | |
3796 | { | |
3797 | long dynindx; | |
3798 | ||
3799 | /* Otherwise, we expect the dynamic linker to create | |
3800 | the entry. */ | |
3801 | ||
3802 | if (h) | |
3803 | { | |
3804 | if (h->dynindx != -1) | |
3805 | dynindx = h->dynindx; | |
3806 | else | |
3807 | dynindx = (_bfd_elf_link_lookup_local_dynindx | |
3808 | (info, h->root.u.def.section->owner, | |
3809 | global_sym_index (h))); | |
3810 | } | |
3811 | else | |
3812 | { | |
3813 | dynindx = (_bfd_elf_link_lookup_local_dynindx | |
dc810e39 | 3814 | (info, input_bfd, (long) r_symndx)); |
800eeca4 JW |
3815 | } |
3816 | ||
bbe66d08 | 3817 | elfNN_ia64_install_dyn_reloc (output_bfd, info, input_section, |
800eeca4 JW |
3818 | srel, rel->r_offset, r_type, |
3819 | dynindx, rel->r_addend); | |
3820 | value = 0; | |
3821 | } | |
3822 | ||
bbe66d08 | 3823 | r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type); |
800eeca4 JW |
3824 | break; |
3825 | ||
3826 | case R_IA64_LTOFF_FPTR22: | |
3827 | case R_IA64_LTOFF_FPTR64I: | |
a4bd8390 JW |
3828 | case R_IA64_LTOFF_FPTR32MSB: |
3829 | case R_IA64_LTOFF_FPTR32LSB: | |
800eeca4 JW |
3830 | case R_IA64_LTOFF_FPTR64MSB: |
3831 | case R_IA64_LTOFF_FPTR64LSB: | |
3832 | { | |
3833 | long dynindx; | |
3834 | ||
3835 | dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, false); | |
3836 | if (dyn_i->want_fptr) | |
3837 | { | |
3838 | BFD_ASSERT (h == NULL || h->dynindx == -1) | |
3839 | if (!undef_weak_ref) | |
3840 | value = set_fptr_entry (output_bfd, info, dyn_i, value); | |
3841 | dynindx = -1; | |
3842 | } | |
3843 | else | |
3844 | { | |
3845 | /* Otherwise, we expect the dynamic linker to create | |
3846 | the entry. */ | |
3847 | if (h) | |
3848 | { | |
3849 | if (h->dynindx != -1) | |
3850 | dynindx = h->dynindx; | |
3851 | else | |
3852 | dynindx = (_bfd_elf_link_lookup_local_dynindx | |
3853 | (info, h->root.u.def.section->owner, | |
3854 | global_sym_index (h))); | |
3855 | } | |
3856 | else | |
3857 | dynindx = (_bfd_elf_link_lookup_local_dynindx | |
dc810e39 | 3858 | (info, input_bfd, (long) r_symndx)); |
800eeca4 JW |
3859 | value = 0; |
3860 | } | |
3861 | ||
3862 | value = set_got_entry (output_bfd, info, dyn_i, dynindx, | |
3863 | rel->r_addend, value, R_IA64_FPTR64LSB); | |
3864 | value -= gp_val; | |
bbe66d08 | 3865 | r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type); |
800eeca4 JW |
3866 | } |
3867 | break; | |
3868 | ||
3869 | case R_IA64_PCREL32MSB: | |
3870 | case R_IA64_PCREL32LSB: | |
3871 | case R_IA64_PCREL64MSB: | |
3872 | case R_IA64_PCREL64LSB: | |
3873 | /* Install a dynamic relocation for this reloc. */ | |
ec338859 AM |
3874 | if ((dynamic_symbol_p |
3875 | || elfNN_ia64_aix_vec (info->hash->creator)) | |
3876 | && r_symndx != 0) | |
800eeca4 JW |
3877 | { |
3878 | BFD_ASSERT (srel != NULL); | |
3879 | ||
bbe66d08 | 3880 | elfNN_ia64_install_dyn_reloc (output_bfd, info, input_section, |
800eeca4 JW |
3881 | srel, rel->r_offset, r_type, |
3882 | h->dynindx, rel->r_addend); | |
3883 | } | |
3884 | goto finish_pcrel; | |
3885 | ||
748abff6 | 3886 | case R_IA64_PCREL21BI: |
800eeca4 JW |
3887 | case R_IA64_PCREL21F: |
3888 | case R_IA64_PCREL21M: | |
3889 | /* ??? These two are only used for speculation fixup code. | |
3890 | They should never be dynamic. */ | |
3891 | if (dynamic_symbol_p) | |
3892 | { | |
3893 | (*_bfd_error_handler) | |
3894 | (_("%s: dynamic relocation against speculation fixup"), | |
8f615d07 | 3895 | bfd_archive_filename (input_bfd)); |
800eeca4 JW |
3896 | ret_val = false; |
3897 | continue; | |
3898 | } | |
3899 | if (undef_weak_ref) | |
3900 | { | |
3901 | (*_bfd_error_handler) | |
3902 | (_("%s: speculation fixup against undefined weak symbol"), | |
8f615d07 | 3903 | bfd_archive_filename (input_bfd)); |
800eeca4 JW |
3904 | ret_val = false; |
3905 | continue; | |
3906 | } | |
3907 | goto finish_pcrel; | |
3908 | ||
3909 | case R_IA64_PCREL21B: | |
748abff6 | 3910 | case R_IA64_PCREL60B: |
800eeca4 | 3911 | /* We should have created a PLT entry for any dynamic symbol. */ |
800eeca4 JW |
3912 | dyn_i = NULL; |
3913 | if (h) | |
3914 | dyn_i = get_dyn_sym_info (ia64_info, h, NULL, NULL, false); | |
3915 | ||
3916 | if (dyn_i && dyn_i->want_plt2) | |
3917 | { | |
3918 | /* Should have caught this earlier. */ | |
3919 | BFD_ASSERT (rel->r_addend == 0); | |
3920 | ||
3921 | value = (ia64_info->plt_sec->output_section->vma | |
3922 | + ia64_info->plt_sec->output_offset | |
3923 | + dyn_i->plt2_offset); | |
3924 | } | |
3925 | else | |
3926 | { | |
3927 | /* Since there's no PLT entry, Validate that this is | |
3928 | locally defined. */ | |
3929 | BFD_ASSERT (undef_weak_ref || sym_sec->output_section != NULL); | |
3930 | ||
3931 | /* If the symbol is undef_weak, we shouldn't be trying | |
3932 | to call it. There's every chance that we'd wind up | |
3933 | with an out-of-range fixup here. Don't bother setting | |
3934 | any value at all. */ | |
3935 | if (undef_weak_ref) | |
3936 | continue; | |
3937 | } | |
3938 | goto finish_pcrel; | |
3939 | ||
748abff6 RH |
3940 | case R_IA64_PCREL22: |
3941 | case R_IA64_PCREL64I: | |
800eeca4 JW |
3942 | finish_pcrel: |
3943 | /* Make pc-relative. */ | |
3944 | value -= (input_section->output_section->vma | |
3945 | + input_section->output_offset | |
3946 | + rel->r_offset) & ~ (bfd_vma) 0x3; | |
bbe66d08 | 3947 | r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type); |
800eeca4 JW |
3948 | break; |
3949 | ||
3950 | case R_IA64_SEGREL32MSB: | |
3951 | case R_IA64_SEGREL32LSB: | |
3952 | case R_IA64_SEGREL64MSB: | |
3953 | case R_IA64_SEGREL64LSB: | |
d7458677 AM |
3954 | if (r_symndx == 0) |
3955 | { | |
3956 | /* If the input section was discarded from the output, then | |
3957 | do nothing. */ | |
3958 | r = bfd_reloc_ok; | |
3959 | } | |
3960 | else | |
3961 | { | |
3962 | struct elf_segment_map *m; | |
3963 | Elf_Internal_Phdr *p; | |
3964 | ||
3965 | /* Find the segment that contains the output_section. */ | |
3966 | for (m = elf_tdata (output_bfd)->segment_map, | |
3967 | p = elf_tdata (output_bfd)->phdr; | |
3968 | m != NULL; | |
3969 | m = m->next, p++) | |
3970 | { | |
3971 | int i; | |
3972 | for (i = m->count - 1; i >= 0; i--) | |
3973 | if (m->sections[i] == sym_sec->output_section) | |
3974 | break; | |
3975 | if (i >= 0) | |
800eeca4 | 3976 | break; |
d7458677 | 3977 | } |
800eeca4 | 3978 | |
d7458677 AM |
3979 | if (m == NULL) |
3980 | { | |
800eeca4 | 3981 | r = bfd_reloc_notsupported; |
d7458677 AM |
3982 | } |
3983 | else | |
3984 | { | |
3985 | /* The VMA of the segment is the vaddr of the associated | |
3986 | program header. */ | |
3987 | if (value > p->p_vaddr) | |
3988 | value -= p->p_vaddr; | |
3989 | else | |
3990 | value = 0; | |
3991 | r = elfNN_ia64_install_value (output_bfd, hit_addr, value, | |
3992 | r_type); | |
3993 | } | |
3994 | break; | |
3995 | } | |
800eeca4 JW |
3996 | |
3997 | case R_IA64_SECREL32MSB: | |
3998 | case R_IA64_SECREL32LSB: | |
3999 | case R_IA64_SECREL64MSB: | |
4000 | case R_IA64_SECREL64LSB: | |
4001 | /* Make output-section relative. */ | |
4002 | if (value > input_section->output_section->vma) | |
4003 | value -= input_section->output_section->vma; | |
4004 | else | |
4005 | value = 0; | |
bbe66d08 | 4006 | r = elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type); |
800eeca4 JW |
4007 | break; |
4008 | ||
800eeca4 JW |
4009 | case R_IA64_IPLTMSB: |
4010 | case R_IA64_IPLTLSB: | |
18b27f17 RH |
4011 | /* Install a dynamic relocation for this reloc. */ |
4012 | if ((dynamic_symbol_p || info->shared) | |
4013 | && (input_section->flags & SEC_ALLOC) != 0) | |
4014 | { | |
18b27f17 RH |
4015 | BFD_ASSERT (srel != NULL); |
4016 | ||
4017 | /* If we don't need dynamic symbol lookup, install two | |
4018 | RELATIVE relocations. */ | |
4019 | if (! dynamic_symbol_p) | |
4020 | { | |
4021 | unsigned int dyn_r_type; | |
3e932841 | 4022 | |
18b27f17 RH |
4023 | if (r_type == R_IA64_IPLTMSB) |
4024 | dyn_r_type = R_IA64_REL64MSB; | |
4025 | else | |
4026 | dyn_r_type = R_IA64_REL64LSB; | |
4027 | ||
4028 | elfNN_ia64_install_dyn_reloc (output_bfd, info, | |
4029 | input_section, | |
4030 | srel, rel->r_offset, | |
4031 | dyn_r_type, 0, value); | |
4032 | elfNN_ia64_install_dyn_reloc (output_bfd, info, | |
4033 | input_section, | |
4034 | srel, rel->r_offset + 8, | |
4035 | dyn_r_type, 0, gp_val); | |
4036 | } | |
4037 | else | |
4038 | elfNN_ia64_install_dyn_reloc (output_bfd, info, input_section, | |
4039 | srel, rel->r_offset, r_type, | |
4040 | h->dynindx, rel->r_addend); | |
4041 | } | |
4042 | ||
4043 | if (r_type == R_IA64_IPLTMSB) | |
4044 | r_type = R_IA64_DIR64MSB; | |
4045 | else | |
4046 | r_type = R_IA64_DIR64LSB; | |
4047 | elfNN_ia64_install_value (output_bfd, hit_addr, value, r_type); | |
4048 | r = elfNN_ia64_install_value (output_bfd, hit_addr + 8, gp_val, | |
4049 | r_type); | |
4050 | break; | |
800eeca4 | 4051 | |
800eeca4 JW |
4052 | default: |
4053 | r = bfd_reloc_notsupported; | |
4054 | break; | |
4055 | } | |
4056 | ||
4057 | switch (r) | |
4058 | { | |
4059 | case bfd_reloc_ok: | |
4060 | break; | |
4061 | ||
4062 | case bfd_reloc_undefined: | |
4063 | /* This can happen for global table relative relocs if | |
4064 | __gp is undefined. This is a panic situation so we | |
4065 | don't try to continue. */ | |
4066 | (*info->callbacks->undefined_symbol) | |
4067 | (info, "__gp", input_bfd, input_section, rel->r_offset, 1); | |
4068 | return false; | |
4069 | ||
4070 | case bfd_reloc_notsupported: | |
4071 | { | |
4072 | const char *name; | |
4073 | ||
4074 | if (h) | |
4075 | name = h->root.root.string; | |
4076 | else | |
4077 | { | |
4078 | name = bfd_elf_string_from_elf_section (input_bfd, | |
4079 | symtab_hdr->sh_link, | |
4080 | sym->st_name); | |
4081 | if (name == NULL) | |
4082 | return false; | |
4083 | if (*name == '\0') | |
4084 | name = bfd_section_name (input_bfd, input_section); | |
4085 | } | |
4086 | if (!(*info->callbacks->warning) (info, _("unsupported reloc"), | |
4087 | name, input_bfd, | |
4088 | input_section, rel->r_offset)) | |
4089 | return false; | |
4090 | ret_val = false; | |
4091 | } | |
4092 | break; | |
4093 | ||
4094 | case bfd_reloc_dangerous: | |
4095 | case bfd_reloc_outofrange: | |
4096 | case bfd_reloc_overflow: | |
4097 | default: | |
4098 | { | |
4099 | const char *name; | |
4100 | ||
4101 | if (h) | |
4102 | name = h->root.root.string; | |
4103 | else | |
4104 | { | |
4105 | name = bfd_elf_string_from_elf_section (input_bfd, | |
4106 | symtab_hdr->sh_link, | |
4107 | sym->st_name); | |
4108 | if (name == NULL) | |
4109 | return false; | |
4110 | if (*name == '\0') | |
4111 | name = bfd_section_name (input_bfd, input_section); | |
4112 | } | |
4113 | if (!(*info->callbacks->reloc_overflow) (info, name, | |
dc810e39 AM |
4114 | howto->name, |
4115 | (bfd_vma) 0, | |
800eeca4 JW |
4116 | input_bfd, |
4117 | input_section, | |
4118 | rel->r_offset)) | |
4119 | return false; | |
4120 | ret_val = false; | |
4121 | } | |
4122 | break; | |
4123 | } | |
4124 | } | |
4125 | ||
4126 | return ret_val; | |
4127 | } | |
4128 | ||
4129 | static boolean | |
bbe66d08 | 4130 | elfNN_ia64_finish_dynamic_symbol (output_bfd, info, h, sym) |
800eeca4 JW |
4131 | bfd *output_bfd; |
4132 | struct bfd_link_info *info; | |
4133 | struct elf_link_hash_entry *h; | |
4134 | Elf_Internal_Sym *sym; | |
4135 | { | |
bbe66d08 JW |
4136 | struct elfNN_ia64_link_hash_table *ia64_info; |
4137 | struct elfNN_ia64_dyn_sym_info *dyn_i; | |
800eeca4 | 4138 | |
bbe66d08 | 4139 | ia64_info = elfNN_ia64_hash_table (info); |
800eeca4 JW |
4140 | dyn_i = get_dyn_sym_info (ia64_info, h, NULL, NULL, false); |
4141 | ||
4142 | /* Fill in the PLT data, if required. */ | |
4143 | if (dyn_i && dyn_i->want_plt) | |
4144 | { | |
4145 | Elf_Internal_Rela outrel; | |
4146 | bfd_byte *loc; | |
4147 | asection *plt_sec; | |
4148 | bfd_vma plt_addr, pltoff_addr, gp_val, index; | |
bbe66d08 | 4149 | ElfNN_External_Rela *rel; |
800eeca4 JW |
4150 | |
4151 | gp_val = _bfd_get_gp_value (output_bfd); | |
4152 | ||
4153 | /* Initialize the minimal PLT entry. */ | |
4154 | ||
4155 | index = (dyn_i->plt_offset - PLT_HEADER_SIZE) / PLT_MIN_ENTRY_SIZE; | |
4156 | plt_sec = ia64_info->plt_sec; | |
4157 | loc = plt_sec->contents + dyn_i->plt_offset; | |
4158 | ||
4159 | memcpy (loc, plt_min_entry, PLT_MIN_ENTRY_SIZE); | |
bbe66d08 JW |
4160 | elfNN_ia64_install_value (output_bfd, loc, index, R_IA64_IMM22); |
4161 | elfNN_ia64_install_value (output_bfd, loc+2, -dyn_i->plt_offset, | |
800eeca4 JW |
4162 | R_IA64_PCREL21B); |
4163 | ||
4164 | plt_addr = (plt_sec->output_section->vma | |
4165 | + plt_sec->output_offset | |
4166 | + dyn_i->plt_offset); | |
4167 | pltoff_addr = set_pltoff_entry (output_bfd, info, dyn_i, plt_addr, true); | |
4168 | ||
4169 | /* Initialize the FULL PLT entry, if needed. */ | |
4170 | if (dyn_i->want_plt2) | |
4171 | { | |
4172 | loc = plt_sec->contents + dyn_i->plt2_offset; | |
4173 | ||
4174 | memcpy (loc, plt_full_entry, PLT_FULL_ENTRY_SIZE); | |
bbe66d08 | 4175 | elfNN_ia64_install_value (output_bfd, loc, pltoff_addr - gp_val, |
800eeca4 JW |
4176 | R_IA64_IMM22); |
4177 | ||
4178 | /* Mark the symbol as undefined, rather than as defined in the | |
4179 | plt section. Leave the value alone. */ | |
4180 | /* ??? We didn't redefine it in adjust_dynamic_symbol in the | |
4181 | first place. But perhaps elflink.h did some for us. */ | |
4182 | if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) | |
4183 | sym->st_shndx = SHN_UNDEF; | |
4184 | } | |
4185 | ||
4186 | /* Create the dynamic relocation. */ | |
4187 | outrel.r_offset = pltoff_addr; | |
4188 | if (bfd_little_endian (output_bfd)) | |
bbe66d08 | 4189 | outrel.r_info = ELFNN_R_INFO (h->dynindx, R_IA64_IPLTLSB); |
800eeca4 | 4190 | else |
bbe66d08 | 4191 | outrel.r_info = ELFNN_R_INFO (h->dynindx, R_IA64_IPLTMSB); |
800eeca4 JW |
4192 | outrel.r_addend = 0; |
4193 | ||
4194 | /* This is fun. In the .IA_64.pltoff section, we've got entries | |
4195 | that correspond both to real PLT entries, and those that | |
4196 | happened to resolve to local symbols but need to be created | |
4197 | to satisfy @pltoff relocations. The .rela.IA_64.pltoff | |
4198 | relocations for the real PLT should come at the end of the | |
4199 | section, so that they can be indexed by plt entry at runtime. | |
4200 | ||
4201 | We emitted all of the relocations for the non-PLT @pltoff | |
4202 | entries during relocate_section. So we can consider the | |
4203 | existing sec->reloc_count to be the base of the array of | |
4204 | PLT relocations. */ | |
4205 | ||
bbe66d08 | 4206 | rel = (ElfNN_External_Rela *)ia64_info->rel_pltoff_sec->contents; |
800eeca4 JW |
4207 | rel += ia64_info->rel_pltoff_sec->reloc_count; |
4208 | ||
bbe66d08 | 4209 | bfd_elfNN_swap_reloca_out (output_bfd, &outrel, rel + index); |
800eeca4 JW |
4210 | } |
4211 | ||
4212 | /* Mark some specially defined symbols as absolute. */ | |
4213 | if (strcmp (h->root.root.string, "_DYNAMIC") == 0 | |
4214 | || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0 | |
4215 | || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0) | |
4216 | sym->st_shndx = SHN_ABS; | |
4217 | ||
4218 | return true; | |
4219 | } | |
4220 | ||
4221 | static boolean | |
bbe66d08 | 4222 | elfNN_ia64_finish_dynamic_sections (abfd, info) |
800eeca4 JW |
4223 | bfd *abfd; |
4224 | struct bfd_link_info *info; | |
4225 | { | |
bbe66d08 | 4226 | struct elfNN_ia64_link_hash_table *ia64_info; |
800eeca4 JW |
4227 | bfd *dynobj; |
4228 | ||
bbe66d08 | 4229 | ia64_info = elfNN_ia64_hash_table (info); |
800eeca4 JW |
4230 | dynobj = ia64_info->root.dynobj; |
4231 | ||
4232 | if (elf_hash_table (info)->dynamic_sections_created) | |
4233 | { | |
bbe66d08 | 4234 | ElfNN_External_Dyn *dyncon, *dynconend; |
800eeca4 JW |
4235 | asection *sdyn, *sgotplt; |
4236 | bfd_vma gp_val; | |
4237 | ||
4238 | sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); | |
4239 | sgotplt = bfd_get_section_by_name (dynobj, ".got.plt"); | |
4240 | BFD_ASSERT (sdyn != NULL); | |
bbe66d08 JW |
4241 | dyncon = (ElfNN_External_Dyn *) sdyn->contents; |
4242 | dynconend = (ElfNN_External_Dyn *) (sdyn->contents + sdyn->_raw_size); | |
800eeca4 JW |
4243 | |
4244 | gp_val = _bfd_get_gp_value (abfd); | |
4245 | ||
4246 | for (; dyncon < dynconend; dyncon++) | |
4247 | { | |
4248 | Elf_Internal_Dyn dyn; | |
800eeca4 | 4249 | |
bbe66d08 | 4250 | bfd_elfNN_swap_dyn_in (dynobj, dyncon, &dyn); |
800eeca4 JW |
4251 | |
4252 | switch (dyn.d_tag) | |
4253 | { | |
4254 | case DT_PLTGOT: | |
4255 | dyn.d_un.d_ptr = gp_val; | |
4256 | break; | |
4257 | ||
4258 | case DT_PLTRELSZ: | |
4259 | dyn.d_un.d_val = (ia64_info->minplt_entries | |
bbe66d08 | 4260 | * sizeof (ElfNN_External_Rela)); |
800eeca4 JW |
4261 | break; |
4262 | ||
4263 | case DT_JMPREL: | |
4264 | /* See the comment above in finish_dynamic_symbol. */ | |
4265 | dyn.d_un.d_ptr = (ia64_info->rel_pltoff_sec->output_section->vma | |
4266 | + ia64_info->rel_pltoff_sec->output_offset | |
4267 | + (ia64_info->rel_pltoff_sec->reloc_count | |
bbe66d08 | 4268 | * sizeof (ElfNN_External_Rela))); |
800eeca4 JW |
4269 | break; |
4270 | ||
4271 | case DT_IA_64_PLT_RESERVE: | |
4272 | dyn.d_un.d_ptr = (sgotplt->output_section->vma | |
4273 | + sgotplt->output_offset); | |
4274 | break; | |
4275 | ||
4276 | case DT_RELASZ: | |
4277 | /* Do not have RELASZ include JMPREL. This makes things | |
3e932841 | 4278 | easier on ld.so. This is not what the rest of BFD set up. */ |
800eeca4 | 4279 | dyn.d_un.d_val -= (ia64_info->minplt_entries |
bbe66d08 | 4280 | * sizeof (ElfNN_External_Rela)); |
800eeca4 | 4281 | break; |
800eeca4 JW |
4282 | } |
4283 | ||
bbe66d08 | 4284 | bfd_elfNN_swap_dyn_out (abfd, &dyn, dyncon); |
800eeca4 JW |
4285 | } |
4286 | ||
4287 | /* Initialize the PLT0 entry */ | |
4288 | if (ia64_info->plt_sec) | |
4289 | { | |
4290 | bfd_byte *loc = ia64_info->plt_sec->contents; | |
4291 | bfd_vma pltres; | |
4292 | ||
4293 | memcpy (loc, plt_header, PLT_HEADER_SIZE); | |
4294 | ||
4295 | pltres = (sgotplt->output_section->vma | |
4296 | + sgotplt->output_offset | |
4297 | - gp_val); | |
4298 | ||
bbe66d08 | 4299 | elfNN_ia64_install_value (abfd, loc+1, pltres, R_IA64_GPREL22); |
800eeca4 JW |
4300 | } |
4301 | } | |
4302 | ||
4303 | return true; | |
4304 | } | |
4305 | \f | |
4306 | /* ELF file flag handling: */ | |
4307 | ||
3e932841 | 4308 | /* Function to keep IA-64 specific file flags. */ |
800eeca4 | 4309 | static boolean |
bbe66d08 | 4310 | elfNN_ia64_set_private_flags (abfd, flags) |
800eeca4 JW |
4311 | bfd *abfd; |
4312 | flagword flags; | |
4313 | { | |
4314 | BFD_ASSERT (!elf_flags_init (abfd) | |
4315 | || elf_elfheader (abfd)->e_flags == flags); | |
4316 | ||
4317 | elf_elfheader (abfd)->e_flags = flags; | |
4318 | elf_flags_init (abfd) = true; | |
4319 | return true; | |
4320 | } | |
4321 | ||
800eeca4 JW |
4322 | /* Merge backend specific data from an object file to the output |
4323 | object file when linking. */ | |
4324 | static boolean | |
bbe66d08 | 4325 | elfNN_ia64_merge_private_bfd_data (ibfd, obfd) |
800eeca4 JW |
4326 | bfd *ibfd, *obfd; |
4327 | { | |
4328 | flagword out_flags; | |
4329 | flagword in_flags; | |
4330 | boolean ok = true; | |
4331 | ||
4332 | /* Don't even pretend to support mixed-format linking. */ | |
4333 | if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour | |
4334 | || bfd_get_flavour (obfd) != bfd_target_elf_flavour) | |
4335 | return false; | |
4336 | ||
4337 | in_flags = elf_elfheader (ibfd)->e_flags; | |
4338 | out_flags = elf_elfheader (obfd)->e_flags; | |
4339 | ||
4340 | if (! elf_flags_init (obfd)) | |
4341 | { | |
4342 | elf_flags_init (obfd) = true; | |
4343 | elf_elfheader (obfd)->e_flags = in_flags; | |
4344 | ||
4345 | if (bfd_get_arch (obfd) == bfd_get_arch (ibfd) | |
4346 | && bfd_get_arch_info (obfd)->the_default) | |
4347 | { | |
4348 | return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), | |
4349 | bfd_get_mach (ibfd)); | |
4350 | } | |
4351 | ||
4352 | return true; | |
4353 | } | |
4354 | ||
4355 | /* Check flag compatibility. */ | |
4356 | if (in_flags == out_flags) | |
4357 | return true; | |
4358 | ||
c43c2cc5 JW |
4359 | /* Output has EF_IA_64_REDUCEDFP set only if all inputs have it set. */ |
4360 | if (!(in_flags & EF_IA_64_REDUCEDFP) && (out_flags & EF_IA_64_REDUCEDFP)) | |
4361 | elf_elfheader (obfd)->e_flags &= ~EF_IA_64_REDUCEDFP; | |
4362 | ||
800eeca4 JW |
4363 | if ((in_flags & EF_IA_64_TRAPNIL) != (out_flags & EF_IA_64_TRAPNIL)) |
4364 | { | |
4365 | (*_bfd_error_handler) | |
4366 | (_("%s: linking trap-on-NULL-dereference with non-trapping files"), | |
8f615d07 | 4367 | bfd_archive_filename (ibfd)); |
800eeca4 JW |
4368 | |
4369 | bfd_set_error (bfd_error_bad_value); | |
4370 | ok = false; | |
4371 | } | |
4372 | if ((in_flags & EF_IA_64_BE) != (out_flags & EF_IA_64_BE)) | |
4373 | { | |
4374 | (*_bfd_error_handler) | |
4375 | (_("%s: linking big-endian files with little-endian files"), | |
8f615d07 | 4376 | bfd_archive_filename (ibfd)); |
800eeca4 JW |
4377 | |
4378 | bfd_set_error (bfd_error_bad_value); | |
4379 | ok = false; | |
4380 | } | |
4381 | if ((in_flags & EF_IA_64_ABI64) != (out_flags & EF_IA_64_ABI64)) | |
4382 | { | |
4383 | (*_bfd_error_handler) | |
4384 | (_("%s: linking 64-bit files with 32-bit files"), | |
8f615d07 | 4385 | bfd_archive_filename (ibfd)); |
800eeca4 JW |
4386 | |
4387 | bfd_set_error (bfd_error_bad_value); | |
4388 | ok = false; | |
4389 | } | |
c43c2cc5 JW |
4390 | if ((in_flags & EF_IA_64_CONS_GP) != (out_flags & EF_IA_64_CONS_GP)) |
4391 | { | |
4392 | (*_bfd_error_handler) | |
4393 | (_("%s: linking constant-gp files with non-constant-gp files"), | |
8f615d07 | 4394 | bfd_archive_filename (ibfd)); |
c43c2cc5 JW |
4395 | |
4396 | bfd_set_error (bfd_error_bad_value); | |
4397 | ok = false; | |
4398 | } | |
4399 | if ((in_flags & EF_IA_64_NOFUNCDESC_CONS_GP) | |
4400 | != (out_flags & EF_IA_64_NOFUNCDESC_CONS_GP)) | |
4401 | { | |
4402 | (*_bfd_error_handler) | |
4403 | (_("%s: linking auto-pic files with non-auto-pic files"), | |
8f615d07 | 4404 | bfd_archive_filename (ibfd)); |
c43c2cc5 JW |
4405 | |
4406 | bfd_set_error (bfd_error_bad_value); | |
4407 | ok = false; | |
4408 | } | |
800eeca4 JW |
4409 | |
4410 | return ok; | |
4411 | } | |
4412 | ||
4413 | static boolean | |
bbe66d08 | 4414 | elfNN_ia64_print_private_bfd_data (abfd, ptr) |
800eeca4 JW |
4415 | bfd *abfd; |
4416 | PTR ptr; | |
4417 | { | |
4418 | FILE *file = (FILE *) ptr; | |
4419 | flagword flags = elf_elfheader (abfd)->e_flags; | |
4420 | ||
4421 | BFD_ASSERT (abfd != NULL && ptr != NULL); | |
4422 | ||
c43c2cc5 | 4423 | fprintf (file, "private flags = %s%s%s%s%s%s%s%s\n", |
800eeca4 JW |
4424 | (flags & EF_IA_64_TRAPNIL) ? "TRAPNIL, " : "", |
4425 | (flags & EF_IA_64_EXT) ? "EXT, " : "", | |
4426 | (flags & EF_IA_64_BE) ? "BE, " : "LE, ", | |
c43c2cc5 JW |
4427 | (flags & EF_IA_64_REDUCEDFP) ? "REDUCEDFP, " : "", |
4428 | (flags & EF_IA_64_CONS_GP) ? "CONS_GP, " : "", | |
4429 | (flags & EF_IA_64_NOFUNCDESC_CONS_GP) ? "NOFUNCDESC_CONS_GP, " : "", | |
4430 | (flags & EF_IA_64_ABSOLUTE) ? "ABSOLUTE, " : "", | |
800eeca4 | 4431 | (flags & EF_IA_64_ABI64) ? "ABI64" : "ABI32"); |
3e932841 | 4432 | |
800eeca4 JW |
4433 | _bfd_elf_print_private_bfd_data (abfd, ptr); |
4434 | return true; | |
4435 | } | |
db6751f2 JJ |
4436 | |
4437 | static enum elf_reloc_type_class | |
f51e552e AM |
4438 | elfNN_ia64_reloc_type_class (rela) |
4439 | const Elf_Internal_Rela *rela; | |
db6751f2 | 4440 | { |
f51e552e | 4441 | switch ((int) ELFNN_R_TYPE (rela->r_info)) |
db6751f2 JJ |
4442 | { |
4443 | case R_IA64_REL32MSB: | |
4444 | case R_IA64_REL32LSB: | |
4445 | case R_IA64_REL64MSB: | |
4446 | case R_IA64_REL64LSB: | |
4447 | return reloc_class_relative; | |
4448 | case R_IA64_IPLTMSB: | |
4449 | case R_IA64_IPLTLSB: | |
4450 | return reloc_class_plt; | |
4451 | case R_IA64_COPY: | |
4452 | return reloc_class_copy; | |
4453 | default: | |
4454 | return reloc_class_normal; | |
4455 | } | |
4456 | } | |
fcf12726 | 4457 | |
d9cf1b54 AM |
4458 | static boolean |
4459 | elfNN_ia64_hpux_vec (const bfd_target *vec) | |
4460 | { | |
4461 | extern const bfd_target bfd_elfNN_ia64_hpux_big_vec; | |
4462 | return (vec == & bfd_elfNN_ia64_hpux_big_vec); | |
4463 | } | |
4464 | ||
fcf12726 AM |
4465 | static void |
4466 | elfNN_hpux_post_process_headers (abfd, info) | |
4467 | bfd *abfd; | |
4468 | struct bfd_link_info *info ATTRIBUTE_UNUSED; | |
4469 | { | |
4470 | Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd); | |
4471 | ||
4472 | i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_HPUX; | |
4473 | i_ehdrp->e_ident[EI_ABIVERSION] = 1; | |
4474 | } | |
d9cf1b54 AM |
4475 | |
4476 | boolean | |
af746e92 | 4477 | elfNN_hpux_backend_section_from_bfd_section (abfd, sec, retval) |
d9cf1b54 | 4478 | bfd *abfd ATTRIBUTE_UNUSED; |
d9cf1b54 AM |
4479 | asection *sec; |
4480 | int *retval; | |
4481 | { | |
4482 | if (bfd_is_com_section (sec)) | |
4483 | { | |
4484 | *retval = SHN_IA_64_ANSI_COMMON; | |
4485 | return true; | |
4486 | } | |
4487 | return false; | |
4488 | } | |
800eeca4 | 4489 | \f |
bbe66d08 JW |
4490 | #define TARGET_LITTLE_SYM bfd_elfNN_ia64_little_vec |
4491 | #define TARGET_LITTLE_NAME "elfNN-ia64-little" | |
4492 | #define TARGET_BIG_SYM bfd_elfNN_ia64_big_vec | |
4493 | #define TARGET_BIG_NAME "elfNN-ia64-big" | |
800eeca4 JW |
4494 | #define ELF_ARCH bfd_arch_ia64 |
4495 | #define ELF_MACHINE_CODE EM_IA_64 | |
4496 | #define ELF_MACHINE_ALT1 1999 /* EAS2.3 */ | |
4497 | #define ELF_MACHINE_ALT2 1998 /* EAS2.2 */ | |
4498 | #define ELF_MAXPAGESIZE 0x10000 /* 64KB */ | |
4499 | ||
4500 | #define elf_backend_section_from_shdr \ | |
bbe66d08 | 4501 | elfNN_ia64_section_from_shdr |
fa152c49 | 4502 | #define elf_backend_section_flags \ |
bbe66d08 | 4503 | elfNN_ia64_section_flags |
800eeca4 | 4504 | #define elf_backend_fake_sections \ |
bbe66d08 | 4505 | elfNN_ia64_fake_sections |
81545d45 RH |
4506 | #define elf_backend_final_write_processing \ |
4507 | elfNN_ia64_final_write_processing | |
800eeca4 | 4508 | #define elf_backend_add_symbol_hook \ |
bbe66d08 | 4509 | elfNN_ia64_add_symbol_hook |
800eeca4 | 4510 | #define elf_backend_additional_program_headers \ |
bbe66d08 | 4511 | elfNN_ia64_additional_program_headers |
800eeca4 | 4512 | #define elf_backend_modify_segment_map \ |
bbe66d08 | 4513 | elfNN_ia64_modify_segment_map |
800eeca4 | 4514 | #define elf_info_to_howto \ |
bbe66d08 | 4515 | elfNN_ia64_info_to_howto |
800eeca4 | 4516 | |
bbe66d08 JW |
4517 | #define bfd_elfNN_bfd_reloc_type_lookup \ |
4518 | elfNN_ia64_reloc_type_lookup | |
4519 | #define bfd_elfNN_bfd_is_local_label_name \ | |
4520 | elfNN_ia64_is_local_label_name | |
4521 | #define bfd_elfNN_bfd_relax_section \ | |
4522 | elfNN_ia64_relax_section | |
800eeca4 JW |
4523 | |
4524 | /* Stuff for the BFD linker: */ | |
bbe66d08 JW |
4525 | #define bfd_elfNN_bfd_link_hash_table_create \ |
4526 | elfNN_ia64_hash_table_create | |
800eeca4 | 4527 | #define elf_backend_create_dynamic_sections \ |
bbe66d08 | 4528 | elfNN_ia64_create_dynamic_sections |
800eeca4 | 4529 | #define elf_backend_check_relocs \ |
bbe66d08 | 4530 | elfNN_ia64_check_relocs |
800eeca4 | 4531 | #define elf_backend_adjust_dynamic_symbol \ |
bbe66d08 | 4532 | elfNN_ia64_adjust_dynamic_symbol |
800eeca4 | 4533 | #define elf_backend_size_dynamic_sections \ |
bbe66d08 | 4534 | elfNN_ia64_size_dynamic_sections |
800eeca4 | 4535 | #define elf_backend_relocate_section \ |
bbe66d08 | 4536 | elfNN_ia64_relocate_section |
800eeca4 | 4537 | #define elf_backend_finish_dynamic_symbol \ |
bbe66d08 | 4538 | elfNN_ia64_finish_dynamic_symbol |
800eeca4 | 4539 | #define elf_backend_finish_dynamic_sections \ |
bbe66d08 JW |
4540 | elfNN_ia64_finish_dynamic_sections |
4541 | #define bfd_elfNN_bfd_final_link \ | |
4542 | elfNN_ia64_final_link | |
4543 | ||
bbe66d08 JW |
4544 | #define bfd_elfNN_bfd_merge_private_bfd_data \ |
4545 | elfNN_ia64_merge_private_bfd_data | |
4546 | #define bfd_elfNN_bfd_set_private_flags \ | |
4547 | elfNN_ia64_set_private_flags | |
4548 | #define bfd_elfNN_bfd_print_private_bfd_data \ | |
4549 | elfNN_ia64_print_private_bfd_data | |
800eeca4 JW |
4550 | |
4551 | #define elf_backend_plt_readonly 1 | |
4552 | #define elf_backend_want_plt_sym 0 | |
4553 | #define elf_backend_plt_alignment 5 | |
4554 | #define elf_backend_got_header_size 0 | |
4555 | #define elf_backend_plt_header_size PLT_HEADER_SIZE | |
4556 | #define elf_backend_want_got_plt 1 | |
4557 | #define elf_backend_may_use_rel_p 1 | |
4558 | #define elf_backend_may_use_rela_p 1 | |
4559 | #define elf_backend_default_use_rela_p 1 | |
4560 | #define elf_backend_want_dynbss 0 | |
bbe66d08 JW |
4561 | #define elf_backend_copy_indirect_symbol elfNN_ia64_hash_copy_indirect |
4562 | #define elf_backend_hide_symbol elfNN_ia64_hash_hide_symbol | |
db6751f2 | 4563 | #define elf_backend_reloc_type_class elfNN_ia64_reloc_type_class |
800eeca4 | 4564 | |
bbe66d08 | 4565 | #include "elfNN-target.h" |
7b6dab7f TW |
4566 | |
4567 | /* AIX-specific vectors. */ | |
4568 | ||
4569 | #undef TARGET_LITTLE_SYM | |
4570 | #define TARGET_LITTLE_SYM bfd_elfNN_ia64_aix_little_vec | |
4571 | #undef TARGET_LITTLE_NAME | |
4572 | #define TARGET_LITTLE_NAME "elfNN-ia64-aix-little" | |
4573 | #undef TARGET_BIG_SYM | |
4574 | #define TARGET_BIG_SYM bfd_elfNN_ia64_aix_big_vec | |
4575 | #undef TARGET_BIG_NAME | |
4576 | #define TARGET_BIG_NAME "elfNN-ia64-aix-big" | |
4577 | ||
4578 | #undef elf_backend_add_symbol_hook | |
4579 | #define elf_backend_add_symbol_hook elfNN_ia64_aix_add_symbol_hook | |
4580 | ||
4581 | #undef bfd_elfNN_bfd_link_add_symbols | |
4582 | #define bfd_elfNN_bfd_link_add_symbols elfNN_ia64_aix_link_add_symbols | |
4583 | ||
4584 | #define elfNN_bed elfNN_ia64_aix_bed | |
4585 | ||
4586 | #include "elfNN-target.h" | |
fcf12726 AM |
4587 | |
4588 | /* HPUX-specific vectors. */ | |
4589 | ||
4590 | #undef TARGET_LITTLE_SYM | |
4591 | #undef TARGET_LITTLE_NAME | |
4592 | #undef TARGET_BIG_SYM | |
4593 | #define TARGET_BIG_SYM bfd_elfNN_ia64_hpux_big_vec | |
4594 | #undef TARGET_BIG_NAME | |
4595 | #define TARGET_BIG_NAME "elfNN-ia64-hpux-big" | |
4596 | ||
254ed743 NC |
4597 | /* We need to undo the AIX specific functions. */ |
4598 | ||
4599 | #undef elf_backend_add_symbol_hook | |
4600 | #define elf_backend_add_symbol_hook elfNN_ia64_add_symbol_hook | |
4601 | ||
4602 | #undef bfd_elfNN_bfd_link_add_symbols | |
4603 | #define bfd_elfNN_bfd_link_add_symbols _bfd_generic_link_add_symbols | |
4604 | ||
4605 | /* These are HP-UX specific functions. */ | |
4606 | ||
fcf12726 AM |
4607 | #undef elf_backend_post_process_headers |
4608 | #define elf_backend_post_process_headers elfNN_hpux_post_process_headers | |
4609 | ||
d9cf1b54 AM |
4610 | #undef elf_backend_section_from_bfd_section |
4611 | #define elf_backend_section_from_bfd_section elfNN_hpux_backend_section_from_bfd_section | |
4612 | ||
fcf12726 AM |
4613 | #undef ELF_MAXPAGESIZE |
4614 | #define ELF_MAXPAGESIZE 0x1000 /* 1K */ | |
4615 | ||
4616 | #undef elfNN_bed | |
4617 | #define elfNN_bed elfNN_ia64_hpux_bed | |
4618 | ||
4619 | #include "elfNN-target.h" |