1 /* IA-64 support for 64-bit ELF
2 Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
3 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
5 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
25 #include "opcode/ia64.h"
30 * THE RULES for all the stuff the linker creates --
32 * GOT Entries created in response to LTOFF or LTOFF_FPTR
33 * relocations. Dynamic relocs created for dynamic
34 * symbols in an application; REL relocs for locals
35 * in a shared library.
37 * FPTR The canonical function descriptor. Created for local
38 * symbols in applications. Descriptors for dynamic symbols
39 * and local symbols in shared libraries are created by
40 * ld.so. Thus there are no dynamic relocs against these
41 * objects. The FPTR relocs for such _are_ passed through
42 * to the dynamic relocation tables.
44 * FULL_PLT Created for a PCREL21B relocation against a dynamic symbol.
45 * Requires the creation of a PLTOFF entry. This does not
46 * require any dynamic relocations.
48 * PLTOFF Created by PLTOFF relocations. For local symbols, this
49 * is an alternate function descriptor, and in shared libraries
50 * requires two REL relocations. Note that this cannot be
51 * transformed into an FPTR relocation, since it must be in
52 * range of the GP. For dynamic symbols, this is a function
53 * descriptor for a MIN_PLT entry, and requires one IPLT reloc.
55 * MIN_PLT Created by PLTOFF entries against dynamic symbols. This
56 * does not reqire dynamic relocations.
59 #define USE_RELA /* we want RELA relocs, not REL */
61 #define NELEMS(a) ((int) (sizeof (a) / sizeof ((a)[0])))
63 typedef struct bfd_hash_entry
*(*new_hash_entry_func
)
64 PARAMS ((struct bfd_hash_entry
*, struct bfd_hash_table
*, const char *));
66 /* In dynamically (linker-) created sections, we generally need to keep track
67 of the place a symbol or expression got allocated to. This is done via hash
68 tables that store entries of the following type. */
70 struct elfNN_ia64_dyn_sym_info
72 /* The addend for which this entry is relevant. */
75 /* Next addend in the list. */
76 struct elfNN_ia64_dyn_sym_info
*next
;
80 bfd_vma pltoff_offset
;
84 /* The symbol table entry, if any, that this was derrived from. */
85 struct elf_link_hash_entry
*h
;
87 /* Used to count non-got, non-plt relocations for delayed sizing
88 of relocation sections. */
89 struct elfNN_ia64_dyn_reloc_entry
91 struct elfNN_ia64_dyn_reloc_entry
*next
;
97 /* True when the section contents have been updated. */
98 unsigned got_done
: 1;
99 unsigned fptr_done
: 1;
100 unsigned pltoff_done
: 1;
102 /* True for the different kinds of linker data we want created. */
103 unsigned want_got
: 1;
104 unsigned want_fptr
: 1;
105 unsigned want_ltoff_fptr
: 1;
106 unsigned want_plt
: 1;
107 unsigned want_plt2
: 1;
108 unsigned want_pltoff
: 1;
111 struct elfNN_ia64_local_hash_entry
113 struct bfd_hash_entry root
;
114 struct elfNN_ia64_dyn_sym_info
*info
;
117 struct elfNN_ia64_local_hash_table
119 struct bfd_hash_table root
;
120 /* No additional fields for now. */
123 struct elfNN_ia64_link_hash_entry
125 struct elf_link_hash_entry root
;
126 struct elfNN_ia64_dyn_sym_info
*info
;
129 struct elfNN_ia64_link_hash_table
131 /* The main hash table */
132 struct elf_link_hash_table root
;
134 asection
*got_sec
; /* the linkage table section (or NULL) */
135 asection
*rel_got_sec
; /* dynamic relocation section for same */
136 asection
*fptr_sec
; /* function descriptor table (or NULL) */
137 asection
*plt_sec
; /* the primary plt section (or NULL) */
138 asection
*pltoff_sec
; /* private descriptors for plt (or NULL) */
139 asection
*rel_pltoff_sec
; /* dynamic relocation section for same */
141 bfd_size_type minplt_entries
; /* number of minplt entries */
143 struct elfNN_ia64_local_hash_table loc_hash_table
;
146 #define elfNN_ia64_hash_table(p) \
147 ((struct elfNN_ia64_link_hash_table *) ((p)->hash))
149 static bfd_reloc_status_type elfNN_ia64_reloc
150 PARAMS ((bfd
*abfd
, arelent
*reloc
, asymbol
*sym
, PTR data
,
151 asection
*input_section
, bfd
*output_bfd
, char **error_message
));
152 static reloc_howto_type
* lookup_howto
153 PARAMS ((unsigned int rtype
));
154 static reloc_howto_type
*elfNN_ia64_reloc_type_lookup
155 PARAMS ((bfd
*abfd
, bfd_reloc_code_real_type bfd_code
));
156 static void elfNN_ia64_info_to_howto
157 PARAMS ((bfd
*abfd
, arelent
*bfd_reloc
, ElfNN_Internal_Rela
*elf_reloc
));
158 static boolean elfNN_ia64_relax_section
159 PARAMS((bfd
*abfd
, asection
*sec
, struct bfd_link_info
*link_info
,
161 static boolean elfNN_ia64_section_from_shdr
162 PARAMS ((bfd
*, ElfNN_Internal_Shdr
*, char *));
163 static boolean elfNN_ia64_fake_sections
164 PARAMS ((bfd
*abfd
, ElfNN_Internal_Shdr
*hdr
, asection
*sec
));
165 static boolean elfNN_ia64_add_symbol_hook
166 PARAMS ((bfd
*abfd
, struct bfd_link_info
*info
, const Elf_Internal_Sym
*sym
,
167 const char **namep
, flagword
*flagsp
, asection
**secp
,
169 static int elfNN_ia64_additional_program_headers
170 PARAMS ((bfd
*abfd
));
171 static boolean elfNN_ia64_is_local_label_name
172 PARAMS ((bfd
*abfd
, const char *name
));
173 static boolean elfNN_ia64_dynamic_symbol_p
174 PARAMS ((struct elf_link_hash_entry
*h
, struct bfd_link_info
*info
));
175 static boolean elfNN_ia64_local_hash_table_init
176 PARAMS ((struct elfNN_ia64_local_hash_table
*ht
, bfd
*abfd
,
177 new_hash_entry_func
new));
178 static struct bfd_hash_entry
*elfNN_ia64_new_loc_hash_entry
179 PARAMS ((struct bfd_hash_entry
*entry
, struct bfd_hash_table
*table
,
180 const char *string
));
181 static struct bfd_hash_entry
*elfNN_ia64_new_elf_hash_entry
182 PARAMS ((struct bfd_hash_entry
*entry
, struct bfd_hash_table
*table
,
183 const char *string
));
184 static struct bfd_link_hash_table
*elfNN_ia64_hash_table_create
185 PARAMS ((bfd
*abfd
));
186 static struct elfNN_ia64_local_hash_entry
*elfNN_ia64_local_hash_lookup
187 PARAMS ((struct elfNN_ia64_local_hash_table
*table
, const char *string
,
188 boolean create
, boolean copy
));
189 static void elfNN_ia64_dyn_sym_traverse
190 PARAMS ((struct elfNN_ia64_link_hash_table
*ia64_info
,
191 boolean (*func
)(struct elfNN_ia64_dyn_sym_info
*, PTR
),
193 static boolean elfNN_ia64_create_dynamic_sections
194 PARAMS ((bfd
*abfd
, struct bfd_link_info
*info
));
195 static struct elfNN_ia64_dyn_sym_info
* get_dyn_sym_info
196 PARAMS ((struct elfNN_ia64_link_hash_table
*ia64_info
,
197 struct elf_link_hash_entry
*h
,
198 bfd
*abfd
, const Elf_Internal_Rela
*rel
, boolean create
));
199 static asection
*get_got
200 PARAMS ((bfd
*abfd
, struct bfd_link_info
*info
,
201 struct elfNN_ia64_link_hash_table
*ia64_info
));
202 static asection
*get_fptr
203 PARAMS ((bfd
*abfd
, struct bfd_link_info
*info
,
204 struct elfNN_ia64_link_hash_table
*ia64_info
));
205 static asection
*get_pltoff
206 PARAMS ((bfd
*abfd
, struct bfd_link_info
*info
,
207 struct elfNN_ia64_link_hash_table
*ia64_info
));
208 static asection
*get_reloc_section
209 PARAMS ((bfd
*abfd
, struct elfNN_ia64_link_hash_table
*ia64_info
,
210 asection
*sec
, boolean create
));
211 static boolean count_dyn_reloc
212 PARAMS ((bfd
*abfd
, struct elfNN_ia64_dyn_sym_info
*dyn_i
,
213 asection
*srel
, int type
));
214 static boolean elfNN_ia64_check_relocs
215 PARAMS ((bfd
*abfd
, struct bfd_link_info
*info
, asection
*sec
,
216 const Elf_Internal_Rela
*relocs
));
217 static boolean elfNN_ia64_adjust_dynamic_symbol
218 PARAMS ((struct bfd_link_info
*info
, struct elf_link_hash_entry
*h
));
219 static unsigned long global_sym_index
220 PARAMS ((struct elf_link_hash_entry
*h
));
221 static boolean allocate_fptr
222 PARAMS ((struct elfNN_ia64_dyn_sym_info
*dyn_i
, PTR data
));
223 static boolean allocate_global_data_got
224 PARAMS ((struct elfNN_ia64_dyn_sym_info
*dyn_i
, PTR data
));
225 static boolean allocate_global_fptr_got
226 PARAMS ((struct elfNN_ia64_dyn_sym_info
*dyn_i
, PTR data
));
227 static boolean allocate_local_got
228 PARAMS ((struct elfNN_ia64_dyn_sym_info
*dyn_i
, PTR data
));
229 static boolean allocate_pltoff_entries
230 PARAMS ((struct elfNN_ia64_dyn_sym_info
*dyn_i
, PTR data
));
231 static boolean allocate_plt_entries
232 PARAMS ((struct elfNN_ia64_dyn_sym_info
*dyn_i
, PTR data
));
233 static boolean allocate_plt2_entries
234 PARAMS ((struct elfNN_ia64_dyn_sym_info
*dyn_i
, PTR data
));
235 static boolean allocate_dynrel_entries
236 PARAMS ((struct elfNN_ia64_dyn_sym_info
*dyn_i
, PTR data
));
237 static boolean elfNN_ia64_size_dynamic_sections
238 PARAMS ((bfd
*output_bfd
, struct bfd_link_info
*info
));
239 static bfd_reloc_status_type elfNN_ia64_install_value
240 PARAMS ((bfd
*abfd
, bfd_byte
*hit_addr
, bfd_vma val
, unsigned int r_type
));
241 static void elfNN_ia64_install_dyn_reloc
242 PARAMS ((bfd
*abfd
, struct bfd_link_info
*info
, asection
*sec
,
243 asection
*srel
, bfd_vma offset
, unsigned int type
,
244 long dynindx
, bfd_vma addend
));
245 static bfd_vma set_got_entry
246 PARAMS ((bfd
*abfd
, struct bfd_link_info
*info
,
247 struct elfNN_ia64_dyn_sym_info
*dyn_i
, long dynindx
,
248 bfd_vma addend
, bfd_vma value
, unsigned int dyn_r_type
));
249 static bfd_vma set_fptr_entry
250 PARAMS ((bfd
*abfd
, struct bfd_link_info
*info
,
251 struct elfNN_ia64_dyn_sym_info
*dyn_i
,
253 static bfd_vma set_pltoff_entry
254 PARAMS ((bfd
*abfd
, struct bfd_link_info
*info
,
255 struct elfNN_ia64_dyn_sym_info
*dyn_i
,
256 bfd_vma value
, boolean
));
257 static boolean elfNN_ia64_final_link
258 PARAMS ((bfd
*abfd
, struct bfd_link_info
*info
));
259 static boolean elfNN_ia64_relocate_section
260 PARAMS ((bfd
*output_bfd
, struct bfd_link_info
*info
, bfd
*input_bfd
,
261 asection
*input_section
, bfd_byte
*contents
,
262 Elf_Internal_Rela
*relocs
, Elf_Internal_Sym
*local_syms
,
263 asection
**local_sections
));
264 static boolean elfNN_ia64_finish_dynamic_symbol
265 PARAMS ((bfd
*output_bfd
, struct bfd_link_info
*info
,
266 struct elf_link_hash_entry
*h
, Elf_Internal_Sym
*sym
));
267 static boolean elfNN_ia64_finish_dynamic_sections
268 PARAMS ((bfd
*abfd
, struct bfd_link_info
*info
));
269 static boolean elfNN_ia64_set_private_flags
270 PARAMS ((bfd
*abfd
, flagword flags
));
271 static boolean elfNN_ia64_copy_private_bfd_data
272 PARAMS ((bfd
*ibfd
, bfd
*obfd
));
273 static boolean elfNN_ia64_merge_private_bfd_data
274 PARAMS ((bfd
*ibfd
, bfd
*obfd
));
275 static boolean elfNN_ia64_print_private_bfd_data
276 PARAMS ((bfd
*abfd
, PTR ptr
));
279 /* ia64-specific relocation */
281 /* Perform a relocation. Not much to do here as all the hard work is
282 done in elfNN_ia64_final_link_relocate. */
283 static bfd_reloc_status_type
284 elfNN_ia64_reloc (abfd
, reloc
, sym
, data
, input_section
,
285 output_bfd
, error_message
)
290 asection
*input_section
;
292 char **error_message
;
296 reloc
->address
+= input_section
->output_offset
;
299 *error_message
= "Unsupported call to elfNN_ia64_reloc";
300 return bfd_reloc_notsupported
;
303 #define IA64_HOWTO(TYPE, NAME, SIZE, PCREL, IN) \
304 HOWTO (TYPE, 0, SIZE, 0, PCREL, 0, complain_overflow_signed, \
305 elfNN_ia64_reloc, NAME, false, 0, 0, IN)
307 /* This table has to be sorted according to increasing number of the
309 static reloc_howto_type ia64_howto_table
[] =
311 IA64_HOWTO (R_IA64_NONE
, "NONE", 0, false, true),
313 IA64_HOWTO (R_IA64_IMM14
, "IMM14", 0, false, true),
314 IA64_HOWTO (R_IA64_IMM22
, "IMM22", 0, false, true),
315 IA64_HOWTO (R_IA64_IMM64
, "IMM64", 0, false, true),
316 IA64_HOWTO (R_IA64_DIR32MSB
, "DIR32MSB", 2, false, true),
317 IA64_HOWTO (R_IA64_DIR32LSB
, "DIR32LSB", 2, false, true),
318 IA64_HOWTO (R_IA64_DIR64MSB
, "DIR64MSB", 4, false, true),
319 IA64_HOWTO (R_IA64_DIR64LSB
, "DIR64LSB", 4, false, true),
321 IA64_HOWTO (R_IA64_GPREL22
, "GPREL22", 0, false, true),
322 IA64_HOWTO (R_IA64_GPREL64I
, "GPREL64I", 0, false, true),
323 IA64_HOWTO (R_IA64_GPREL32MSB
, "GPREL32MSB", 2, false, true),
324 IA64_HOWTO (R_IA64_GPREL32LSB
, "GPREL32LSB", 2, false, true),
325 IA64_HOWTO (R_IA64_GPREL64MSB
, "GPREL64MSB", 4, false, true),
326 IA64_HOWTO (R_IA64_GPREL64LSB
, "GPREL64LSB", 4, false, true),
328 IA64_HOWTO (R_IA64_LTOFF22
, "LTOFF22", 0, false, true),
329 IA64_HOWTO (R_IA64_LTOFF64I
, "LTOFF64I", 0, false, true),
331 IA64_HOWTO (R_IA64_PLTOFF22
, "PLTOFF22", 0, false, true),
332 IA64_HOWTO (R_IA64_PLTOFF64I
, "PLTOFF64I", 0, false, true),
333 IA64_HOWTO (R_IA64_PLTOFF64MSB
, "PLTOFF64MSB", 4, false, true),
334 IA64_HOWTO (R_IA64_PLTOFF64LSB
, "PLTOFF64LSB", 4, false, true),
336 IA64_HOWTO (R_IA64_FPTR64I
, "FPTR64I", 0, false, true),
337 IA64_HOWTO (R_IA64_FPTR32MSB
, "FPTR32MSB", 2, false, true),
338 IA64_HOWTO (R_IA64_FPTR32LSB
, "FPTR32LSB", 2, false, true),
339 IA64_HOWTO (R_IA64_FPTR64MSB
, "FPTR64MSB", 4, false, true),
340 IA64_HOWTO (R_IA64_FPTR64LSB
, "FPTR64LSB", 4, false, true),
342 IA64_HOWTO (R_IA64_PCREL60B
, "PCREL60B", 0, true, true),
343 IA64_HOWTO (R_IA64_PCREL21B
, "PCREL21B", 0, true, true),
344 IA64_HOWTO (R_IA64_PCREL21M
, "PCREL21M", 0, true, true),
345 IA64_HOWTO (R_IA64_PCREL21F
, "PCREL21F", 0, true, true),
346 IA64_HOWTO (R_IA64_PCREL32MSB
, "PCREL32MSB", 2, true, true),
347 IA64_HOWTO (R_IA64_PCREL32LSB
, "PCREL32LSB", 2, true, true),
348 IA64_HOWTO (R_IA64_PCREL64MSB
, "PCREL64MSB", 4, true, true),
349 IA64_HOWTO (R_IA64_PCREL64LSB
, "PCREL64LSB", 4, true, true),
351 IA64_HOWTO (R_IA64_LTOFF_FPTR22
, "LTOFF_FPTR22", 0, false, true),
352 IA64_HOWTO (R_IA64_LTOFF_FPTR64I
, "LTOFF_FPTR64I", 0, false, true),
353 IA64_HOWTO (R_IA64_LTOFF_FPTR64MSB
, "LTOFF_FPTR64MSB", 4, false, true),
354 IA64_HOWTO (R_IA64_LTOFF_FPTR64LSB
, "LTOFF_FPTR64LSB", 4, false, true),
356 IA64_HOWTO (R_IA64_SEGBASE
, "SEGBASE", 4, false, true),
357 IA64_HOWTO (R_IA64_SEGREL32MSB
, "SEGREL32MSB", 2, false, true),
358 IA64_HOWTO (R_IA64_SEGREL32LSB
, "SEGREL32LSB", 2, false, true),
359 IA64_HOWTO (R_IA64_SEGREL64MSB
, "SEGREL64MSB", 4, false, true),
360 IA64_HOWTO (R_IA64_SEGREL64LSB
, "SEGREL64LSB", 4, false, true),
362 IA64_HOWTO (R_IA64_SECREL32MSB
, "SECREL32MSB", 2, false, true),
363 IA64_HOWTO (R_IA64_SECREL32LSB
, "SECREL32LSB", 2, false, true),
364 IA64_HOWTO (R_IA64_SECREL64MSB
, "SECREL64MSB", 4, false, true),
365 IA64_HOWTO (R_IA64_SECREL64LSB
, "SECREL64LSB", 4, false, true),
367 IA64_HOWTO (R_IA64_REL32MSB
, "REL32MSB", 2, false, true),
368 IA64_HOWTO (R_IA64_REL32LSB
, "REL32LSB", 2, false, true),
369 IA64_HOWTO (R_IA64_REL64MSB
, "REL64MSB", 4, false, true),
370 IA64_HOWTO (R_IA64_REL64LSB
, "REL64LSB", 4, false, true),
372 IA64_HOWTO (R_IA64_LTV32MSB
, "LTV32MSB", 2, false, true),
373 IA64_HOWTO (R_IA64_LTV32LSB
, "LTV32LSB", 2, false, true),
374 IA64_HOWTO (R_IA64_LTV64MSB
, "LTV64MSB", 4, false, true),
375 IA64_HOWTO (R_IA64_LTV64LSB
, "LTV64LSB", 4, false, true),
377 IA64_HOWTO (R_IA64_PCREL21BI
, "PCREL21BI", 0, true, true),
378 IA64_HOWTO (R_IA64_PCREL22
, "PCREL22", 0, true, true),
379 IA64_HOWTO (R_IA64_PCREL64I
, "PCREL64I", 0, true, true),
381 IA64_HOWTO (R_IA64_IPLTMSB
, "IPLTMSB", 4, false, true),
382 IA64_HOWTO (R_IA64_IPLTLSB
, "IPLTLSB", 4, false, true),
383 IA64_HOWTO (R_IA64_EPLTMSB
, "EPLTMSB", 4, false, true),
384 IA64_HOWTO (R_IA64_EPLTLSB
, "EPLTLSB", 4, false, true),
385 IA64_HOWTO (R_IA64_COPY
, "COPY", 4, false, true),
386 IA64_HOWTO (R_IA64_LTOFF22X
, "LTOFF22X", 0, false, true),
387 IA64_HOWTO (R_IA64_LDXMOV
, "LDXMOV", 0, false, true),
389 IA64_HOWTO (R_IA64_TPREL22
, "TPREL22", 0, false, false),
390 IA64_HOWTO (R_IA64_TPREL64MSB
, "TPREL64MSB", 8, false, false),
391 IA64_HOWTO (R_IA64_TPREL64LSB
, "TPREL64LSB", 8, false, false),
392 IA64_HOWTO (R_IA64_LTOFF_TP22
, "LTOFF_TP22", 0, false, false),
395 static unsigned char elf_code_to_howto_index
[R_IA64_MAX_RELOC_CODE
+ 1];
397 /* Given a BFD reloc type, return the matching HOWTO structure. */
399 static reloc_howto_type
*
403 static int inited
= 0;
410 memset (elf_code_to_howto_index
, 0xff, sizeof (elf_code_to_howto_index
));
411 for (i
= 0; i
< NELEMS (ia64_howto_table
); ++i
)
412 elf_code_to_howto_index
[ia64_howto_table
[i
].type
] = i
;
415 BFD_ASSERT (rtype
<= R_IA64_MAX_RELOC_CODE
);
416 i
= elf_code_to_howto_index
[rtype
];
417 if (i
>= NELEMS (ia64_howto_table
))
419 return ia64_howto_table
+ i
;
422 static reloc_howto_type
*
423 elfNN_ia64_reloc_type_lookup (abfd
, bfd_code
)
425 bfd_reloc_code_real_type bfd_code
;
431 case BFD_RELOC_NONE
: rtype
= R_IA64_NONE
; break;
433 case BFD_RELOC_IA64_IMM14
: rtype
= R_IA64_IMM14
; break;
434 case BFD_RELOC_IA64_IMM22
: rtype
= R_IA64_IMM22
; break;
435 case BFD_RELOC_IA64_IMM64
: rtype
= R_IA64_IMM64
; break;
437 case BFD_RELOC_IA64_DIR32MSB
: rtype
= R_IA64_DIR32MSB
; break;
438 case BFD_RELOC_IA64_DIR32LSB
: rtype
= R_IA64_DIR32LSB
; break;
439 case BFD_RELOC_IA64_DIR64MSB
: rtype
= R_IA64_DIR64MSB
; break;
440 case BFD_RELOC_IA64_DIR64LSB
: rtype
= R_IA64_DIR64LSB
; break;
442 case BFD_RELOC_IA64_GPREL22
: rtype
= R_IA64_GPREL22
; break;
443 case BFD_RELOC_IA64_GPREL64I
: rtype
= R_IA64_GPREL64I
; break;
444 case BFD_RELOC_IA64_GPREL32MSB
: rtype
= R_IA64_GPREL32MSB
; break;
445 case BFD_RELOC_IA64_GPREL32LSB
: rtype
= R_IA64_GPREL32LSB
; break;
446 case BFD_RELOC_IA64_GPREL64MSB
: rtype
= R_IA64_GPREL64MSB
; break;
447 case BFD_RELOC_IA64_GPREL64LSB
: rtype
= R_IA64_GPREL64LSB
; break;
449 case BFD_RELOC_IA64_LTOFF22
: rtype
= R_IA64_LTOFF22
; break;
450 case BFD_RELOC_IA64_LTOFF64I
: rtype
= R_IA64_LTOFF64I
; break;
452 case BFD_RELOC_IA64_PLTOFF22
: rtype
= R_IA64_PLTOFF22
; break;
453 case BFD_RELOC_IA64_PLTOFF64I
: rtype
= R_IA64_PLTOFF64I
; break;
454 case BFD_RELOC_IA64_PLTOFF64MSB
: rtype
= R_IA64_PLTOFF64MSB
; break;
455 case BFD_RELOC_IA64_PLTOFF64LSB
: rtype
= R_IA64_PLTOFF64LSB
; break;
456 case BFD_RELOC_IA64_FPTR64I
: rtype
= R_IA64_FPTR64I
; break;
457 case BFD_RELOC_IA64_FPTR32MSB
: rtype
= R_IA64_FPTR32MSB
; break;
458 case BFD_RELOC_IA64_FPTR32LSB
: rtype
= R_IA64_FPTR32LSB
; break;
459 case BFD_RELOC_IA64_FPTR64MSB
: rtype
= R_IA64_FPTR64MSB
; break;
460 case BFD_RELOC_IA64_FPTR64LSB
: rtype
= R_IA64_FPTR64LSB
; break;
462 case BFD_RELOC_IA64_PCREL21B
: rtype
= R_IA64_PCREL21B
; break;
463 case BFD_RELOC_IA64_PCREL21BI
: rtype
= R_IA64_PCREL21BI
; break;
464 case BFD_RELOC_IA64_PCREL21M
: rtype
= R_IA64_PCREL21M
; break;
465 case BFD_RELOC_IA64_PCREL21F
: rtype
= R_IA64_PCREL21F
; break;
466 case BFD_RELOC_IA64_PCREL22
: rtype
= R_IA64_PCREL22
; break;
467 case BFD_RELOC_IA64_PCREL60B
: rtype
= R_IA64_PCREL60B
; break;
468 case BFD_RELOC_IA64_PCREL64I
: rtype
= R_IA64_PCREL64I
; break;
469 case BFD_RELOC_IA64_PCREL32MSB
: rtype
= R_IA64_PCREL32MSB
; break;
470 case BFD_RELOC_IA64_PCREL32LSB
: rtype
= R_IA64_PCREL32LSB
; break;
471 case BFD_RELOC_IA64_PCREL64MSB
: rtype
= R_IA64_PCREL64MSB
; break;
472 case BFD_RELOC_IA64_PCREL64LSB
: rtype
= R_IA64_PCREL64LSB
; break;
474 case BFD_RELOC_IA64_LTOFF_FPTR22
: rtype
= R_IA64_LTOFF_FPTR22
; break;
475 case BFD_RELOC_IA64_LTOFF_FPTR64I
: rtype
= R_IA64_LTOFF_FPTR64I
; break;
476 case BFD_RELOC_IA64_LTOFF_FPTR64MSB
: rtype
= R_IA64_LTOFF_FPTR64MSB
; break;
477 case BFD_RELOC_IA64_LTOFF_FPTR64LSB
: rtype
= R_IA64_LTOFF_FPTR64LSB
; break;
479 case BFD_RELOC_IA64_SEGBASE
: rtype
= R_IA64_SEGBASE
; break;
480 case BFD_RELOC_IA64_SEGREL32MSB
: rtype
= R_IA64_SEGREL32MSB
; break;
481 case BFD_RELOC_IA64_SEGREL32LSB
: rtype
= R_IA64_SEGREL32LSB
; break;
482 case BFD_RELOC_IA64_SEGREL64MSB
: rtype
= R_IA64_SEGREL64MSB
; break;
483 case BFD_RELOC_IA64_SEGREL64LSB
: rtype
= R_IA64_SEGREL64LSB
; break;
485 case BFD_RELOC_IA64_SECREL32MSB
: rtype
= R_IA64_SECREL32MSB
; break;
486 case BFD_RELOC_IA64_SECREL32LSB
: rtype
= R_IA64_SECREL32LSB
; break;
487 case BFD_RELOC_IA64_SECREL64MSB
: rtype
= R_IA64_SECREL64MSB
; break;
488 case BFD_RELOC_IA64_SECREL64LSB
: rtype
= R_IA64_SECREL64LSB
; break;
490 case BFD_RELOC_IA64_REL32MSB
: rtype
= R_IA64_REL32MSB
; break;
491 case BFD_RELOC_IA64_REL32LSB
: rtype
= R_IA64_REL32LSB
; break;
492 case BFD_RELOC_IA64_REL64MSB
: rtype
= R_IA64_REL64MSB
; break;
493 case BFD_RELOC_IA64_REL64LSB
: rtype
= R_IA64_REL64LSB
; break;
495 case BFD_RELOC_IA64_LTV32MSB
: rtype
= R_IA64_LTV32MSB
; break;
496 case BFD_RELOC_IA64_LTV32LSB
: rtype
= R_IA64_LTV32LSB
; break;
497 case BFD_RELOC_IA64_LTV64MSB
: rtype
= R_IA64_LTV64MSB
; break;
498 case BFD_RELOC_IA64_LTV64LSB
: rtype
= R_IA64_LTV64LSB
; break;
500 case BFD_RELOC_IA64_IPLTMSB
: rtype
= R_IA64_IPLTMSB
; break;
501 case BFD_RELOC_IA64_IPLTLSB
: rtype
= R_IA64_IPLTLSB
; break;
502 case BFD_RELOC_IA64_EPLTMSB
: rtype
= R_IA64_EPLTMSB
; break;
503 case BFD_RELOC_IA64_EPLTLSB
: rtype
= R_IA64_EPLTLSB
; break;
504 case BFD_RELOC_IA64_COPY
: rtype
= R_IA64_COPY
; break;
505 case BFD_RELOC_IA64_LTOFF22X
: rtype
= R_IA64_LTOFF22X
; break;
506 case BFD_RELOC_IA64_LDXMOV
: rtype
= R_IA64_LDXMOV
; break;
508 case BFD_RELOC_IA64_TPREL22
: rtype
= R_IA64_TPREL22
; break;
509 case BFD_RELOC_IA64_TPREL64MSB
: rtype
= R_IA64_TPREL64MSB
; break;
510 case BFD_RELOC_IA64_TPREL64LSB
: rtype
= R_IA64_TPREL64LSB
; break;
511 case BFD_RELOC_IA64_LTOFF_TP22
: rtype
= R_IA64_LTOFF_TP22
; break;
515 return lookup_howto (rtype
);
518 /* Given a ELF reloc, return the matching HOWTO structure. */
521 elfNN_ia64_info_to_howto (abfd
, bfd_reloc
, elf_reloc
)
524 ElfNN_Internal_Rela
*elf_reloc
;
526 bfd_reloc
->howto
= lookup_howto (ELFNN_R_TYPE (elf_reloc
->r_info
));
529 #define PLT_HEADER_SIZE (3 * 16)
530 #define PLT_MIN_ENTRY_SIZE (1 * 16)
531 #define PLT_FULL_ENTRY_SIZE (2 * 16)
532 #define PLT_RESERVED_WORDS 3
534 static const bfd_byte plt_header
[PLT_HEADER_SIZE
] =
536 0x0b, 0x10, 0x00, 0x1c, 0x00, 0x21, /* [MMI] mov r2=r14;; */
537 0xe0, 0x00, 0x08, 0x00, 0x48, 0x00, /* addl r14=0,r2 */
538 0x00, 0x00, 0x04, 0x00, /* nop.i 0x0;; */
539 0x0b, 0x80, 0x20, 0x1c, 0x18, 0x14, /* [MMI] ld8 r16=[r14],8;; */
540 0x10, 0x41, 0x38, 0x30, 0x28, 0x00, /* ld8 r17=[r14],8 */
541 0x00, 0x00, 0x04, 0x00, /* nop.i 0x0;; */
542 0x11, 0x08, 0x00, 0x1c, 0x18, 0x10, /* [MIB] ld8 r1=[r14] */
543 0x60, 0x88, 0x04, 0x80, 0x03, 0x00, /* mov b6=r17 */
544 0x60, 0x00, 0x80, 0x00 /* br.few b6;; */
547 static const bfd_byte plt_min_entry
[PLT_MIN_ENTRY_SIZE
] =
549 0x11, 0x78, 0x00, 0x00, 0x00, 0x24, /* [MIB] mov r15=0 */
550 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, /* nop.i 0x0 */
551 0x00, 0x00, 0x00, 0x40 /* br.few 0 <PLT0>;; */
554 static const bfd_byte plt_full_entry
[PLT_FULL_ENTRY_SIZE
] =
556 0x0b, 0x78, 0x00, 0x02, 0x00, 0x24, /* [MMI] addl r15=0,r1;; */
557 0x00, 0x41, 0x3c, 0x30, 0x28, 0xc0, /* ld8 r16=[r15],8 */
558 0x01, 0x08, 0x00, 0x84, /* mov r14=r1;; */
559 0x11, 0x08, 0x00, 0x1e, 0x18, 0x10, /* [MIB] ld8 r1=[r15] */
560 0x60, 0x80, 0x04, 0x80, 0x03, 0x00, /* mov b6=r16 */
561 0x60, 0x00, 0x80, 0x00 /* br.few b6;; */
564 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
566 /* Select out of range branch fixup type. Note that Itanium does
567 not support brl, and so it gets emulated by the kernel. */
570 static const bfd_byte oor_brl
[16] =
572 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MLX] nop.m 0 */
573 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* brl.sptk.few tgt;; */
574 0x00, 0x00, 0x00, 0xc0
577 static const bfd_byte oor_ip
[48] =
579 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MLX] nop.m 0 */
580 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, /* movl r15=0 */
581 0x01, 0x00, 0x00, 0x60,
582 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MII] nop.m 0 */
583 0x00, 0x01, 0x00, 0x60, 0x00, 0x00, /* mov r16=ip;; */
584 0xf2, 0x80, 0x00, 0x80, /* add r16=r15,r16;; */
585 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, /* [MIB] nop.m 0 */
586 0x60, 0x80, 0x04, 0x80, 0x03, 0x00, /* mov b6=r16 */
587 0x60, 0x00, 0x80, 0x00 /* br b6;; */
590 /* These functions do relaxation for IA-64 ELF.
592 This is primarily to support branches to targets out of range;
593 relaxation of R_IA64_LTOFF22X and R_IA64_LDXMOV not yet supported. */
596 elfNN_ia64_relax_section (abfd
, sec
, link_info
, again
)
599 struct bfd_link_info
*link_info
;
604 struct one_fixup
*next
;
610 Elf_Internal_Shdr
*symtab_hdr
;
611 Elf_Internal_Rela
*internal_relocs
;
612 Elf_Internal_Rela
*free_relocs
;
613 Elf_Internal_Rela
*irel
, *irelend
;
615 bfd_byte
*free_contents
;
616 ElfNN_External_Sym
*extsyms
;
617 ElfNN_External_Sym
*free_extsyms
;
618 struct elfNN_ia64_link_hash_table
*ia64_info
;
619 struct one_fixup
*fixups
= NULL
;
620 boolean changed_contents
= false;
621 boolean changed_relocs
= false;
623 /* Assume we're not going to change any sizes, and we'll only need
627 /* Nothing to do if there are no relocations. */
628 if ((sec
->flags
& SEC_RELOC
) == 0
629 || sec
->reloc_count
== 0)
632 /* If this is the first time we have been called for this section,
633 initialize the cooked size. */
634 if (sec
->_cooked_size
== 0)
635 sec
->_cooked_size
= sec
->_raw_size
;
637 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
639 /* Load the relocations for this section. */
640 internal_relocs
= (_bfd_elfNN_link_read_relocs
641 (abfd
, sec
, (PTR
) NULL
, (Elf_Internal_Rela
*) NULL
,
642 link_info
->keep_memory
));
643 if (internal_relocs
== NULL
)
646 if (! link_info
->keep_memory
)
647 free_relocs
= internal_relocs
;
649 ia64_info
= elfNN_ia64_hash_table (link_info
);
650 irelend
= internal_relocs
+ sec
->reloc_count
;
652 for (irel
= internal_relocs
; irel
< irelend
; irel
++)
653 if (ELFNN_R_TYPE (irel
->r_info
) == (int) R_IA64_PCREL21B
)
656 /* No branch-type relocations. */
659 if (free_relocs
!= NULL
)
664 /* Get the section contents. */
665 free_contents
= NULL
;
666 if (elf_section_data (sec
)->this_hdr
.contents
!= NULL
)
667 contents
= elf_section_data (sec
)->this_hdr
.contents
;
670 contents
= (bfd_byte
*) bfd_malloc (sec
->_raw_size
);
671 if (contents
== NULL
)
673 free_contents
= contents
;
675 if (! bfd_get_section_contents (abfd
, sec
, contents
,
676 (file_ptr
) 0, sec
->_raw_size
))
680 /* Read this BFD's symbols. */
682 if (symtab_hdr
->contents
!= NULL
)
683 extsyms
= (ElfNN_External_Sym
*) symtab_hdr
->contents
;
686 extsyms
= (ElfNN_External_Sym
*) bfd_malloc (symtab_hdr
->sh_size
);
689 free_extsyms
= extsyms
;
690 if (bfd_seek (abfd
, symtab_hdr
->sh_offset
, SEEK_SET
) != 0
691 || (bfd_read (extsyms
, 1, symtab_hdr
->sh_size
, abfd
)
692 != symtab_hdr
->sh_size
))
696 for (; irel
< irelend
; irel
++)
698 bfd_vma symaddr
, reladdr
, trampoff
, toff
, roff
;
699 Elf_Internal_Sym isym
;
703 if (ELFNN_R_TYPE (irel
->r_info
) != (int) R_IA64_PCREL21B
)
706 /* Get the value of the symbol referred to by the reloc. */
707 if (ELFNN_R_SYM (irel
->r_info
) < symtab_hdr
->sh_info
)
709 /* A local symbol. */
710 bfd_elfNN_swap_symbol_in (abfd
,
711 extsyms
+ ELFNN_R_SYM (irel
->r_info
),
713 if (isym
.st_shndx
== SHN_UNDEF
)
714 continue; /* We can't do anthing with undefined symbols. */
715 else if (isym
.st_shndx
== SHN_ABS
)
716 tsec
= bfd_abs_section_ptr
;
717 else if (isym
.st_shndx
== SHN_COMMON
)
718 tsec
= bfd_com_section_ptr
;
719 else if (isym
.st_shndx
> 0 && isym
.st_shndx
< SHN_LORESERVE
)
720 tsec
= bfd_section_from_elf_index (abfd
, isym
.st_shndx
);
722 continue; /* who knows. */
724 toff
= isym
.st_value
;
729 struct elf_link_hash_entry
*h
;
730 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
732 indx
= ELFNN_R_SYM (irel
->r_info
) - symtab_hdr
->sh_info
;
733 h
= elf_sym_hashes (abfd
)[indx
];
734 BFD_ASSERT (h
!= NULL
);
736 while (h
->root
.type
== bfd_link_hash_indirect
737 || h
->root
.type
== bfd_link_hash_warning
)
738 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
740 dyn_i
= get_dyn_sym_info (ia64_info
, h
, abfd
, irel
, false);
742 /* For branches to dynamic symbols, we're interested instead
743 in a branch to the PLT entry. */
744 if (dyn_i
&& dyn_i
->want_plt2
)
746 tsec
= ia64_info
->plt_sec
;
747 toff
= dyn_i
->plt2_offset
;
751 /* We can't do anthing with undefined symbols. */
752 if (h
->root
.type
== bfd_link_hash_undefined
753 || h
->root
.type
== bfd_link_hash_undefweak
)
756 tsec
= h
->root
.u
.def
.section
;
757 toff
= h
->root
.u
.def
.value
;
761 symaddr
= (tsec
->output_section
->vma
762 + tsec
->output_offset
766 roff
= irel
->r_offset
;
767 reladdr
= (sec
->output_section
->vma
771 /* If the branch is in range, no need to do anything. */
772 if ((bfd_signed_vma
) (symaddr
- reladdr
) >= -0x1000000
773 && (bfd_signed_vma
) (symaddr
- reladdr
) <= 0x0FFFFF0)
776 /* If the branch and target are in the same section, you've
777 got one honking big section and we can't help you. You'll
778 get an error message later. */
782 /* Look for an existing fixup to this address. */
783 for (f
= fixups
; f
; f
= f
->next
)
784 if (f
->tsec
== tsec
&& f
->toff
== toff
)
789 /* Two alternatives: If it's a branch to a PLT entry, we can
790 make a copy of the FULL_PLT entry. Otherwise, we'll have
791 to use a `brl' insn to get where we're going. */
795 if (tsec
== ia64_info
->plt_sec
)
796 size
= sizeof (plt_full_entry
);
800 size
= sizeof (oor_brl
);
802 size
= sizeof (oor_ip
);
806 /* Resize the current section to make room for the new branch. */
807 trampoff
= (sec
->_cooked_size
+ 15) & -16;
808 contents
= (bfd_byte
*) bfd_realloc (contents
, trampoff
+ size
);
809 if (contents
== NULL
)
811 sec
->_cooked_size
= trampoff
+ size
;
813 if (tsec
== ia64_info
->plt_sec
)
815 memcpy (contents
+ trampoff
, plt_full_entry
, size
);
817 /* Hijack the old relocation for use as the PLTOFF reloc. */
818 irel
->r_info
= ELFNN_R_INFO (ELFNN_R_SYM (irel
->r_info
),
820 irel
->r_offset
= trampoff
;
825 memcpy (contents
+ trampoff
, oor_brl
, size
);
826 irel
->r_info
= ELFNN_R_INFO (ELFNN_R_SYM (irel
->r_info
),
828 irel
->r_offset
= trampoff
+ 2;
830 memcpy (contents
+ trampoff
, oor_ip
, size
);
831 irel
->r_info
= ELFNN_R_INFO (ELFNN_R_SYM (irel
->r_info
),
833 irel
->r_addend
-= 16;
834 irel
->r_offset
= trampoff
+ 2;
838 /* Record the fixup so we don't do it again this section. */
839 f
= (struct one_fixup
*) bfd_malloc (sizeof (*f
));
843 f
->trampoff
= trampoff
;
848 /* Nop out the reloc, since we're finalizing things here. */
849 irel
->r_info
= ELFNN_R_INFO (0, R_IA64_NONE
);
852 /* Fix up the existing branch to hit the trampoline. Hope like
853 hell this doesn't overflow too. */
854 if (elfNN_ia64_install_value (abfd
, contents
+ roff
,
855 f
->trampoff
- (roff
& -4),
856 R_IA64_PCREL21B
) != bfd_reloc_ok
)
859 changed_contents
= true;
860 changed_relocs
= true;
863 /* Clean up and go home. */
866 struct one_fixup
*f
= fixups
;
867 fixups
= fixups
->next
;
872 elf_section_data (sec
)->relocs
= internal_relocs
;
873 else if (free_relocs
!= NULL
)
876 if (changed_contents
)
877 elf_section_data (sec
)->this_hdr
.contents
= contents
;
878 else if (free_contents
!= NULL
)
880 if (! link_info
->keep_memory
)
881 free (free_contents
);
884 /* Cache the section contents for elf_link_input_bfd. */
885 elf_section_data (sec
)->this_hdr
.contents
= contents
;
889 if (free_extsyms
!= NULL
)
891 if (! link_info
->keep_memory
)
895 /* Cache the symbols for elf_link_input_bfd. */
896 symtab_hdr
->contents
= extsyms
;
900 *again
= changed_contents
|| changed_relocs
;
904 if (free_relocs
!= NULL
)
906 if (free_contents
!= NULL
)
907 free (free_contents
);
908 if (free_extsyms
!= NULL
)
913 /* Handle an IA-64 specific section when reading an object file. This
914 is called when elfcode.h finds a section with an unknown type. */
917 elfNN_ia64_section_from_shdr (abfd
, hdr
, name
)
919 ElfNN_Internal_Shdr
*hdr
;
924 /* There ought to be a place to keep ELF backend specific flags, but
925 at the moment there isn't one. We just keep track of the
926 sections by their name, instead. Fortunately, the ABI gives
927 suggested names for all the MIPS specific sections, so we will
928 probably get away with this. */
929 switch (hdr
->sh_type
)
931 case SHT_IA_64_UNWIND
:
932 if (strcmp (name
, ELF_STRING_ia64_unwind
) != 0)
937 if (strcmp (name
, ELF_STRING_ia64_archext
) != 0)
945 if (! _bfd_elf_make_section_from_shdr (abfd
, hdr
, name
))
947 newsect
= hdr
->bfd_section
;
952 /* Convert IA-64 specific section flags to bfd internal section flags. */
954 /* ??? There is no bfd internal flag equivalent to the SHF_IA_64_NORECOV
958 elfNN_ia64_section_flags (flags
, hdr
)
960 ElfNN_Internal_Shdr
*hdr
;
962 if (hdr
->sh_flags
& SHF_IA_64_SHORT
)
963 *flags
|= SEC_SMALL_DATA
;
968 /* Set the correct type for an IA-64 ELF section. We do this by the
969 section name, which is a hack, but ought to work. */
972 elfNN_ia64_fake_sections (abfd
, hdr
, sec
)
974 ElfNN_Internal_Shdr
*hdr
;
977 register const char *name
;
979 name
= bfd_get_section_name (abfd
, sec
);
981 if (strcmp (name
, ELF_STRING_ia64_unwind
) == 0)
982 hdr
->sh_type
= SHT_IA_64_UNWIND
;
983 else if (strcmp (name
, ELF_STRING_ia64_archext
) == 0)
984 hdr
->sh_type
= SHT_IA_64_EXT
;
985 else if (strcmp (name
, ".reloc") == 0)
987 * This is an ugly, but unfortunately necessary hack that is
988 * needed when producing EFI binaries on IA-64. It tells
989 * elf.c:elf_fake_sections() not to consider ".reloc" as a section
990 * containing ELF relocation info. We need this hack in order to
991 * be able to generate ELF binaries that can be translated into
992 * EFI applications (which are essentially COFF objects). Those
993 * files contain a COFF ".reloc" section inside an ELFNN object,
994 * which would normally cause BFD to segfault because it would
995 * attempt to interpret this section as containing relocation
996 * entries for section "oc". With this hack enabled, ".reloc"
997 * will be treated as a normal data section, which will avoid the
998 * segfault. However, you won't be able to create an ELFNN binary
999 * with a section named "oc" that needs relocations, but that's
1000 * the kind of ugly side-effects you get when detecting section
1001 * types based on their names... In practice, this limitation is
1004 hdr
->sh_type
= SHT_PROGBITS
;
1006 if (sec
->flags
& SEC_SMALL_DATA
)
1007 hdr
->sh_flags
|= SHF_IA_64_SHORT
;
1012 /* Hook called by the linker routine which adds symbols from an object
1013 file. We use it to put .comm items in .sbss, and not .bss. */
1016 elfNN_ia64_add_symbol_hook (abfd
, info
, sym
, namep
, flagsp
, secp
, valp
)
1018 struct bfd_link_info
*info
;
1019 const Elf_Internal_Sym
*sym
;
1025 if (sym
->st_shndx
== SHN_COMMON
1026 && !info
->relocateable
1027 && sym
->st_size
<= bfd_get_gp_size (abfd
))
1029 /* Common symbols less than or equal to -G nn bytes are
1030 automatically put into .sbss. */
1032 asection
*scomm
= bfd_get_section_by_name (abfd
, ".scommon");
1036 scomm
= bfd_make_section (abfd
, ".scommon");
1038 || !bfd_set_section_flags (abfd
, scomm
, (SEC_ALLOC
1040 | SEC_LINKER_CREATED
)))
1045 *valp
= sym
->st_size
;
1051 /* Return the number of additional phdrs we will need. */
1054 elfNN_ia64_additional_program_headers (abfd
)
1060 /* See if we need a PT_IA_64_ARCHEXT segment. */
1061 s
= bfd_get_section_by_name (abfd
, ELF_STRING_ia64_archext
);
1062 if (s
&& (s
->flags
& SEC_LOAD
))
1065 /* See if we need a PT_IA_64_UNWIND segment. */
1066 s
= bfd_get_section_by_name (abfd
, ELF_STRING_ia64_unwind
);
1067 if (s
&& (s
->flags
& SEC_LOAD
))
1074 elfNN_ia64_modify_segment_map (abfd
)
1077 struct elf_segment_map
*m
, **pm
;
1080 /* If we need a PT_IA_64_ARCHEXT segment, it must come before
1081 all PT_LOAD segments. */
1082 s
= bfd_get_section_by_name (abfd
, ELF_STRING_ia64_archext
);
1083 if (s
&& (s
->flags
& SEC_LOAD
))
1085 for (m
= elf_tdata (abfd
)->segment_map
; m
!= NULL
; m
= m
->next
)
1086 if (m
->p_type
== PT_IA_64_ARCHEXT
)
1090 m
= (struct elf_segment_map
*) bfd_zalloc (abfd
, sizeof *m
);
1094 m
->p_type
= PT_IA_64_ARCHEXT
;
1098 /* We want to put it after the PHDR and INTERP segments. */
1099 pm
= &elf_tdata (abfd
)->segment_map
;
1101 && ((*pm
)->p_type
== PT_PHDR
1102 || (*pm
)->p_type
== PT_INTERP
))
1110 /* Install the PT_IA_64_UNWIND segment, if needed. */
1111 s
= bfd_get_section_by_name (abfd
, ELF_STRING_ia64_unwind
);
1112 if (s
&& (s
->flags
& SEC_LOAD
))
1114 for (m
= elf_tdata (abfd
)->segment_map
; m
!= NULL
; m
= m
->next
)
1115 if (m
->p_type
== PT_IA_64_UNWIND
)
1119 m
= (struct elf_segment_map
*) bfd_zalloc (abfd
, sizeof *m
);
1123 m
->p_type
= PT_IA_64_UNWIND
;
1128 /* We want to put it last. */
1129 pm
= &elf_tdata (abfd
)->segment_map
;
1136 /* Turn on PF_IA_64_NORECOV if needed. This involves traversing all of
1137 the input sections for each output section in the segment and testing
1138 for SHF_IA_64_NORECOV on each. */
1139 for (m
= elf_tdata (abfd
)->segment_map
; m
!= NULL
; m
= m
->next
)
1140 if (m
->p_type
== PT_LOAD
)
1143 for (i
= m
->count
- 1; i
>= 0; --i
)
1145 struct bfd_link_order
*order
= m
->sections
[i
]->link_order_head
;
1148 if (order
->type
== bfd_indirect_link_order
)
1150 asection
*is
= order
->u
.indirect
.section
;
1151 bfd_vma flags
= elf_section_data(is
)->this_hdr
.sh_flags
;
1152 if (flags
& SHF_IA_64_NORECOV
)
1154 m
->p_flags
|= PF_IA_64_NORECOV
;
1158 order
= order
->next
;
1168 /* According to the Tahoe assembler spec, all labels starting with a
1172 elfNN_ia64_is_local_label_name (abfd
, name
)
1176 return name
[0] == '.';
1179 /* Should we do dynamic things to this symbol? */
1182 elfNN_ia64_dynamic_symbol_p (h
, info
)
1183 struct elf_link_hash_entry
*h
;
1184 struct bfd_link_info
*info
;
1189 while (h
->root
.type
== bfd_link_hash_indirect
1190 || h
->root
.type
== bfd_link_hash_warning
)
1191 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
1193 if (h
->dynindx
== -1)
1196 if (h
->root
.type
== bfd_link_hash_undefweak
1197 || h
->root
.type
== bfd_link_hash_defweak
)
1200 if ((info
->shared
&& !info
->symbolic
)
1201 || ((h
->elf_link_hash_flags
1202 & (ELF_LINK_HASH_DEF_DYNAMIC
| ELF_LINK_HASH_REF_REGULAR
))
1203 == (ELF_LINK_HASH_DEF_DYNAMIC
| ELF_LINK_HASH_REF_REGULAR
)))
1210 elfNN_ia64_local_hash_table_init (ht
, abfd
, new)
1211 struct elfNN_ia64_local_hash_table
*ht
;
1213 new_hash_entry_func
new;
1215 memset (ht
, 0, sizeof(*ht
));
1216 return bfd_hash_table_init (&ht
->root
, new);
1219 static struct bfd_hash_entry
*
1220 elfNN_ia64_new_loc_hash_entry (entry
, table
, string
)
1221 struct bfd_hash_entry
*entry
;
1222 struct bfd_hash_table
*table
;
1225 struct elfNN_ia64_local_hash_entry
*ret
;
1226 ret
= (struct elfNN_ia64_local_hash_entry
*) entry
;
1228 /* Allocate the structure if it has not already been allocated by a
1231 ret
= bfd_hash_allocate (table
, sizeof (*ret
));
1236 /* Initialize our local data. All zeros, and definitely easier
1237 than setting a handful of bit fields. */
1238 memset (ret
, 0, sizeof(*ret
));
1240 /* Call the allocation method of the superclass. */
1241 ret
= ((struct elfNN_ia64_local_hash_entry
*)
1242 bfd_hash_newfunc ((struct bfd_hash_entry
*) ret
, table
, string
));
1244 return (struct bfd_hash_entry
*) ret
;
1247 static struct bfd_hash_entry
*
1248 elfNN_ia64_new_elf_hash_entry (entry
, table
, string
)
1249 struct bfd_hash_entry
*entry
;
1250 struct bfd_hash_table
*table
;
1253 struct elfNN_ia64_link_hash_entry
*ret
;
1254 ret
= (struct elfNN_ia64_link_hash_entry
*) entry
;
1256 /* Allocate the structure if it has not already been allocated by a
1259 ret
= bfd_hash_allocate (table
, sizeof (*ret
));
1264 /* Initialize our local data. All zeros, and definitely easier
1265 than setting a handful of bit fields. */
1266 memset (ret
, 0, sizeof(*ret
));
1268 /* Call the allocation method of the superclass. */
1269 ret
= ((struct elfNN_ia64_link_hash_entry
*)
1270 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry
*) ret
,
1273 return (struct bfd_hash_entry
*) ret
;
1277 elfNN_ia64_hash_copy_indirect (xdir
, xind
)
1278 struct elf_link_hash_entry
*xdir
, *xind
;
1280 struct elfNN_ia64_link_hash_entry
*dir
, *ind
;
1282 dir
= (struct elfNN_ia64_link_hash_entry
*)xdir
;
1283 ind
= (struct elfNN_ia64_link_hash_entry
*)xind
;
1285 /* Copy down any references that we may have already seen to the
1286 symbol which just became indirect. */
1288 dir
->root
.elf_link_hash_flags
|=
1289 (ind
->root
.elf_link_hash_flags
1290 & (ELF_LINK_HASH_REF_DYNAMIC
1291 | ELF_LINK_HASH_REF_REGULAR
1292 | ELF_LINK_HASH_REF_REGULAR_NONWEAK
));
1294 /* Copy over the got and plt data. This would have been done
1297 if (dir
->info
== NULL
)
1299 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
1301 dir
->info
= dyn_i
= ind
->info
;
1304 /* Fix up the dyn_sym_info pointers to the global symbol. */
1305 for (; dyn_i
; dyn_i
= dyn_i
->next
)
1306 dyn_i
->h
= &dir
->root
;
1308 BFD_ASSERT (ind
->info
== NULL
);
1310 /* Copy over the dynindx. */
1312 if (dir
->root
.dynindx
== -1)
1314 dir
->root
.dynindx
= ind
->root
.dynindx
;
1315 dir
->root
.dynstr_index
= ind
->root
.dynstr_index
;
1316 ind
->root
.dynindx
= -1;
1317 ind
->root
.dynstr_index
= 0;
1319 BFD_ASSERT (ind
->root
.dynindx
== -1);
1323 elfNN_ia64_hash_hide_symbol (info
, xh
)
1324 struct bfd_link_info
*info ATTRIBUTE_UNUSED
;
1325 struct elf_link_hash_entry
*xh
;
1327 struct elfNN_ia64_link_hash_entry
*h
;
1328 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
1330 h
= (struct elfNN_ia64_link_hash_entry
*)xh
;
1332 h
->root
.elf_link_hash_flags
&= ~ELF_LINK_HASH_NEEDS_PLT
;
1333 h
->root
.dynindx
= -1;
1335 for (dyn_i
= h
->info
; dyn_i
; dyn_i
= dyn_i
->next
)
1336 dyn_i
->want_plt2
= 0;
1339 /* Create the derived linker hash table. The IA-64 ELF port uses this
1340 derived hash table to keep information specific to the IA-64 ElF
1341 linker (without using static variables). */
1343 static struct bfd_link_hash_table
*
1344 elfNN_ia64_hash_table_create (abfd
)
1347 struct elfNN_ia64_link_hash_table
*ret
;
1349 ret
= bfd_alloc (abfd
, sizeof (*ret
));
1352 if (!_bfd_elf_link_hash_table_init (&ret
->root
, abfd
,
1353 elfNN_ia64_new_elf_hash_entry
))
1355 bfd_release (abfd
, ret
);
1359 if (!elfNN_ia64_local_hash_table_init (&ret
->loc_hash_table
, abfd
,
1360 elfNN_ia64_new_loc_hash_entry
))
1362 return &ret
->root
.root
;
1365 /* Look up an entry in a Alpha ELF linker hash table. */
1367 static INLINE
struct elfNN_ia64_local_hash_entry
*
1368 elfNN_ia64_local_hash_lookup(table
, string
, create
, copy
)
1369 struct elfNN_ia64_local_hash_table
*table
;
1371 boolean create
, copy
;
1373 return ((struct elfNN_ia64_local_hash_entry
*)
1374 bfd_hash_lookup (&table
->root
, string
, create
, copy
));
1377 /* Traverse both local and global hash tables. */
1379 struct elfNN_ia64_dyn_sym_traverse_data
1381 boolean (*func
) PARAMS ((struct elfNN_ia64_dyn_sym_info
*, PTR
));
1386 elfNN_ia64_global_dyn_sym_thunk (xentry
, xdata
)
1387 struct bfd_hash_entry
*xentry
;
1390 struct elfNN_ia64_link_hash_entry
*entry
1391 = (struct elfNN_ia64_link_hash_entry
*) xentry
;
1392 struct elfNN_ia64_dyn_sym_traverse_data
*data
1393 = (struct elfNN_ia64_dyn_sym_traverse_data
*) xdata
;
1394 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
1396 for (dyn_i
= entry
->info
; dyn_i
; dyn_i
= dyn_i
->next
)
1397 if (! (*data
->func
) (dyn_i
, data
->data
))
1403 elfNN_ia64_local_dyn_sym_thunk (xentry
, xdata
)
1404 struct bfd_hash_entry
*xentry
;
1407 struct elfNN_ia64_local_hash_entry
*entry
1408 = (struct elfNN_ia64_local_hash_entry
*) xentry
;
1409 struct elfNN_ia64_dyn_sym_traverse_data
*data
1410 = (struct elfNN_ia64_dyn_sym_traverse_data
*) xdata
;
1411 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
1413 for (dyn_i
= entry
->info
; dyn_i
; dyn_i
= dyn_i
->next
)
1414 if (! (*data
->func
) (dyn_i
, data
->data
))
1420 elfNN_ia64_dyn_sym_traverse (ia64_info
, func
, data
)
1421 struct elfNN_ia64_link_hash_table
*ia64_info
;
1422 boolean (*func
) PARAMS ((struct elfNN_ia64_dyn_sym_info
*, PTR
));
1425 struct elfNN_ia64_dyn_sym_traverse_data xdata
;
1430 elf_link_hash_traverse (&ia64_info
->root
,
1431 elfNN_ia64_global_dyn_sym_thunk
, &xdata
);
1432 bfd_hash_traverse (&ia64_info
->loc_hash_table
.root
,
1433 elfNN_ia64_local_dyn_sym_thunk
, &xdata
);
1437 elfNN_ia64_create_dynamic_sections (abfd
, info
)
1439 struct bfd_link_info
*info
;
1441 struct elfNN_ia64_link_hash_table
*ia64_info
;
1442 struct elf_link_hash_entry
*h
;
1445 if (! _bfd_elf_create_dynamic_sections (abfd
, info
))
1448 ia64_info
= elfNN_ia64_hash_table (info
);
1450 ia64_info
->plt_sec
= bfd_get_section_by_name (abfd
, ".plt");
1451 ia64_info
->got_sec
= bfd_get_section_by_name (abfd
, ".got");
1454 flagword flags
= bfd_get_section_flags (abfd
, ia64_info
->got_sec
);
1455 bfd_set_section_flags (abfd
, ia64_info
->got_sec
, SEC_SMALL_DATA
| flags
);
1458 if (!get_pltoff (abfd
, info
, ia64_info
))
1461 s
= bfd_make_section(abfd
, ".rela.IA_64.pltoff");
1463 || !bfd_set_section_flags (abfd
, s
, (SEC_ALLOC
| SEC_LOAD
1466 | SEC_LINKER_CREATED
1468 || !bfd_set_section_alignment (abfd
, s
, 3))
1470 ia64_info
->rel_pltoff_sec
= s
;
1472 s
= bfd_make_section(abfd
, ".rela.got");
1474 || !bfd_set_section_flags (abfd
, s
, (SEC_ALLOC
| SEC_LOAD
1477 | SEC_LINKER_CREATED
1479 || !bfd_set_section_alignment (abfd
, s
, 3))
1481 ia64_info
->rel_got_sec
= s
;
1486 /* Find and/or create a descriptor for dynamic symbol info. This will
1487 vary based on global or local symbol, and the addend to the reloc. */
1489 static struct elfNN_ia64_dyn_sym_info
*
1490 get_dyn_sym_info (ia64_info
, h
, abfd
, rel
, create
)
1491 struct elfNN_ia64_link_hash_table
*ia64_info
;
1492 struct elf_link_hash_entry
*h
;
1494 const Elf_Internal_Rela
*rel
;
1497 struct elfNN_ia64_dyn_sym_info
**pp
;
1498 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
1499 bfd_vma addend
= rel
? rel
->r_addend
: 0;
1502 pp
= &((struct elfNN_ia64_link_hash_entry
*)h
)->info
;
1505 struct elfNN_ia64_local_hash_entry
*loc_h
;
1509 /* Construct a string for use in the elfNN_ia64_local_hash_table.
1510 The name describes what was once anonymous memory. */
1512 len
= sizeof(void*)*2 + 1 + sizeof(bfd_vma
)*4 + 1 + 1;
1513 len
+= 10; /* %p slop */
1515 addr_name
= alloca (len
);
1516 sprintf (addr_name
, "%p:%lx", abfd
, ELFNN_R_SYM (rel
->r_info
));
1518 /* Collect the canonical entry data for this address. */
1519 loc_h
= elfNN_ia64_local_hash_lookup (&ia64_info
->loc_hash_table
,
1520 addr_name
, create
, create
);
1526 for (dyn_i
= *pp
; dyn_i
&& dyn_i
->addend
!= addend
; dyn_i
= *pp
)
1529 if (dyn_i
== NULL
&& create
)
1531 dyn_i
= (struct elfNN_ia64_dyn_sym_info
*)
1532 bfd_zalloc (abfd
, sizeof *dyn_i
);
1534 dyn_i
->addend
= addend
;
1541 get_got (abfd
, info
, ia64_info
)
1543 struct bfd_link_info
*info
;
1544 struct elfNN_ia64_link_hash_table
*ia64_info
;
1546 asection
*got
, *srel
;
1549 got
= ia64_info
->got_sec
;
1554 dynobj
= ia64_info
->root
.dynobj
;
1556 ia64_info
->root
.dynobj
= dynobj
= abfd
;
1557 if (!_bfd_elf_create_got_section (dynobj
, info
))
1560 got
= bfd_get_section_by_name (dynobj
, ".got");
1562 ia64_info
->got_sec
= got
;
1564 flags
= bfd_get_section_flags (abfd
, got
);
1565 bfd_set_section_flags (abfd
, got
, SEC_SMALL_DATA
| flags
);
1571 /* Create function descriptor section (.opd). This section is called .opd
1572 because it contains "official prodecure descriptors". The "official"
1573 refers to the fact that these descriptors are used when taking the address
1574 of a procedure, thus ensuring a unique address for each procedure. */
1577 get_fptr (abfd
, info
, ia64_info
)
1579 struct bfd_link_info
*info
;
1580 struct elfNN_ia64_link_hash_table
*ia64_info
;
1585 fptr
= ia64_info
->fptr_sec
;
1588 dynobj
= ia64_info
->root
.dynobj
;
1590 ia64_info
->root
.dynobj
= dynobj
= abfd
;
1592 fptr
= bfd_make_section (dynobj
, ".opd");
1594 || !bfd_set_section_flags (dynobj
, fptr
,
1600 | SEC_LINKER_CREATED
))
1601 || !bfd_set_section_alignment (abfd
, fptr
, 4))
1607 ia64_info
->fptr_sec
= fptr
;
1614 get_pltoff (abfd
, info
, ia64_info
)
1616 struct bfd_link_info
*info
;
1617 struct elfNN_ia64_link_hash_table
*ia64_info
;
1622 pltoff
= ia64_info
->pltoff_sec
;
1625 dynobj
= ia64_info
->root
.dynobj
;
1627 ia64_info
->root
.dynobj
= dynobj
= abfd
;
1629 pltoff
= bfd_make_section (dynobj
, ELF_STRING_ia64_pltoff
);
1631 || !bfd_set_section_flags (dynobj
, pltoff
,
1637 | SEC_LINKER_CREATED
))
1638 || !bfd_set_section_alignment (abfd
, pltoff
, 4))
1644 ia64_info
->pltoff_sec
= pltoff
;
1651 get_reloc_section (abfd
, ia64_info
, sec
, create
)
1653 struct elfNN_ia64_link_hash_table
*ia64_info
;
1657 const char *srel_name
;
1661 srel_name
= (bfd_elf_string_from_elf_section
1662 (abfd
, elf_elfheader(abfd
)->e_shstrndx
,
1663 elf_section_data(sec
)->rel_hdr
.sh_name
));
1664 if (srel_name
== NULL
)
1667 BFD_ASSERT ((strncmp (srel_name
, ".rela", 5) == 0
1668 && strcmp (bfd_get_section_name (abfd
, sec
),
1670 || (strncmp (srel_name
, ".rel", 4) == 0
1671 && strcmp (bfd_get_section_name (abfd
, sec
),
1672 srel_name
+4) == 0));
1674 dynobj
= ia64_info
->root
.dynobj
;
1676 ia64_info
->root
.dynobj
= dynobj
= abfd
;
1678 srel
= bfd_get_section_by_name (dynobj
, srel_name
);
1679 if (srel
== NULL
&& create
)
1681 srel
= bfd_make_section (dynobj
, srel_name
);
1683 || !bfd_set_section_flags (dynobj
, srel
,
1688 | SEC_LINKER_CREATED
1690 || !bfd_set_section_alignment (dynobj
, srel
, 3))
1698 count_dyn_reloc (abfd
, dyn_i
, srel
, type
)
1700 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
1704 struct elfNN_ia64_dyn_reloc_entry
*rent
;
1706 for (rent
= dyn_i
->reloc_entries
; rent
; rent
= rent
->next
)
1707 if (rent
->srel
== srel
&& rent
->type
== type
)
1712 rent
= (struct elfNN_ia64_dyn_reloc_entry
*)
1713 bfd_alloc (abfd
, sizeof (*rent
));
1717 rent
->next
= dyn_i
->reloc_entries
;
1721 dyn_i
->reloc_entries
= rent
;
1729 elfNN_ia64_check_relocs (abfd
, info
, sec
, relocs
)
1731 struct bfd_link_info
*info
;
1733 const Elf_Internal_Rela
*relocs
;
1735 struct elfNN_ia64_link_hash_table
*ia64_info
;
1736 const Elf_Internal_Rela
*relend
;
1737 Elf_Internal_Shdr
*symtab_hdr
;
1738 const Elf_Internal_Rela
*rel
;
1739 asection
*got
, *fptr
, *srel
;
1741 if (info
->relocateable
)
1744 symtab_hdr
= &elf_tdata (abfd
)->symtab_hdr
;
1745 ia64_info
= elfNN_ia64_hash_table (info
);
1747 got
= fptr
= srel
= NULL
;
1749 relend
= relocs
+ sec
->reloc_count
;
1750 for (rel
= relocs
; rel
< relend
; ++rel
)
1759 NEED_LTOFF_FPTR
= 64,
1762 struct elf_link_hash_entry
*h
= NULL
;
1763 unsigned long r_symndx
= ELFNN_R_SYM (rel
->r_info
);
1764 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
1766 boolean maybe_dynamic
;
1769 if (r_symndx
>= symtab_hdr
->sh_info
)
1771 /* We're dealing with a global symbol -- find its hash entry
1772 and mark it as being referenced. */
1773 long indx
= r_symndx
- symtab_hdr
->sh_info
;
1774 h
= elf_sym_hashes (abfd
)[indx
];
1775 while (h
->root
.type
== bfd_link_hash_indirect
1776 || h
->root
.type
== bfd_link_hash_warning
)
1777 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
1779 h
->elf_link_hash_flags
|= ELF_LINK_HASH_REF_REGULAR
;
1782 /* We can only get preliminary data on whether a symbol is
1783 locally or externally defined, as not all of the input files
1784 have yet been processed. Do something with what we know, as
1785 this may help reduce memory usage and processing time later. */
1786 maybe_dynamic
= false;
1787 if (h
&& ((info
->shared
&& ! info
->symbolic
)
1788 || ! (h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
)
1789 || h
->root
.type
== bfd_link_hash_defweak
))
1790 maybe_dynamic
= true;
1793 switch (ELFNN_R_TYPE (rel
->r_info
))
1795 case R_IA64_TPREL22
:
1796 case R_IA64_TPREL64MSB
:
1797 case R_IA64_TPREL64LSB
:
1798 case R_IA64_LTOFF_TP22
:
1801 case R_IA64_LTOFF_FPTR22
:
1802 case R_IA64_LTOFF_FPTR64I
:
1803 case R_IA64_LTOFF_FPTR64MSB
:
1804 case R_IA64_LTOFF_FPTR64LSB
:
1805 need_entry
= NEED_FPTR
| NEED_GOT
| NEED_LTOFF_FPTR
;
1808 case R_IA64_FPTR64I
:
1809 case R_IA64_FPTR32MSB
:
1810 case R_IA64_FPTR32LSB
:
1811 case R_IA64_FPTR64MSB
:
1812 case R_IA64_FPTR64LSB
:
1813 if (info
->shared
|| h
)
1814 need_entry
= NEED_FPTR
| NEED_DYNREL
;
1816 need_entry
= NEED_FPTR
;
1817 dynrel_type
= R_IA64_FPTR64LSB
;
1820 case R_IA64_LTOFF22
:
1821 case R_IA64_LTOFF22X
:
1822 case R_IA64_LTOFF64I
:
1823 need_entry
= NEED_GOT
;
1826 case R_IA64_PLTOFF22
:
1827 case R_IA64_PLTOFF64I
:
1828 case R_IA64_PLTOFF64MSB
:
1829 case R_IA64_PLTOFF64LSB
:
1830 need_entry
= NEED_PLTOFF
;
1834 need_entry
|= NEED_MIN_PLT
;
1838 (*info
->callbacks
->warning
)
1839 (info
, _("@pltoff reloc against local symbol"), 0,
1844 case R_IA64_PCREL21B
:
1845 case R_IA64_PCREL60B
:
1846 /* Depending on where this symbol is defined, we may or may not
1847 need a full plt entry. Only skip if we know we'll not need
1848 the entry -- static or symbolic, and the symbol definition
1849 has already been seen. */
1850 if (maybe_dynamic
&& rel
->r_addend
== 0)
1851 need_entry
= NEED_FULL_PLT
;
1857 case R_IA64_DIR32MSB
:
1858 case R_IA64_DIR32LSB
:
1859 case R_IA64_DIR64MSB
:
1860 case R_IA64_DIR64LSB
:
1861 /* Shared objects will always need at least a REL relocation. */
1862 if (info
->shared
|| maybe_dynamic
)
1863 need_entry
= NEED_DYNREL
;
1864 dynrel_type
= R_IA64_DIR64LSB
;
1867 case R_IA64_PCREL22
:
1868 case R_IA64_PCREL64I
:
1869 case R_IA64_PCREL32MSB
:
1870 case R_IA64_PCREL32LSB
:
1871 case R_IA64_PCREL64MSB
:
1872 case R_IA64_PCREL64LSB
:
1874 need_entry
= NEED_DYNREL
;
1875 dynrel_type
= R_IA64_PCREL64LSB
;
1882 if ((need_entry
& NEED_FPTR
) != 0
1885 (*info
->callbacks
->warning
)
1886 (info
, _("non-zero addend in @fptr reloc"), 0,
1890 dyn_i
= get_dyn_sym_info (ia64_info
, h
, abfd
, rel
, true);
1892 /* Record whether or not this is a local symbol. */
1895 /* Create what's needed. */
1896 if (need_entry
& NEED_GOT
)
1900 got
= get_got (abfd
, info
, ia64_info
);
1904 dyn_i
->want_got
= 1;
1906 if (need_entry
& NEED_FPTR
)
1910 fptr
= get_fptr (abfd
, info
, ia64_info
);
1915 /* FPTRs for shared libraries are allocated by the dynamic
1916 linker. Make sure this local symbol will appear in the
1917 dynamic symbol table. */
1918 if (!h
&& info
->shared
)
1920 if (! (_bfd_elfNN_link_record_local_dynamic_symbol
1921 (info
, abfd
, r_symndx
)))
1925 dyn_i
->want_fptr
= 1;
1927 if (need_entry
& NEED_LTOFF_FPTR
)
1928 dyn_i
->want_ltoff_fptr
= 1;
1929 if (need_entry
& (NEED_MIN_PLT
| NEED_FULL_PLT
))
1931 if (!ia64_info
->root
.dynobj
)
1932 ia64_info
->root
.dynobj
= abfd
;
1933 h
->elf_link_hash_flags
|= ELF_LINK_HASH_NEEDS_PLT
;
1934 dyn_i
->want_plt
= 1;
1936 if (need_entry
& NEED_FULL_PLT
)
1937 dyn_i
->want_plt2
= 1;
1938 if (need_entry
& NEED_PLTOFF
)
1939 dyn_i
->want_pltoff
= 1;
1940 if ((need_entry
& NEED_DYNREL
) && (sec
->flags
& SEC_ALLOC
))
1944 srel
= get_reloc_section (abfd
, ia64_info
, sec
, true);
1948 if (!count_dyn_reloc (abfd
, dyn_i
, srel
, dynrel_type
))
1956 struct elfNN_ia64_allocate_data
1958 struct bfd_link_info
*info
;
1962 /* For cleanliness, and potentially faster dynamic loading, allocate
1963 external GOT entries first. */
1966 allocate_global_data_got (dyn_i
, data
)
1967 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
1970 struct elfNN_ia64_allocate_data
*x
= (struct elfNN_ia64_allocate_data
*)data
;
1973 && ! dyn_i
->want_fptr
1974 && elfNN_ia64_dynamic_symbol_p (dyn_i
->h
, x
->info
))
1976 dyn_i
->got_offset
= x
->ofs
;
1982 /* Next, allocate all the GOT entries used by LTOFF_FPTR relocs. */
1985 allocate_global_fptr_got (dyn_i
, data
)
1986 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
1989 struct elfNN_ia64_allocate_data
*x
= (struct elfNN_ia64_allocate_data
*)data
;
1993 && elfNN_ia64_dynamic_symbol_p (dyn_i
->h
, x
->info
))
1995 dyn_i
->got_offset
= x
->ofs
;
2001 /* Lastly, allocate all the GOT entries for local data. */
2004 allocate_local_got (dyn_i
, data
)
2005 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
2008 struct elfNN_ia64_allocate_data
*x
= (struct elfNN_ia64_allocate_data
*)data
;
2011 && ! elfNN_ia64_dynamic_symbol_p (dyn_i
->h
, x
->info
))
2013 dyn_i
->got_offset
= x
->ofs
;
2019 /* Search for the index of a global symbol in it's defining object file. */
2021 static unsigned long
2022 global_sym_index (h
)
2023 struct elf_link_hash_entry
*h
;
2025 struct elf_link_hash_entry
**p
;
2028 BFD_ASSERT (h
->root
.type
== bfd_link_hash_defined
2029 || h
->root
.type
== bfd_link_hash_defweak
);
2031 obj
= h
->root
.u
.def
.section
->owner
;
2032 for (p
= elf_sym_hashes (obj
); *p
!= h
; ++p
)
2035 return p
- elf_sym_hashes (obj
) + elf_tdata (obj
)->symtab_hdr
.sh_info
;
2038 /* Allocate function descriptors. We can do these for every function
2039 in a main executable that is not exported. */
2042 allocate_fptr (dyn_i
, data
)
2043 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
2046 struct elfNN_ia64_allocate_data
*x
= (struct elfNN_ia64_allocate_data
*)data
;
2048 if (dyn_i
->want_fptr
)
2050 struct elf_link_hash_entry
*h
= dyn_i
->h
;
2053 while (h
->root
.type
== bfd_link_hash_indirect
2054 || h
->root
.type
== bfd_link_hash_warning
)
2055 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
2057 if (x
->info
->shared
)
2059 if (h
&& h
->dynindx
== -1)
2061 BFD_ASSERT ((h
->root
.type
== bfd_link_hash_defined
)
2062 || (h
->root
.type
== bfd_link_hash_defweak
));
2064 if (!_bfd_elfNN_link_record_local_dynamic_symbol
2065 (x
->info
, h
->root
.u
.def
.section
->owner
,
2066 global_sym_index (h
)))
2070 dyn_i
->want_fptr
= 0;
2072 else if (h
== NULL
|| h
->dynindx
== -1)
2074 dyn_i
->fptr_offset
= x
->ofs
;
2078 dyn_i
->want_fptr
= 0;
2083 /* Allocate all the minimal PLT entries. */
2086 allocate_plt_entries (dyn_i
, data
)
2087 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
2090 struct elfNN_ia64_allocate_data
*x
= (struct elfNN_ia64_allocate_data
*)data
;
2092 if (dyn_i
->want_plt
)
2094 struct elf_link_hash_entry
*h
= dyn_i
->h
;
2097 while (h
->root
.type
== bfd_link_hash_indirect
2098 || h
->root
.type
== bfd_link_hash_warning
)
2099 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
2101 /* ??? Versioned symbols seem to lose ELF_LINK_HASH_NEEDS_PLT. */
2102 if (elfNN_ia64_dynamic_symbol_p (h
, x
->info
))
2104 bfd_size_type offset
= x
->ofs
;
2106 offset
= PLT_HEADER_SIZE
;
2107 dyn_i
->plt_offset
= offset
;
2108 x
->ofs
= offset
+ PLT_MIN_ENTRY_SIZE
;
2110 dyn_i
->want_pltoff
= 1;
2114 dyn_i
->want_plt
= 0;
2115 dyn_i
->want_plt2
= 0;
2121 /* Allocate all the full PLT entries. */
2124 allocate_plt2_entries (dyn_i
, data
)
2125 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
2128 struct elfNN_ia64_allocate_data
*x
= (struct elfNN_ia64_allocate_data
*)data
;
2130 if (dyn_i
->want_plt2
)
2132 struct elf_link_hash_entry
*h
= dyn_i
->h
;
2133 bfd_size_type ofs
= x
->ofs
;
2135 dyn_i
->plt2_offset
= ofs
;
2136 x
->ofs
= ofs
+ PLT_FULL_ENTRY_SIZE
;
2138 while (h
->root
.type
== bfd_link_hash_indirect
2139 || h
->root
.type
== bfd_link_hash_warning
)
2140 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
2141 dyn_i
->h
->plt
.offset
= ofs
;
2146 /* Allocate all the PLTOFF entries requested by relocations and
2147 plt entries. We can't share space with allocated FPTR entries,
2148 because the latter are not necessarily addressable by the GP.
2149 ??? Relaxation might be able to determine that they are. */
2152 allocate_pltoff_entries (dyn_i
, data
)
2153 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
2156 struct elfNN_ia64_allocate_data
*x
= (struct elfNN_ia64_allocate_data
*)data
;
2158 if (dyn_i
->want_pltoff
)
2160 dyn_i
->pltoff_offset
= x
->ofs
;
2166 /* Allocate dynamic relocations for those symbols that turned out
2170 allocate_dynrel_entries (dyn_i
, data
)
2171 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
2174 struct elfNN_ia64_allocate_data
*x
= (struct elfNN_ia64_allocate_data
*)data
;
2175 struct elfNN_ia64_link_hash_table
*ia64_info
;
2176 struct elfNN_ia64_dyn_reloc_entry
*rent
;
2177 boolean dynamic_symbol
, shared
;
2179 ia64_info
= elfNN_ia64_hash_table (x
->info
);
2180 dynamic_symbol
= elfNN_ia64_dynamic_symbol_p (dyn_i
->h
, x
->info
);
2181 shared
= x
->info
->shared
;
2183 /* Take care of the normal data relocations. */
2185 for (rent
= dyn_i
->reloc_entries
; rent
; rent
= rent
->next
)
2189 case R_IA64_FPTR64LSB
:
2190 /* Allocate one iff !want_fptr, which by this point will
2191 be true only if we're actually allocating one statically
2192 in the main executable. */
2193 if (dyn_i
->want_fptr
)
2196 case R_IA64_PCREL64LSB
:
2197 if (!dynamic_symbol
)
2200 case R_IA64_DIR64LSB
:
2201 if (!dynamic_symbol
&& !shared
)
2205 rent
->srel
->_raw_size
+= sizeof (ElfNN_External_Rela
) * rent
->count
;
2208 /* Take care of the GOT and PLT relocations. */
2210 if (((dynamic_symbol
|| shared
) && dyn_i
->want_got
)
2211 || (dyn_i
->want_ltoff_fptr
&& dyn_i
->h
&& dyn_i
->h
->dynindx
!= -1))
2212 ia64_info
->rel_got_sec
->_raw_size
+= sizeof (ElfNN_External_Rela
);
2214 if (dyn_i
->want_pltoff
)
2216 bfd_size_type t
= 0;
2218 /* Dynamic symbols get one IPLT relocation. Local symbols in
2219 shared libraries get two REL relocations. Local symbols in
2220 main applications get nothing. */
2222 t
= sizeof (ElfNN_External_Rela
);
2224 t
= 2 * sizeof (ElfNN_External_Rela
);
2226 ia64_info
->rel_pltoff_sec
->_raw_size
+= t
;
2233 elfNN_ia64_adjust_dynamic_symbol (info
, h
)
2234 struct bfd_link_info
*info
;
2235 struct elf_link_hash_entry
*h
;
2237 /* ??? Undefined symbols with PLT entries should be re-defined
2238 to be the PLT entry. */
2240 /* If this is a weak symbol, and there is a real definition, the
2241 processor independent code will have arranged for us to see the
2242 real definition first, and we can just use the same value. */
2243 if (h
->weakdef
!= NULL
)
2245 BFD_ASSERT (h
->weakdef
->root
.type
== bfd_link_hash_defined
2246 || h
->weakdef
->root
.type
== bfd_link_hash_defweak
);
2247 h
->root
.u
.def
.section
= h
->weakdef
->root
.u
.def
.section
;
2248 h
->root
.u
.def
.value
= h
->weakdef
->root
.u
.def
.value
;
2252 /* If this is a reference to a symbol defined by a dynamic object which
2253 is not a function, we might allocate the symbol in our .dynbss section
2254 and allocate a COPY dynamic relocation.
2256 But IA-64 code is canonically PIC, so as a rule we can avoid this sort
2263 elfNN_ia64_size_dynamic_sections (output_bfd
, info
)
2265 struct bfd_link_info
*info
;
2267 struct elfNN_ia64_allocate_data data
;
2268 struct elfNN_ia64_link_hash_table
*ia64_info
;
2271 boolean reltext
= false;
2272 boolean relplt
= false;
2274 dynobj
= elf_hash_table(info
)->dynobj
;
2275 ia64_info
= elfNN_ia64_hash_table (info
);
2276 BFD_ASSERT(dynobj
!= NULL
);
2279 /* Set the contents of the .interp section to the interpreter. */
2280 if (ia64_info
->root
.dynamic_sections_created
2283 sec
= bfd_get_section_by_name (dynobj
, ".interp");
2284 BFD_ASSERT (sec
!= NULL
);
2285 sec
->contents
= (bfd_byte
*) ELF_DYNAMIC_INTERPRETER
;
2286 sec
->_raw_size
= strlen (ELF_DYNAMIC_INTERPRETER
) + 1;
2289 /* DT_INIT and DT_FINI get function descriptors not raw code addresses.
2290 Force their symbols to have pltoff entries so we can use those. */
2291 if (ia64_info
->root
.dynamic_sections_created
)
2293 struct elf_link_hash_entry
*h
;
2294 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
2296 if (info
->init_function
2297 && (h
= elf_link_hash_lookup (elf_hash_table (info
),
2298 info
->init_function
, false,
2300 && (h
->elf_link_hash_flags
& (ELF_LINK_HASH_REF_REGULAR
2301 | ELF_LINK_HASH_DEF_REGULAR
)) != 0)
2303 dyn_i
= get_dyn_sym_info (ia64_info
, h
, output_bfd
, NULL
, true);
2304 dyn_i
->want_pltoff
= 1;
2307 if (info
->fini_function
2308 && (h
= elf_link_hash_lookup (elf_hash_table (info
),
2309 info
->fini_function
, false,
2311 && (h
->elf_link_hash_flags
& (ELF_LINK_HASH_REF_REGULAR
2312 | ELF_LINK_HASH_DEF_REGULAR
)) != 0)
2314 dyn_i
= get_dyn_sym_info (ia64_info
, h
, output_bfd
, NULL
, true);
2315 dyn_i
->want_pltoff
= 1;
2319 /* Allocate the GOT entries. */
2321 if (ia64_info
->got_sec
)
2324 elfNN_ia64_dyn_sym_traverse (ia64_info
, allocate_global_data_got
, &data
);
2325 elfNN_ia64_dyn_sym_traverse (ia64_info
, allocate_global_fptr_got
, &data
);
2326 elfNN_ia64_dyn_sym_traverse (ia64_info
, allocate_local_got
, &data
);
2327 ia64_info
->got_sec
->_raw_size
= data
.ofs
;
2330 /* Allocate the FPTR entries. */
2332 if (ia64_info
->fptr_sec
)
2335 elfNN_ia64_dyn_sym_traverse (ia64_info
, allocate_fptr
, &data
);
2336 ia64_info
->fptr_sec
->_raw_size
= data
.ofs
;
2339 /* Now that we've seen all of the input files, we can decide which
2340 symbols need plt entries. Allocate the minimal PLT entries first.
2341 We do this even though dynamic_sections_created may be false, because
2342 this has the side-effect of clearing want_plt and want_plt2. */
2345 elfNN_ia64_dyn_sym_traverse (ia64_info
, allocate_plt_entries
, &data
);
2347 ia64_info
->minplt_entries
= 0;
2350 ia64_info
->minplt_entries
2351 = (data
.ofs
- PLT_HEADER_SIZE
) / PLT_MIN_ENTRY_SIZE
;
2354 /* Align the pointer for the plt2 entries. */
2355 data
.ofs
= (data
.ofs
+ 31) & -32;
2357 elfNN_ia64_dyn_sym_traverse (ia64_info
, allocate_plt2_entries
, &data
);
2360 BFD_ASSERT (ia64_info
->root
.dynamic_sections_created
);
2362 ia64_info
->plt_sec
->_raw_size
= data
.ofs
;
2364 /* If we've got a .plt, we need some extra memory for the dynamic
2365 linker. We stuff these in .got.plt. */
2366 sec
= bfd_get_section_by_name (dynobj
, ".got.plt");
2367 sec
->_raw_size
= 8 * PLT_RESERVED_WORDS
;
2370 /* Allocate the PLTOFF entries. */
2372 if (ia64_info
->pltoff_sec
)
2375 elfNN_ia64_dyn_sym_traverse (ia64_info
, allocate_pltoff_entries
, &data
);
2376 ia64_info
->pltoff_sec
->_raw_size
= data
.ofs
;
2379 if (ia64_info
->root
.dynamic_sections_created
)
2381 /* Allocate space for the dynamic relocations that turned out to be
2384 elfNN_ia64_dyn_sym_traverse (ia64_info
, allocate_dynrel_entries
, &data
);
2387 /* We have now determined the sizes of the various dynamic sections.
2388 Allocate memory for them. */
2389 for (sec
= dynobj
->sections
; sec
!= NULL
; sec
= sec
->next
)
2393 if (!(sec
->flags
& SEC_LINKER_CREATED
))
2396 /* If we don't need this section, strip it from the output file.
2397 There were several sections primarily related to dynamic
2398 linking that must be create before the linker maps input
2399 sections to output sections. The linker does that before
2400 bfd_elf_size_dynamic_sections is called, and it is that
2401 function which decides whether anything needs to go into
2404 strip
= (sec
->_raw_size
== 0);
2406 if (sec
== ia64_info
->got_sec
)
2408 else if (sec
== ia64_info
->rel_got_sec
)
2411 ia64_info
->rel_got_sec
= NULL
;
2413 /* We use the reloc_count field as a counter if we need to
2414 copy relocs into the output file. */
2415 sec
->reloc_count
= 0;
2417 else if (sec
== ia64_info
->fptr_sec
)
2420 ia64_info
->fptr_sec
= NULL
;
2422 else if (sec
== ia64_info
->plt_sec
)
2425 ia64_info
->plt_sec
= NULL
;
2427 else if (sec
== ia64_info
->pltoff_sec
)
2430 ia64_info
->pltoff_sec
= NULL
;
2432 else if (sec
== ia64_info
->rel_pltoff_sec
)
2435 ia64_info
->rel_pltoff_sec
= NULL
;
2439 /* We use the reloc_count field as a counter if we need to
2440 copy relocs into the output file. */
2441 sec
->reloc_count
= 0;
2448 /* It's OK to base decisions on the section name, because none
2449 of the dynobj section names depend upon the input files. */
2450 name
= bfd_get_section_name (dynobj
, sec
);
2452 if (strcmp (name
, ".got.plt") == 0)
2454 else if (strncmp (name
, ".rel", 4) == 0)
2458 const char *outname
;
2461 /* If this relocation section applies to a read only
2462 section, then we probably need a DT_TEXTREL entry. */
2463 outname
= bfd_get_section_name (output_bfd
,
2464 sec
->output_section
);
2465 if (outname
[4] == 'a')
2470 target
= bfd_get_section_by_name (output_bfd
, outname
);
2472 && (target
->flags
& SEC_READONLY
) != 0
2473 && (target
->flags
& SEC_ALLOC
) != 0)
2476 /* We use the reloc_count field as a counter if we need to
2477 copy relocs into the output file. */
2478 sec
->reloc_count
= 0;
2486 _bfd_strip_section_from_output (info
, sec
);
2489 /* Allocate memory for the section contents. */
2490 sec
->contents
= (bfd_byte
*) bfd_zalloc(dynobj
, sec
->_raw_size
);
2491 if (sec
->contents
== NULL
&& sec
->_raw_size
!= 0)
2496 if (elf_hash_table (info
)->dynamic_sections_created
)
2498 /* Add some entries to the .dynamic section. We fill in the values
2499 later (in finish_dynamic_sections) but we must add the entries now
2500 so that we get the correct size for the .dynamic section. */
2504 /* The DT_DEBUG entry is filled in by the dynamic linker and used
2506 if (!bfd_elfNN_add_dynamic_entry (info
, DT_DEBUG
, 0))
2510 if (! bfd_elfNN_add_dynamic_entry (info
, DT_IA_64_PLT_RESERVE
, 0))
2512 if (! bfd_elfNN_add_dynamic_entry (info
, DT_PLTGOT
, 0))
2517 if (! bfd_elfNN_add_dynamic_entry (info
, DT_PLTRELSZ
, 0)
2518 || ! bfd_elfNN_add_dynamic_entry (info
, DT_PLTREL
, DT_RELA
)
2519 || ! bfd_elfNN_add_dynamic_entry (info
, DT_JMPREL
, 0))
2523 if (! bfd_elfNN_add_dynamic_entry (info
, DT_RELA
, 0)
2524 || ! bfd_elfNN_add_dynamic_entry (info
, DT_RELASZ
, 0)
2525 || ! bfd_elfNN_add_dynamic_entry (info
, DT_RELAENT
,
2526 sizeof(ElfNN_External_Rela
)))
2531 if (! bfd_elfNN_add_dynamic_entry (info
, DT_TEXTREL
, 0))
2533 info
->flags
|= DF_TEXTREL
;
2537 /* ??? Perhaps force __gp local. */
2542 static bfd_reloc_status_type
2543 elfNN_ia64_install_value (abfd
, hit_addr
, val
, r_type
)
2547 unsigned int r_type
;
2549 const struct ia64_operand
*op
;
2550 int bigendian
= 0, shift
= 0;
2551 bfd_vma t0
, t1
, insn
, dword
;
2552 enum ia64_opnd opnd
;
2556 opnd
= IA64_OPND_NIL
;
2561 return bfd_reloc_ok
;
2563 /* Instruction relocations. */
2565 case R_IA64_IMM14
: opnd
= IA64_OPND_IMM14
; break;
2567 case R_IA64_PCREL21F
: opnd
= IA64_OPND_TGT25
; break;
2568 case R_IA64_PCREL21M
: opnd
= IA64_OPND_TGT25b
; break;
2569 case R_IA64_PCREL60B
: opnd
= IA64_OPND_TGT64
; break;
2570 case R_IA64_PCREL21B
:
2571 case R_IA64_PCREL21BI
:
2572 opnd
= IA64_OPND_TGT25c
;
2576 case R_IA64_GPREL22
:
2577 case R_IA64_LTOFF22
:
2578 case R_IA64_LTOFF22X
:
2579 case R_IA64_PLTOFF22
:
2580 case R_IA64_PCREL22
:
2581 case R_IA64_LTOFF_FPTR22
:
2582 opnd
= IA64_OPND_IMM22
;
2586 case R_IA64_GPREL64I
:
2587 case R_IA64_LTOFF64I
:
2588 case R_IA64_PLTOFF64I
:
2589 case R_IA64_PCREL64I
:
2590 case R_IA64_FPTR64I
:
2591 case R_IA64_LTOFF_FPTR64I
:
2592 opnd
= IA64_OPND_IMMU64
;
2595 /* Data relocations. */
2597 case R_IA64_DIR32MSB
:
2598 case R_IA64_GPREL32MSB
:
2599 case R_IA64_FPTR32MSB
:
2600 case R_IA64_PCREL32MSB
:
2601 case R_IA64_SEGREL32MSB
:
2602 case R_IA64_SECREL32MSB
:
2603 case R_IA64_LTV32MSB
:
2604 size
= 4; bigendian
= 1;
2607 case R_IA64_DIR32LSB
:
2608 case R_IA64_GPREL32LSB
:
2609 case R_IA64_FPTR32LSB
:
2610 case R_IA64_PCREL32LSB
:
2611 case R_IA64_SEGREL32LSB
:
2612 case R_IA64_SECREL32LSB
:
2613 case R_IA64_LTV32LSB
:
2614 size
= 4; bigendian
= 0;
2617 case R_IA64_DIR64MSB
:
2618 case R_IA64_GPREL64MSB
:
2619 case R_IA64_PLTOFF64MSB
:
2620 case R_IA64_FPTR64MSB
:
2621 case R_IA64_PCREL64MSB
:
2622 case R_IA64_LTOFF_FPTR64MSB
:
2623 case R_IA64_SEGREL64MSB
:
2624 case R_IA64_SECREL64MSB
:
2625 case R_IA64_LTV64MSB
:
2626 size
= 8; bigendian
= 1;
2629 case R_IA64_DIR64LSB
:
2630 case R_IA64_GPREL64LSB
:
2631 case R_IA64_PLTOFF64LSB
:
2632 case R_IA64_FPTR64LSB
:
2633 case R_IA64_PCREL64LSB
:
2634 case R_IA64_LTOFF_FPTR64LSB
:
2635 case R_IA64_SEGREL64LSB
:
2636 case R_IA64_SECREL64LSB
:
2637 case R_IA64_LTV64LSB
:
2638 size
= 8; bigendian
= 0;
2641 /* Unsupported / Dynamic relocations. */
2643 case R_IA64_REL32MSB
:
2644 case R_IA64_REL32LSB
:
2645 case R_IA64_REL64MSB
:
2646 case R_IA64_REL64LSB
:
2648 case R_IA64_IPLTMSB
:
2649 case R_IA64_IPLTLSB
:
2650 case R_IA64_EPLTMSB
:
2651 case R_IA64_EPLTLSB
:
2654 case R_IA64_SEGBASE
:
2656 case R_IA64_TPREL22
:
2657 case R_IA64_TPREL64MSB
:
2658 case R_IA64_TPREL64LSB
:
2659 case R_IA64_LTOFF_TP22
:
2662 return bfd_reloc_notsupported
;
2667 case IA64_OPND_IMMU64
:
2668 hit_addr
-= (long) hit_addr
& 0x3;
2669 t0
= bfd_get_64 (abfd
, hit_addr
);
2670 t1
= bfd_get_64 (abfd
, hit_addr
+ 8);
2672 /* tmpl/s: bits 0.. 5 in t0
2673 slot 0: bits 5..45 in t0
2674 slot 1: bits 46..63 in t0, bits 0..22 in t1
2675 slot 2: bits 23..63 in t1 */
2677 /* First, clear the bits that form the 64 bit constant. */
2678 t0
&= ~(0x3ffffLL
<< 46);
2680 | (( (0x07fLL
<< 13) | (0x1ffLL
<< 27)
2681 | (0x01fLL
<< 22) | (0x001LL
<< 21)
2682 | (0x001LL
<< 36)) << 23));
2684 t0
|= ((val
>> 22) & 0x03ffffLL
) << 46; /* 18 lsbs of imm41 */
2685 t1
|= ((val
>> 40) & 0x7fffffLL
) << 0; /* 23 msbs of imm41 */
2686 t1
|= ( (((val
>> 0) & 0x07f) << 13) /* imm7b */
2687 | (((val
>> 7) & 0x1ff) << 27) /* imm9d */
2688 | (((val
>> 16) & 0x01f) << 22) /* imm5c */
2689 | (((val
>> 21) & 0x001) << 21) /* ic */
2690 | (((val
>> 63) & 0x001) << 36)) << 23; /* i */
2692 bfd_put_64 (abfd
, t0
, hit_addr
);
2693 bfd_put_64 (abfd
, t1
, hit_addr
+ 8);
2696 case IA64_OPND_TGT64
:
2697 hit_addr
-= (long) hit_addr
& 0x3;
2698 t0
= bfd_get_64 (abfd
, hit_addr
);
2699 t1
= bfd_get_64 (abfd
, hit_addr
+ 8);
2701 /* tmpl/s: bits 0.. 5 in t0
2702 slot 0: bits 5..45 in t0
2703 slot 1: bits 46..63 in t0, bits 0..22 in t1
2704 slot 2: bits 23..63 in t1 */
2706 /* First, clear the bits that form the 64 bit constant. */
2707 t0
&= ~(0x3ffffLL
<< 46);
2709 | ((1LL << 36 | 0xfffffLL
<< 13) << 23));
2712 t0
|= ((val
>> 20) & 0xffffLL
) << 2 << 46; /* 16 lsbs of imm39 */
2713 t1
|= ((val
>> 36) & 0x7fffffLL
) << 0; /* 23 msbs of imm39 */
2714 t1
|= ((((val
>> 0) & 0xfffffLL
) << 13) /* imm20b */
2715 | (((val
>> 59) & 0x1LL
) << 36)) << 23; /* i */
2717 bfd_put_64 (abfd
, t0
, hit_addr
);
2718 bfd_put_64 (abfd
, t1
, hit_addr
+ 8);
2722 switch ((long) hit_addr
& 0x3)
2724 case 0: shift
= 5; break;
2725 case 1: shift
= 14; hit_addr
+= 3; break;
2726 case 2: shift
= 23; hit_addr
+= 6; break;
2727 case 3: return bfd_reloc_notsupported
; /* shouldn't happen... */
2729 dword
= bfd_get_64 (abfd
, hit_addr
);
2730 insn
= (dword
>> shift
) & 0x1ffffffffffLL
;
2732 op
= elf64_ia64_operands
+ opnd
;
2733 err
= (*op
->insert
) (op
, val
, &insn
);
2735 return bfd_reloc_overflow
;
2737 dword
&= ~(0x1ffffffffffLL
<< shift
);
2738 dword
|= (insn
<< shift
);
2739 bfd_put_64 (abfd
, dword
, hit_addr
);
2743 /* A data relocation. */
2746 bfd_putb32 (val
, hit_addr
);
2748 bfd_putb64 (val
, hit_addr
);
2751 bfd_putl32 (val
, hit_addr
);
2753 bfd_putl64 (val
, hit_addr
);
2757 return bfd_reloc_ok
;
2761 elfNN_ia64_install_dyn_reloc (abfd
, info
, sec
, srel
, offset
, type
,
2764 struct bfd_link_info
*info
;
2772 Elf_Internal_Rela outrel
;
2774 outrel
.r_offset
= (sec
->output_section
->vma
2775 + sec
->output_offset
2778 BFD_ASSERT (dynindx
!= -1);
2779 outrel
.r_info
= ELFNN_R_INFO (dynindx
, type
);
2780 outrel
.r_addend
= addend
;
2782 if (elf_section_data (sec
)->stab_info
!= NULL
)
2784 /* This may be NULL for linker-generated relocations, as it is
2785 inconvenient to pass all the bits around. And this shouldn't
2787 BFD_ASSERT (info
!= NULL
);
2789 offset
= (_bfd_stab_section_offset
2790 (abfd
, &elf_hash_table (info
)->stab_info
, sec
,
2791 &elf_section_data (sec
)->stab_info
, offset
));
2792 if (offset
== (bfd_vma
) -1)
2794 /* Run for the hills. We shouldn't be outputting a relocation
2795 for this. So do what everyone else does and output a no-op. */
2796 outrel
.r_info
= ELFNN_R_INFO (0, R_IA64_NONE
);
2797 outrel
.r_addend
= 0;
2800 outrel
.r_offset
= offset
;
2803 bfd_elfNN_swap_reloca_out (abfd
, &outrel
,
2804 ((ElfNN_External_Rela
*) srel
->contents
2805 + srel
->reloc_count
++));
2806 BFD_ASSERT (sizeof(ElfNN_External_Rela
) * srel
->reloc_count
2807 <= srel
->_cooked_size
);
2810 /* Store an entry for target address TARGET_ADDR in the linkage table
2811 and return the gp-relative address of the linkage table entry. */
2814 set_got_entry (abfd
, info
, dyn_i
, dynindx
, addend
, value
, dyn_r_type
)
2816 struct bfd_link_info
*info
;
2817 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
2821 unsigned int dyn_r_type
;
2823 struct elfNN_ia64_link_hash_table
*ia64_info
;
2826 ia64_info
= elfNN_ia64_hash_table (info
);
2827 got_sec
= ia64_info
->got_sec
;
2829 BFD_ASSERT ((dyn_i
->got_offset
& 7) == 0);
2831 if (! dyn_i
->got_done
)
2833 dyn_i
->got_done
= true;
2835 /* Store the target address in the linkage table entry. */
2836 bfd_put_64 (abfd
, value
, got_sec
->contents
+ dyn_i
->got_offset
);
2838 /* Install a dynamic relocation if needed. */
2840 || elfNN_ia64_dynamic_symbol_p (dyn_i
->h
, info
)
2841 || (dynindx
!= -1 && dyn_r_type
== R_IA64_FPTR64LSB
))
2845 dyn_r_type
= R_IA64_REL64LSB
;
2850 if (bfd_big_endian (abfd
))
2854 case R_IA64_REL64LSB
:
2855 dyn_r_type
= R_IA64_REL64MSB
;
2857 case R_IA64_DIR64LSB
:
2858 dyn_r_type
= R_IA64_DIR64MSB
;
2860 case R_IA64_FPTR64LSB
:
2861 dyn_r_type
= R_IA64_FPTR64MSB
;
2869 elfNN_ia64_install_dyn_reloc (abfd
, NULL
, got_sec
,
2870 ia64_info
->rel_got_sec
,
2871 dyn_i
->got_offset
, dyn_r_type
,
2876 /* Return the address of the linkage table entry. */
2877 value
= (got_sec
->output_section
->vma
2878 + got_sec
->output_offset
2879 + dyn_i
->got_offset
);
2884 /* Fill in a function descriptor consisting of the function's code
2885 address and its global pointer. Return the descriptor's address. */
2888 set_fptr_entry (abfd
, info
, dyn_i
, value
)
2890 struct bfd_link_info
*info
;
2891 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
2894 struct elfNN_ia64_link_hash_table
*ia64_info
;
2897 ia64_info
= elfNN_ia64_hash_table (info
);
2898 fptr_sec
= ia64_info
->fptr_sec
;
2900 if (!dyn_i
->fptr_done
)
2902 dyn_i
->fptr_done
= 1;
2904 /* Fill in the function descriptor. */
2905 bfd_put_64 (abfd
, value
, fptr_sec
->contents
+ dyn_i
->fptr_offset
);
2906 bfd_put_64 (abfd
, _bfd_get_gp_value (abfd
),
2907 fptr_sec
->contents
+ dyn_i
->fptr_offset
+ 8);
2910 /* Return the descriptor's address. */
2911 value
= (fptr_sec
->output_section
->vma
2912 + fptr_sec
->output_offset
2913 + dyn_i
->fptr_offset
);
2918 /* Fill in a PLTOFF entry consisting of the function's code address
2919 and its global pointer. Return the descriptor's address. */
2922 set_pltoff_entry (abfd
, info
, dyn_i
, value
, is_plt
)
2924 struct bfd_link_info
*info
;
2925 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
2929 struct elfNN_ia64_link_hash_table
*ia64_info
;
2930 asection
*pltoff_sec
;
2932 ia64_info
= elfNN_ia64_hash_table (info
);
2933 pltoff_sec
= ia64_info
->pltoff_sec
;
2935 /* Don't do anything if this symbol uses a real PLT entry. In
2936 that case, we'll fill this in during finish_dynamic_symbol. */
2937 if ((! dyn_i
->want_plt
|| is_plt
)
2938 && !dyn_i
->pltoff_done
)
2940 /* Fill in the function descriptor. */
2941 bfd_put_64 (abfd
, value
, pltoff_sec
->contents
+ dyn_i
->pltoff_offset
);
2942 bfd_put_64 (abfd
, _bfd_get_gp_value (abfd
),
2943 pltoff_sec
->contents
+ dyn_i
->pltoff_offset
+ 8);
2945 /* Install dynamic relocations if needed. */
2946 if (!is_plt
&& info
->shared
)
2948 unsigned int dyn_r_type
;
2950 if (bfd_big_endian (abfd
))
2951 dyn_r_type
= R_IA64_REL64MSB
;
2953 dyn_r_type
= R_IA64_REL64LSB
;
2955 elfNN_ia64_install_dyn_reloc (abfd
, NULL
, pltoff_sec
,
2956 ia64_info
->rel_pltoff_sec
,
2957 dyn_i
->pltoff_offset
,
2959 elfNN_ia64_install_dyn_reloc (abfd
, NULL
, pltoff_sec
,
2960 ia64_info
->rel_pltoff_sec
,
2961 dyn_i
->pltoff_offset
+ 8,
2965 dyn_i
->pltoff_done
= 1;
2968 /* Return the descriptor's address. */
2969 value
= (pltoff_sec
->output_section
->vma
2970 + pltoff_sec
->output_offset
2971 + dyn_i
->pltoff_offset
);
2976 /* Called through qsort to sort the .IA_64.unwind section during a
2977 non-relocatable link. Set elfNN_ia64_unwind_entry_compare_bfd
2978 to the output bfd so we can do proper endianness frobbing. */
2980 static bfd
*elfNN_ia64_unwind_entry_compare_bfd
;
2983 elfNN_ia64_unwind_entry_compare (a
, b
)
2989 av
= bfd_get_64 (elfNN_ia64_unwind_entry_compare_bfd
, a
);
2990 bv
= bfd_get_64 (elfNN_ia64_unwind_entry_compare_bfd
, b
);
2992 return (av
< bv
? -1 : av
> bv
? 1 : 0);
2996 elfNN_ia64_final_link (abfd
, info
)
2998 struct bfd_link_info
*info
;
3000 struct elfNN_ia64_link_hash_table
*ia64_info
;
3001 asection
*unwind_output_sec
;
3003 ia64_info
= elfNN_ia64_hash_table (info
);
3005 /* Make sure we've got ourselves a nice fat __gp value. */
3006 if (!info
->relocateable
)
3008 bfd_vma min_vma
= (bfd_vma
) -1, max_vma
= 0;
3009 bfd_vma min_short_vma
= min_vma
, max_short_vma
= 0;
3010 struct elf_link_hash_entry
*gp
;
3014 /* Find the min and max vma of all sections marked short. Also
3015 collect min and max vma of any type, for use in selecting a
3017 for (os
= abfd
->sections
; os
; os
= os
->next
)
3021 if ((os
->flags
& SEC_ALLOC
) == 0)
3025 hi
= os
->vma
+ os
->_raw_size
;
3033 if (os
->flags
& SEC_SMALL_DATA
)
3035 if (min_short_vma
> lo
)
3037 if (max_short_vma
< hi
)
3042 /* See if the user wants to force a value. */
3043 gp
= elf_link_hash_lookup (elf_hash_table (info
), "__gp", false,
3047 && (gp
->root
.type
== bfd_link_hash_defined
3048 || gp
->root
.type
== bfd_link_hash_defweak
))
3050 asection
*gp_sec
= gp
->root
.u
.def
.section
;
3051 gp_val
= (gp
->root
.u
.def
.value
3052 + gp_sec
->output_section
->vma
3053 + gp_sec
->output_offset
);
3057 /* Pick a sensible value. */
3059 asection
*got_sec
= ia64_info
->got_sec
;
3061 /* Start with just the address of the .got. */
3063 gp_val
= got_sec
->output_section
->vma
;
3064 else if (max_short_vma
!= 0)
3065 gp_val
= min_short_vma
;
3069 /* If it is possible to address the entire image, but we
3070 don't with the choice above, adjust. */
3071 if (max_vma
- min_vma
< 0x400000
3072 && max_vma
- gp_val
<= 0x200000
3073 && gp_val
- min_vma
> 0x200000)
3074 gp_val
= min_vma
+ 0x200000;
3075 else if (max_short_vma
!= 0)
3077 /* If we don't cover all the short data, adjust. */
3078 if (max_short_vma
- gp_val
>= 0x200000)
3079 gp_val
= min_short_vma
+ 0x200000;
3081 /* If we're addressing stuff past the end, adjust back. */
3082 if (gp_val
> max_vma
)
3083 gp_val
= max_vma
- 0x200000 + 8;
3087 /* Validate whether all SHF_IA_64_SHORT sections are within
3088 range of the chosen GP. */
3090 if (max_short_vma
!= 0)
3092 if (max_short_vma
- min_short_vma
>= 0x400000)
3094 (*_bfd_error_handler
)
3095 (_("%s: short data segment overflowed (0x%lx >= 0x400000)"),
3096 bfd_get_filename (abfd
),
3097 (unsigned long)(max_short_vma
- min_short_vma
));
3100 else if ((gp_val
> min_short_vma
3101 && gp_val
- min_short_vma
> 0x200000)
3102 || (gp_val
< max_short_vma
3103 && max_short_vma
- gp_val
>= 0x200000))
3105 (*_bfd_error_handler
)
3106 (_("%s: __gp does not cover short data segment"),
3107 bfd_get_filename (abfd
));
3112 _bfd_set_gp_value (abfd
, gp_val
);
3115 /* Tricky bits. DT_INIT and DT_FINI use a pltoff entry, which is
3116 normally initialized in finish_dynamic_sections. Except that
3117 we need all non-plt pltoff entries to be initialized before
3118 finish_dynamic_symbols. This because the array of relocations
3119 used for plt entries (aka DT_JMPREL) begins after all the
3120 non-plt pltoff relocations. If the order gets confused, we
3121 munge either the array or the array base. */
3122 if (ia64_info
->root
.dynamic_sections_created
)
3124 struct elf_link_hash_entry
*h
;
3125 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
3128 if (info
->init_function
3129 && (h
= elf_link_hash_lookup (elf_hash_table (info
),
3130 info
->init_function
, false,
3132 && (h
->elf_link_hash_flags
& (ELF_LINK_HASH_REF_REGULAR
3133 | ELF_LINK_HASH_DEF_REGULAR
)) != 0)
3135 dyn_i
= get_dyn_sym_info (ia64_info
, h
, NULL
, NULL
, false);
3136 addr
= (h
->root
.u
.def
.section
->output_section
->vma
3137 + h
->root
.u
.def
.section
->output_offset
3138 + h
->root
.u
.def
.value
);
3139 (void) set_pltoff_entry (abfd
, info
, dyn_i
, addr
, false);
3142 if (info
->fini_function
3143 && (h
= elf_link_hash_lookup (elf_hash_table (info
),
3144 info
->fini_function
, false,
3146 && (h
->elf_link_hash_flags
& (ELF_LINK_HASH_REF_REGULAR
3147 | ELF_LINK_HASH_DEF_REGULAR
)) != 0)
3149 dyn_i
= get_dyn_sym_info (ia64_info
, h
, NULL
, NULL
, false);
3150 addr
= (h
->root
.u
.def
.section
->output_section
->vma
3151 + h
->root
.u
.def
.section
->output_offset
3152 + h
->root
.u
.def
.value
);
3153 (void) set_pltoff_entry (abfd
, info
, dyn_i
, addr
, false);
3157 /* If we're producing a final executable, we need to sort the contents
3158 of the .IA_64.unwind section. Force this section to be relocated
3159 into memory rather than written immediately to the output file. */
3160 unwind_output_sec
= NULL
;
3161 if (!info
->relocateable
)
3163 asection
*s
= bfd_get_section_by_name (abfd
, ELF_STRING_ia64_unwind
);
3166 unwind_output_sec
= s
->output_section
;
3167 unwind_output_sec
->contents
3168 = bfd_malloc (unwind_output_sec
->_raw_size
);
3169 if (unwind_output_sec
->contents
== NULL
)
3174 /* Invoke the regular ELF backend linker to do all the work. */
3175 if (!bfd_elfNN_bfd_final_link (abfd
, info
))
3178 if (unwind_output_sec
)
3180 elfNN_ia64_unwind_entry_compare_bfd
= abfd
;
3181 qsort (unwind_output_sec
->contents
, unwind_output_sec
->_raw_size
/ 24,
3182 24, elfNN_ia64_unwind_entry_compare
);
3184 if (! bfd_set_section_contents (abfd
, unwind_output_sec
,
3185 unwind_output_sec
->contents
, 0,
3186 unwind_output_sec
->_raw_size
))
3194 elfNN_ia64_relocate_section (output_bfd
, info
, input_bfd
, input_section
,
3195 contents
, relocs
, local_syms
, local_sections
)
3197 struct bfd_link_info
*info
;
3199 asection
*input_section
;
3201 Elf_Internal_Rela
*relocs
;
3202 Elf_Internal_Sym
*local_syms
;
3203 asection
**local_sections
;
3205 struct elfNN_ia64_link_hash_table
*ia64_info
;
3206 Elf_Internal_Shdr
*symtab_hdr
;
3207 Elf_Internal_Rela
*rel
;
3208 Elf_Internal_Rela
*relend
;
3210 boolean ret_val
= true; /* for non-fatal errors */
3213 symtab_hdr
= &elf_tdata (input_bfd
)->symtab_hdr
;
3214 ia64_info
= elfNN_ia64_hash_table (info
);
3216 /* Infect various flags from the input section to the output section. */
3217 if (info
->relocateable
)
3221 flags
= elf_section_data(input_section
)->this_hdr
.sh_flags
;
3222 flags
&= SHF_IA_64_NORECOV
;
3224 elf_section_data(input_section
->output_section
)
3225 ->this_hdr
.sh_flags
|= flags
;
3228 gp_val
= _bfd_get_gp_value (output_bfd
);
3229 srel
= get_reloc_section (input_bfd
, ia64_info
, input_section
, false);
3232 relend
= relocs
+ input_section
->reloc_count
;
3233 for (; rel
< relend
; ++rel
)
3235 struct elf_link_hash_entry
*h
;
3236 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
3237 bfd_reloc_status_type r
;
3238 reloc_howto_type
*howto
;
3239 unsigned long r_symndx
;
3240 Elf_Internal_Sym
*sym
;
3241 unsigned int r_type
;
3245 boolean dynamic_symbol_p
;
3246 boolean undef_weak_ref
;
3248 r_type
= ELFNN_R_TYPE (rel
->r_info
);
3249 if (r_type
> R_IA64_MAX_RELOC_CODE
)
3251 (*_bfd_error_handler
)
3252 (_("%s: unknown relocation type %d"),
3253 bfd_get_filename (input_bfd
), (int)r_type
);
3254 bfd_set_error (bfd_error_bad_value
);
3258 howto
= lookup_howto (r_type
);
3259 r_symndx
= ELFNN_R_SYM (rel
->r_info
);
3261 if (info
->relocateable
)
3263 /* This is a relocateable link. We don't have to change
3264 anything, unless the reloc is against a section symbol,
3265 in which case we have to adjust according to where the
3266 section symbol winds up in the output section. */
3267 if (r_symndx
< symtab_hdr
->sh_info
)
3269 sym
= local_syms
+ r_symndx
;
3270 if (ELF_ST_TYPE (sym
->st_info
) == STT_SECTION
)
3272 sym_sec
= local_sections
[r_symndx
];
3273 rel
->r_addend
+= sym_sec
->output_offset
;
3279 /* This is a final link. */
3284 undef_weak_ref
= false;
3286 if (r_symndx
< symtab_hdr
->sh_info
)
3288 /* Reloc against local symbol. */
3289 sym
= local_syms
+ r_symndx
;
3290 sym_sec
= local_sections
[r_symndx
];
3291 value
= (sym_sec
->output_section
->vma
3292 + sym_sec
->output_offset
3299 /* Reloc against global symbol. */
3300 indx
= r_symndx
- symtab_hdr
->sh_info
;
3301 h
= elf_sym_hashes (input_bfd
)[indx
];
3302 while (h
->root
.type
== bfd_link_hash_indirect
3303 || h
->root
.type
== bfd_link_hash_warning
)
3304 h
= (struct elf_link_hash_entry
*) h
->root
.u
.i
.link
;
3307 if (h
->root
.type
== bfd_link_hash_defined
3308 || h
->root
.type
== bfd_link_hash_defweak
)
3310 sym_sec
= h
->root
.u
.def
.section
;
3312 /* Detect the cases that sym_sec->output_section is
3313 expected to be NULL -- all cases in which the symbol
3314 is defined in another shared module. This includes
3315 PLT relocs for which we've created a PLT entry and
3316 other relocs for which we're prepared to create
3317 dynamic relocations. */
3318 /* ??? Just accept it NULL and continue. */
3320 if (sym_sec
->output_section
!= NULL
)
3322 value
= (h
->root
.u
.def
.value
3323 + sym_sec
->output_section
->vma
3324 + sym_sec
->output_offset
);
3327 else if (h
->root
.type
== bfd_link_hash_undefweak
)
3328 undef_weak_ref
= true;
3329 else if (info
->shared
&& !info
->symbolic
3330 && !info
->no_undefined
3331 && ELF_ST_VISIBILITY (h
->other
) == STV_DEFAULT
)
3335 if (! ((*info
->callbacks
->undefined_symbol
)
3336 (info
, h
->root
.root
.string
, input_bfd
,
3337 input_section
, rel
->r_offset
,
3338 (!info
->shared
|| info
->no_undefined
3339 || ELF_ST_VISIBILITY (h
->other
)))))
3346 hit_addr
= contents
+ rel
->r_offset
;
3347 value
+= rel
->r_addend
;
3348 dynamic_symbol_p
= elfNN_ia64_dynamic_symbol_p (h
, info
);
3359 case R_IA64_DIR32MSB
:
3360 case R_IA64_DIR32LSB
:
3361 case R_IA64_DIR64MSB
:
3362 case R_IA64_DIR64LSB
:
3363 /* Install a dynamic relocation for this reloc. */
3364 if ((dynamic_symbol_p
|| info
->shared
)
3365 && (input_section
->flags
& SEC_ALLOC
) != 0)
3367 unsigned int dyn_r_type
;
3370 BFD_ASSERT (srel
!= NULL
);
3372 /* If we don't need dynamic symbol lookup, find a
3373 matching RELATIVE relocation. */
3374 dyn_r_type
= r_type
;
3375 if (dynamic_symbol_p
)
3376 dynindx
= h
->dynindx
;
3381 case R_IA64_DIR32MSB
:
3382 dyn_r_type
= R_IA64_REL32MSB
;
3384 case R_IA64_DIR32LSB
:
3385 dyn_r_type
= R_IA64_REL32LSB
;
3387 case R_IA64_DIR64MSB
:
3388 dyn_r_type
= R_IA64_REL64MSB
;
3390 case R_IA64_DIR64LSB
:
3391 dyn_r_type
= R_IA64_REL64LSB
;
3395 /* We can't represent this without a dynamic symbol.
3396 Adjust the relocation to be against an output
3397 section symbol, which are always present in the
3398 dynamic symbol table. */
3399 /* ??? People shouldn't be doing non-pic code in
3400 shared libraries. Hork. */
3401 (*_bfd_error_handler
)
3402 (_("%s: linking non-pic code in a shared library"),
3403 bfd_get_filename (input_bfd
));
3410 elfNN_ia64_install_dyn_reloc (output_bfd
, info
, input_section
,
3411 srel
, rel
->r_offset
, dyn_r_type
,
3412 dynindx
, rel
->r_addend
);
3416 case R_IA64_LTV32MSB
:
3417 case R_IA64_LTV32LSB
:
3418 case R_IA64_LTV64MSB
:
3419 case R_IA64_LTV64LSB
:
3420 r
= elfNN_ia64_install_value (output_bfd
, hit_addr
, value
, r_type
);
3423 case R_IA64_GPREL22
:
3424 case R_IA64_GPREL64I
:
3425 case R_IA64_GPREL32MSB
:
3426 case R_IA64_GPREL32LSB
:
3427 case R_IA64_GPREL64MSB
:
3428 case R_IA64_GPREL64LSB
:
3429 if (dynamic_symbol_p
)
3431 (*_bfd_error_handler
)
3432 (_("%s: @gprel relocation against dynamic symbol %s"),
3433 bfd_get_filename (input_bfd
), h
->root
.root
.string
);
3438 r
= elfNN_ia64_install_value (output_bfd
, hit_addr
, value
, r_type
);
3441 case R_IA64_LTOFF22
:
3442 case R_IA64_LTOFF22X
:
3443 case R_IA64_LTOFF64I
:
3444 dyn_i
= get_dyn_sym_info (ia64_info
, h
, input_bfd
, rel
, false);
3445 value
= set_got_entry (input_bfd
, info
, dyn_i
, (h
? h
->dynindx
: -1),
3446 rel
->r_addend
, value
, R_IA64_DIR64LSB
);
3448 r
= elfNN_ia64_install_value (output_bfd
, hit_addr
, value
, r_type
);
3451 case R_IA64_PLTOFF22
:
3452 case R_IA64_PLTOFF64I
:
3453 case R_IA64_PLTOFF64MSB
:
3454 case R_IA64_PLTOFF64LSB
:
3455 dyn_i
= get_dyn_sym_info (ia64_info
, h
, input_bfd
, rel
, false);
3456 value
= set_pltoff_entry (output_bfd
, info
, dyn_i
, value
, false);
3458 r
= elfNN_ia64_install_value (output_bfd
, hit_addr
, value
, r_type
);
3461 case R_IA64_FPTR64I
:
3462 case R_IA64_FPTR32MSB
:
3463 case R_IA64_FPTR32LSB
:
3464 case R_IA64_FPTR64MSB
:
3465 case R_IA64_FPTR64LSB
:
3466 dyn_i
= get_dyn_sym_info (ia64_info
, h
, input_bfd
, rel
, false);
3467 if (dyn_i
->want_fptr
)
3469 if (!undef_weak_ref
)
3470 value
= set_fptr_entry (output_bfd
, info
, dyn_i
, value
);
3476 /* Otherwise, we expect the dynamic linker to create
3481 if (h
->dynindx
!= -1)
3482 dynindx
= h
->dynindx
;
3484 dynindx
= (_bfd_elf_link_lookup_local_dynindx
3485 (info
, h
->root
.u
.def
.section
->owner
,
3486 global_sym_index (h
)));
3490 dynindx
= (_bfd_elf_link_lookup_local_dynindx
3491 (info
, input_bfd
, r_symndx
));
3494 elfNN_ia64_install_dyn_reloc (output_bfd
, info
, input_section
,
3495 srel
, rel
->r_offset
, r_type
,
3496 dynindx
, rel
->r_addend
);
3500 r
= elfNN_ia64_install_value (output_bfd
, hit_addr
, value
, r_type
);
3503 case R_IA64_LTOFF_FPTR22
:
3504 case R_IA64_LTOFF_FPTR64I
:
3505 case R_IA64_LTOFF_FPTR64MSB
:
3506 case R_IA64_LTOFF_FPTR64LSB
:
3510 dyn_i
= get_dyn_sym_info (ia64_info
, h
, input_bfd
, rel
, false);
3511 if (dyn_i
->want_fptr
)
3513 BFD_ASSERT (h
== NULL
|| h
->dynindx
== -1)
3514 if (!undef_weak_ref
)
3515 value
= set_fptr_entry (output_bfd
, info
, dyn_i
, value
);
3520 /* Otherwise, we expect the dynamic linker to create
3524 if (h
->dynindx
!= -1)
3525 dynindx
= h
->dynindx
;
3527 dynindx
= (_bfd_elf_link_lookup_local_dynindx
3528 (info
, h
->root
.u
.def
.section
->owner
,
3529 global_sym_index (h
)));
3532 dynindx
= (_bfd_elf_link_lookup_local_dynindx
3533 (info
, input_bfd
, r_symndx
));
3537 value
= set_got_entry (output_bfd
, info
, dyn_i
, dynindx
,
3538 rel
->r_addend
, value
, R_IA64_FPTR64LSB
);
3540 r
= elfNN_ia64_install_value (output_bfd
, hit_addr
, value
, r_type
);
3544 case R_IA64_PCREL32MSB
:
3545 case R_IA64_PCREL32LSB
:
3546 case R_IA64_PCREL64MSB
:
3547 case R_IA64_PCREL64LSB
:
3548 /* Install a dynamic relocation for this reloc. */
3549 if (dynamic_symbol_p
)
3551 BFD_ASSERT (srel
!= NULL
);
3553 elfNN_ia64_install_dyn_reloc (output_bfd
, info
, input_section
,
3554 srel
, rel
->r_offset
, r_type
,
3555 h
->dynindx
, rel
->r_addend
);
3559 case R_IA64_PCREL21BI
:
3560 case R_IA64_PCREL21F
:
3561 case R_IA64_PCREL21M
:
3562 /* ??? These two are only used for speculation fixup code.
3563 They should never be dynamic. */
3564 if (dynamic_symbol_p
)
3566 (*_bfd_error_handler
)
3567 (_("%s: dynamic relocation against speculation fixup"),
3568 bfd_get_filename (input_bfd
));
3574 (*_bfd_error_handler
)
3575 (_("%s: speculation fixup against undefined weak symbol"),
3576 bfd_get_filename (input_bfd
));
3582 case R_IA64_PCREL21B
:
3583 case R_IA64_PCREL60B
:
3584 /* We should have created a PLT entry for any dynamic symbol. */
3587 dyn_i
= get_dyn_sym_info (ia64_info
, h
, NULL
, NULL
, false);
3589 if (dyn_i
&& dyn_i
->want_plt2
)
3591 /* Should have caught this earlier. */
3592 BFD_ASSERT (rel
->r_addend
== 0);
3594 value
= (ia64_info
->plt_sec
->output_section
->vma
3595 + ia64_info
->plt_sec
->output_offset
3596 + dyn_i
->plt2_offset
);
3600 /* Since there's no PLT entry, Validate that this is
3602 BFD_ASSERT (undef_weak_ref
|| sym_sec
->output_section
!= NULL
);
3604 /* If the symbol is undef_weak, we shouldn't be trying
3605 to call it. There's every chance that we'd wind up
3606 with an out-of-range fixup here. Don't bother setting
3607 any value at all. */
3613 case R_IA64_PCREL22
:
3614 case R_IA64_PCREL64I
:
3616 /* Make pc-relative. */
3617 value
-= (input_section
->output_section
->vma
3618 + input_section
->output_offset
3619 + rel
->r_offset
) & ~ (bfd_vma
) 0x3;
3620 r
= elfNN_ia64_install_value (output_bfd
, hit_addr
, value
, r_type
);
3623 case R_IA64_SEGREL32MSB
:
3624 case R_IA64_SEGREL32LSB
:
3625 case R_IA64_SEGREL64MSB
:
3626 case R_IA64_SEGREL64LSB
:
3628 struct elf_segment_map
*m
;
3629 Elf_Internal_Phdr
*p
;
3631 /* Find the segment that contains the output_section. */
3632 for (m
= elf_tdata (output_bfd
)->segment_map
,
3633 p
= elf_tdata (output_bfd
)->phdr
;
3638 for (i
= m
->count
- 1; i
>= 0; i
--)
3639 if (m
->sections
[i
] == sym_sec
->output_section
)
3647 /* If the input section was discarded from the output, then
3650 if (bfd_is_abs_section (sym_sec
->output_section
))
3653 r
= bfd_reloc_notsupported
;
3657 /* The VMA of the segment is the vaddr of the associated
3659 if (value
> p
->p_vaddr
)
3660 value
-= p
->p_vaddr
;
3663 r
= elfNN_ia64_install_value (output_bfd
, hit_addr
, value
,
3669 case R_IA64_SECREL32MSB
:
3670 case R_IA64_SECREL32LSB
:
3671 case R_IA64_SECREL64MSB
:
3672 case R_IA64_SECREL64LSB
:
3673 /* Make output-section relative. */
3674 if (value
> input_section
->output_section
->vma
)
3675 value
-= input_section
->output_section
->vma
;
3678 r
= elfNN_ia64_install_value (output_bfd
, hit_addr
, value
, r_type
);
3681 case R_IA64_SEGBASE
:
3683 case R_IA64_REL32MSB
:
3684 case R_IA64_REL32LSB
:
3685 case R_IA64_REL64MSB
:
3686 case R_IA64_REL64LSB
:
3688 case R_IA64_IPLTMSB
:
3689 case R_IA64_IPLTLSB
:
3690 case R_IA64_EPLTMSB
:
3691 case R_IA64_EPLTLSB
:
3694 case R_IA64_TPREL22
:
3695 case R_IA64_TPREL64MSB
:
3696 case R_IA64_TPREL64LSB
:
3697 case R_IA64_LTOFF_TP22
:
3699 r
= bfd_reloc_notsupported
;
3708 case bfd_reloc_undefined
:
3709 /* This can happen for global table relative relocs if
3710 __gp is undefined. This is a panic situation so we
3711 don't try to continue. */
3712 (*info
->callbacks
->undefined_symbol
)
3713 (info
, "__gp", input_bfd
, input_section
, rel
->r_offset
, 1);
3716 case bfd_reloc_notsupported
:
3721 name
= h
->root
.root
.string
;
3724 name
= bfd_elf_string_from_elf_section (input_bfd
,
3725 symtab_hdr
->sh_link
,
3730 name
= bfd_section_name (input_bfd
, input_section
);
3732 if (!(*info
->callbacks
->warning
) (info
, _("unsupported reloc"),
3734 input_section
, rel
->r_offset
))
3740 case bfd_reloc_dangerous
:
3741 case bfd_reloc_outofrange
:
3742 case bfd_reloc_overflow
:
3748 name
= h
->root
.root
.string
;
3751 name
= bfd_elf_string_from_elf_section (input_bfd
,
3752 symtab_hdr
->sh_link
,
3757 name
= bfd_section_name (input_bfd
, input_section
);
3759 if (!(*info
->callbacks
->reloc_overflow
) (info
, name
,
3775 elfNN_ia64_finish_dynamic_symbol (output_bfd
, info
, h
, sym
)
3777 struct bfd_link_info
*info
;
3778 struct elf_link_hash_entry
*h
;
3779 Elf_Internal_Sym
*sym
;
3781 struct elfNN_ia64_link_hash_table
*ia64_info
;
3782 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
3784 ia64_info
= elfNN_ia64_hash_table (info
);
3785 dyn_i
= get_dyn_sym_info (ia64_info
, h
, NULL
, NULL
, false);
3787 /* Fill in the PLT data, if required. */
3788 if (dyn_i
&& dyn_i
->want_plt
)
3790 Elf_Internal_Rela outrel
;
3793 bfd_vma plt_addr
, pltoff_addr
, gp_val
, index
;
3794 ElfNN_External_Rela
*rel
;
3796 gp_val
= _bfd_get_gp_value (output_bfd
);
3798 /* Initialize the minimal PLT entry. */
3800 index
= (dyn_i
->plt_offset
- PLT_HEADER_SIZE
) / PLT_MIN_ENTRY_SIZE
;
3801 plt_sec
= ia64_info
->plt_sec
;
3802 loc
= plt_sec
->contents
+ dyn_i
->plt_offset
;
3804 memcpy (loc
, plt_min_entry
, PLT_MIN_ENTRY_SIZE
);
3805 elfNN_ia64_install_value (output_bfd
, loc
, index
, R_IA64_IMM22
);
3806 elfNN_ia64_install_value (output_bfd
, loc
+2, -dyn_i
->plt_offset
,
3809 plt_addr
= (plt_sec
->output_section
->vma
3810 + plt_sec
->output_offset
3811 + dyn_i
->plt_offset
);
3812 pltoff_addr
= set_pltoff_entry (output_bfd
, info
, dyn_i
, plt_addr
, true);
3814 /* Initialize the FULL PLT entry, if needed. */
3815 if (dyn_i
->want_plt2
)
3817 loc
= plt_sec
->contents
+ dyn_i
->plt2_offset
;
3819 memcpy (loc
, plt_full_entry
, PLT_FULL_ENTRY_SIZE
);
3820 elfNN_ia64_install_value (output_bfd
, loc
, pltoff_addr
- gp_val
,
3823 /* Mark the symbol as undefined, rather than as defined in the
3824 plt section. Leave the value alone. */
3825 /* ??? We didn't redefine it in adjust_dynamic_symbol in the
3826 first place. But perhaps elflink.h did some for us. */
3827 if ((h
->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR
) == 0)
3828 sym
->st_shndx
= SHN_UNDEF
;
3831 /* Create the dynamic relocation. */
3832 outrel
.r_offset
= pltoff_addr
;
3833 if (bfd_little_endian (output_bfd
))
3834 outrel
.r_info
= ELFNN_R_INFO (h
->dynindx
, R_IA64_IPLTLSB
);
3836 outrel
.r_info
= ELFNN_R_INFO (h
->dynindx
, R_IA64_IPLTMSB
);
3837 outrel
.r_addend
= 0;
3839 /* This is fun. In the .IA_64.pltoff section, we've got entries
3840 that correspond both to real PLT entries, and those that
3841 happened to resolve to local symbols but need to be created
3842 to satisfy @pltoff relocations. The .rela.IA_64.pltoff
3843 relocations for the real PLT should come at the end of the
3844 section, so that they can be indexed by plt entry at runtime.
3846 We emitted all of the relocations for the non-PLT @pltoff
3847 entries during relocate_section. So we can consider the
3848 existing sec->reloc_count to be the base of the array of
3851 rel
= (ElfNN_External_Rela
*)ia64_info
->rel_pltoff_sec
->contents
;
3852 rel
+= ia64_info
->rel_pltoff_sec
->reloc_count
;
3854 bfd_elfNN_swap_reloca_out (output_bfd
, &outrel
, rel
+ index
);
3857 /* Mark some specially defined symbols as absolute. */
3858 if (strcmp (h
->root
.root
.string
, "_DYNAMIC") == 0
3859 || strcmp (h
->root
.root
.string
, "_GLOBAL_OFFSET_TABLE_") == 0
3860 || strcmp (h
->root
.root
.string
, "_PROCEDURE_LINKAGE_TABLE_") == 0)
3861 sym
->st_shndx
= SHN_ABS
;
3867 elfNN_ia64_finish_dynamic_sections (abfd
, info
)
3869 struct bfd_link_info
*info
;
3871 struct elfNN_ia64_link_hash_table
*ia64_info
;
3874 ia64_info
= elfNN_ia64_hash_table (info
);
3875 dynobj
= ia64_info
->root
.dynobj
;
3877 if (elf_hash_table (info
)->dynamic_sections_created
)
3879 ElfNN_External_Dyn
*dyncon
, *dynconend
;
3880 asection
*sdyn
, *sgotplt
;
3883 sdyn
= bfd_get_section_by_name (dynobj
, ".dynamic");
3884 sgotplt
= bfd_get_section_by_name (dynobj
, ".got.plt");
3885 BFD_ASSERT (sdyn
!= NULL
);
3886 dyncon
= (ElfNN_External_Dyn
*) sdyn
->contents
;
3887 dynconend
= (ElfNN_External_Dyn
*) (sdyn
->contents
+ sdyn
->_raw_size
);
3889 gp_val
= _bfd_get_gp_value (abfd
);
3891 for (; dyncon
< dynconend
; dyncon
++)
3893 Elf_Internal_Dyn dyn
;
3895 bfd_elfNN_swap_dyn_in (dynobj
, dyncon
, &dyn
);
3900 dyn
.d_un
.d_ptr
= gp_val
;
3904 dyn
.d_un
.d_val
= (ia64_info
->minplt_entries
3905 * sizeof (ElfNN_External_Rela
));
3909 /* See the comment above in finish_dynamic_symbol. */
3910 dyn
.d_un
.d_ptr
= (ia64_info
->rel_pltoff_sec
->output_section
->vma
3911 + ia64_info
->rel_pltoff_sec
->output_offset
3912 + (ia64_info
->rel_pltoff_sec
->reloc_count
3913 * sizeof (ElfNN_External_Rela
)));
3916 case DT_IA_64_PLT_RESERVE
:
3917 dyn
.d_un
.d_ptr
= (sgotplt
->output_section
->vma
3918 + sgotplt
->output_offset
);
3922 /* Do not have RELASZ include JMPREL. This makes things
3923 easier on ld.so. This is not what the rest of BFD set up. */
3924 dyn
.d_un
.d_val
-= (ia64_info
->minplt_entries
3925 * sizeof (ElfNN_External_Rela
));
3931 struct elf_link_hash_entry
*h
;
3932 struct elfNN_ia64_dyn_sym_info
*dyn_i
;
3935 if (dyn
.d_tag
== DT_INIT
)
3936 which
= info
->init_function
;
3938 which
= info
->fini_function
;
3940 h
= elf_link_hash_lookup (elf_hash_table (info
), which
,
3941 false, false, false);
3942 dyn_i
= get_dyn_sym_info (ia64_info
, h
, NULL
, NULL
, false);
3943 dyn
.d_un
.d_ptr
= set_pltoff_entry (abfd
, info
, dyn_i
,
3948 bfd_elfNN_swap_dyn_out (abfd
, &dyn
, dyncon
);
3951 /* Initialize the PLT0 entry */
3952 if (ia64_info
->plt_sec
)
3954 bfd_byte
*loc
= ia64_info
->plt_sec
->contents
;
3957 memcpy (loc
, plt_header
, PLT_HEADER_SIZE
);
3959 pltres
= (sgotplt
->output_section
->vma
3960 + sgotplt
->output_offset
3963 elfNN_ia64_install_value (abfd
, loc
+1, pltres
, R_IA64_GPREL22
);
3970 /* ELF file flag handling: */
3972 /* Function to keep IA-64 specific file flags. */
3974 elfNN_ia64_set_private_flags (abfd
, flags
)
3978 BFD_ASSERT (!elf_flags_init (abfd
)
3979 || elf_elfheader (abfd
)->e_flags
== flags
);
3981 elf_elfheader (abfd
)->e_flags
= flags
;
3982 elf_flags_init (abfd
) = true;
3986 /* Copy backend specific data from one object module to another */
3988 elfNN_ia64_copy_private_bfd_data (ibfd
, obfd
)
3991 if ( bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
3992 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
3995 BFD_ASSERT (!elf_flags_init (obfd
)
3996 || (elf_elfheader (obfd
)->e_flags
3997 == elf_elfheader (ibfd
)->e_flags
));
3999 elf_elfheader (obfd
)->e_flags
= elf_elfheader (ibfd
)->e_flags
;
4000 elf_flags_init (obfd
) = true;
4004 /* Merge backend specific data from an object file to the output
4005 object file when linking. */
4007 elfNN_ia64_merge_private_bfd_data (ibfd
, obfd
)
4014 /* Don't even pretend to support mixed-format linking. */
4015 if (bfd_get_flavour (ibfd
) != bfd_target_elf_flavour
4016 || bfd_get_flavour (obfd
) != bfd_target_elf_flavour
)
4019 in_flags
= elf_elfheader (ibfd
)->e_flags
;
4020 out_flags
= elf_elfheader (obfd
)->e_flags
;
4022 if (! elf_flags_init (obfd
))
4024 elf_flags_init (obfd
) = true;
4025 elf_elfheader (obfd
)->e_flags
= in_flags
;
4027 if (bfd_get_arch (obfd
) == bfd_get_arch (ibfd
)
4028 && bfd_get_arch_info (obfd
)->the_default
)
4030 return bfd_set_arch_mach (obfd
, bfd_get_arch (ibfd
),
4031 bfd_get_mach (ibfd
));
4037 /* Check flag compatibility. */
4038 if (in_flags
== out_flags
)
4041 /* Output has EF_IA_64_REDUCEDFP set only if all inputs have it set. */
4042 if (!(in_flags
& EF_IA_64_REDUCEDFP
) && (out_flags
& EF_IA_64_REDUCEDFP
))
4043 elf_elfheader (obfd
)->e_flags
&= ~EF_IA_64_REDUCEDFP
;
4045 if ((in_flags
& EF_IA_64_TRAPNIL
) != (out_flags
& EF_IA_64_TRAPNIL
))
4047 (*_bfd_error_handler
)
4048 (_("%s: linking trap-on-NULL-dereference with non-trapping files"),
4049 bfd_get_filename (ibfd
));
4051 bfd_set_error (bfd_error_bad_value
);
4054 if ((in_flags
& EF_IA_64_BE
) != (out_flags
& EF_IA_64_BE
))
4056 (*_bfd_error_handler
)
4057 (_("%s: linking big-endian files with little-endian files"),
4058 bfd_get_filename (ibfd
));
4060 bfd_set_error (bfd_error_bad_value
);
4063 if ((in_flags
& EF_IA_64_ABI64
) != (out_flags
& EF_IA_64_ABI64
))
4065 (*_bfd_error_handler
)
4066 (_("%s: linking 64-bit files with 32-bit files"),
4067 bfd_get_filename (ibfd
));
4069 bfd_set_error (bfd_error_bad_value
);
4072 if ((in_flags
& EF_IA_64_CONS_GP
) != (out_flags
& EF_IA_64_CONS_GP
))
4074 (*_bfd_error_handler
)
4075 (_("%s: linking constant-gp files with non-constant-gp files"),
4076 bfd_get_filename (ibfd
));
4078 bfd_set_error (bfd_error_bad_value
);
4081 if ((in_flags
& EF_IA_64_NOFUNCDESC_CONS_GP
)
4082 != (out_flags
& EF_IA_64_NOFUNCDESC_CONS_GP
))
4084 (*_bfd_error_handler
)
4085 (_("%s: linking auto-pic files with non-auto-pic files"),
4086 bfd_get_filename (ibfd
));
4088 bfd_set_error (bfd_error_bad_value
);
4096 elfNN_ia64_print_private_bfd_data (abfd
, ptr
)
4100 FILE *file
= (FILE *) ptr
;
4101 flagword flags
= elf_elfheader (abfd
)->e_flags
;
4103 BFD_ASSERT (abfd
!= NULL
&& ptr
!= NULL
);
4105 fprintf (file
, "private flags = %s%s%s%s%s%s%s%s\n",
4106 (flags
& EF_IA_64_TRAPNIL
) ? "TRAPNIL, " : "",
4107 (flags
& EF_IA_64_EXT
) ? "EXT, " : "",
4108 (flags
& EF_IA_64_BE
) ? "BE, " : "LE, ",
4109 (flags
& EF_IA_64_REDUCEDFP
) ? "REDUCEDFP, " : "",
4110 (flags
& EF_IA_64_CONS_GP
) ? "CONS_GP, " : "",
4111 (flags
& EF_IA_64_NOFUNCDESC_CONS_GP
) ? "NOFUNCDESC_CONS_GP, " : "",
4112 (flags
& EF_IA_64_ABSOLUTE
) ? "ABSOLUTE, " : "",
4113 (flags
& EF_IA_64_ABI64
) ? "ABI64" : "ABI32");
4115 _bfd_elf_print_private_bfd_data (abfd
, ptr
);
4119 #define TARGET_LITTLE_SYM bfd_elfNN_ia64_little_vec
4120 #define TARGET_LITTLE_NAME "elfNN-ia64-little"
4121 #define TARGET_BIG_SYM bfd_elfNN_ia64_big_vec
4122 #define TARGET_BIG_NAME "elfNN-ia64-big"
4123 #define ELF_ARCH bfd_arch_ia64
4124 #define ELF_MACHINE_CODE EM_IA_64
4125 #define ELF_MACHINE_ALT1 1999 /* EAS2.3 */
4126 #define ELF_MACHINE_ALT2 1998 /* EAS2.2 */
4127 #define ELF_MAXPAGESIZE 0x10000 /* 64KB */
4129 #define elf_backend_section_from_shdr \
4130 elfNN_ia64_section_from_shdr
4131 #define elf_backend_section_flags \
4132 elfNN_ia64_section_flags
4133 #define elf_backend_fake_sections \
4134 elfNN_ia64_fake_sections
4135 #define elf_backend_add_symbol_hook \
4136 elfNN_ia64_add_symbol_hook
4137 #define elf_backend_additional_program_headers \
4138 elfNN_ia64_additional_program_headers
4139 #define elf_backend_modify_segment_map \
4140 elfNN_ia64_modify_segment_map
4141 #define elf_info_to_howto \
4142 elfNN_ia64_info_to_howto
4144 #define bfd_elfNN_bfd_reloc_type_lookup \
4145 elfNN_ia64_reloc_type_lookup
4146 #define bfd_elfNN_bfd_is_local_label_name \
4147 elfNN_ia64_is_local_label_name
4148 #define bfd_elfNN_bfd_relax_section \
4149 elfNN_ia64_relax_section
4151 /* Stuff for the BFD linker: */
4152 #define bfd_elfNN_bfd_link_hash_table_create \
4153 elfNN_ia64_hash_table_create
4154 #define elf_backend_create_dynamic_sections \
4155 elfNN_ia64_create_dynamic_sections
4156 #define elf_backend_check_relocs \
4157 elfNN_ia64_check_relocs
4158 #define elf_backend_adjust_dynamic_symbol \
4159 elfNN_ia64_adjust_dynamic_symbol
4160 #define elf_backend_size_dynamic_sections \
4161 elfNN_ia64_size_dynamic_sections
4162 #define elf_backend_relocate_section \
4163 elfNN_ia64_relocate_section
4164 #define elf_backend_finish_dynamic_symbol \
4165 elfNN_ia64_finish_dynamic_symbol
4166 #define elf_backend_finish_dynamic_sections \
4167 elfNN_ia64_finish_dynamic_sections
4168 #define bfd_elfNN_bfd_final_link \
4169 elfNN_ia64_final_link
4171 #define bfd_elfNN_bfd_copy_private_bfd_data \
4172 elfNN_ia64_copy_private_bfd_data
4173 #define bfd_elfNN_bfd_merge_private_bfd_data \
4174 elfNN_ia64_merge_private_bfd_data
4175 #define bfd_elfNN_bfd_set_private_flags \
4176 elfNN_ia64_set_private_flags
4177 #define bfd_elfNN_bfd_print_private_bfd_data \
4178 elfNN_ia64_print_private_bfd_data
4180 #define elf_backend_plt_readonly 1
4181 #define elf_backend_want_plt_sym 0
4182 #define elf_backend_plt_alignment 5
4183 #define elf_backend_got_header_size 0
4184 #define elf_backend_plt_header_size PLT_HEADER_SIZE
4185 #define elf_backend_want_got_plt 1
4186 #define elf_backend_may_use_rel_p 1
4187 #define elf_backend_may_use_rela_p 1
4188 #define elf_backend_default_use_rela_p 1
4189 #define elf_backend_want_dynbss 0
4190 #define elf_backend_copy_indirect_symbol elfNN_ia64_hash_copy_indirect
4191 #define elf_backend_hide_symbol elfNN_ia64_hash_hide_symbol
4193 #include "elfNN-target.h"