Commit | Line | Data |
---|---|---|
297a4f1a ILT |
1 | /* ALPHA-specific support for 64-bit ELF |
2 | Copyright 1996 Free Software Foundation, Inc. | |
3 | Contributed by Richard Henderson <rth@tamu.edu>. | |
4 | ||
5 | This file is part of BFD, the Binary File Descriptor library. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
20 | ||
21 | /* We need a published ABI spec for this. Until one comes out, don't | |
22 | assume this'll remain unchanged forever. */ | |
23 | ||
24 | #include "bfd.h" | |
25 | #include "sysdep.h" | |
26 | #include "libbfd.h" | |
27 | #include "elf-bfd.h" | |
28 | ||
29 | #include "elf/alpha.h" | |
30 | ||
31 | #define ALPHAECOFF | |
32 | ||
33 | #define NO_COFF_RELOCS | |
34 | #define NO_COFF_SYMBOLS | |
35 | #define NO_COFF_LINENOS | |
36 | ||
37 | /* Get the ECOFF swapping routines. Needed for the debug information. */ | |
38 | #include "coff/internal.h" | |
39 | #include "coff/sym.h" | |
40 | #include "coff/symconst.h" | |
41 | #include "coff/ecoff.h" | |
42 | #include "coff/alpha.h" | |
43 | #include "aout/ar.h" | |
44 | #include "libcoff.h" | |
45 | #include "libecoff.h" | |
46 | #define ECOFF_64 | |
47 | #include "ecoffswap.h" | |
48 | ||
49 | static struct bfd_hash_entry * elf64_alpha_link_hash_newfunc | |
50 | PARAMS((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); | |
51 | static struct bfd_link_hash_table * elf64_alpha_bfd_link_hash_table_create | |
52 | PARAMS((bfd *)); | |
53 | ||
54 | static bfd_reloc_status_type elf64_alpha_reloc_nil | |
55 | PARAMS((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); | |
56 | static bfd_reloc_status_type elf64_alpha_do_reloc_gpdisp | |
57 | PARAMS((bfd *, bfd_vma, bfd_byte *, bfd_byte *)); | |
58 | static bfd_reloc_status_type elf64_alpha_reloc_gpdisp | |
59 | PARAMS((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); | |
60 | static bfd_reloc_status_type elf64_alpha_reloc_op_push | |
61 | PARAMS((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); | |
62 | static bfd_reloc_status_type elf64_alpha_reloc_op_store | |
63 | PARAMS((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); | |
64 | static bfd_reloc_status_type elf64_alpha_reloc_op_psub | |
65 | PARAMS((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); | |
66 | static bfd_reloc_status_type elf64_alpha_reloc_op_prshift | |
67 | PARAMS((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); | |
68 | ||
69 | static reloc_howto_type * elf64_alpha_bfd_reloc_type_lookup | |
70 | PARAMS((bfd *, bfd_reloc_code_real_type)); | |
71 | static void elf64_alpha_info_to_howto | |
72 | PARAMS((bfd *, arelent *, Elf64_Internal_Rela *)); | |
73 | ||
74 | static boolean elf64_alpha_object_p | |
75 | PARAMS((bfd *)); | |
76 | static boolean elf64_alpha_section_from_shdr | |
77 | PARAMS((bfd *, Elf64_Internal_Shdr *, char *)); | |
78 | static boolean elf64_alpha_fake_sections | |
79 | PARAMS((bfd *, Elf64_Internal_Shdr *, asection *)); | |
80 | static int elf64_alpha_additional_program_headers | |
81 | PARAMS((bfd *)); | |
82 | static boolean elf64_alpha_create_got_section | |
83 | PARAMS((bfd *, struct bfd_link_info *)); | |
84 | static boolean elf64_alpha_create_dynamic_sections | |
85 | PARAMS((bfd *, struct bfd_link_info *)); | |
86 | ||
87 | static boolean elf64_alpha_read_ecoff_info | |
88 | PARAMS((bfd *, asection *, struct ecoff_debug_info *)); | |
89 | static boolean elf64_alpha_is_local_label | |
90 | PARAMS((bfd *, asymbol *)); | |
91 | static boolean elf64_alpha_find_nearest_line | |
92 | PARAMS((bfd *, asection *, asymbol **, bfd_vma, const char **, | |
93 | const char **, unsigned int *)); | |
94 | ||
95 | struct alpha_elf_link_hash_entry; | |
96 | static boolean elf64_alpha_output_extsym | |
97 | PARAMS((struct alpha_elf_link_hash_entry *, PTR)); | |
98 | ||
99 | static boolean elf64_alpha_check_relocs | |
100 | PARAMS((bfd *, struct bfd_link_info *, asection *sec, | |
101 | const Elf_Internal_Rela *)); | |
102 | static boolean elf64_alpha_adjust_dynamic_symbol | |
103 | PARAMS((struct bfd_link_info *, struct elf_link_hash_entry *)); | |
104 | static boolean elf64_alpha_size_dynamic_sections | |
105 | PARAMS((bfd *, struct bfd_link_info *)); | |
106 | static boolean elf64_alpha_adjust_dynindx | |
107 | PARAMS((struct elf_link_hash_entry *, PTR)); | |
108 | static boolean elf64_alpha_relocate_section | |
109 | PARAMS((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, | |
110 | Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); | |
111 | static boolean elf64_alpha_finish_dynamic_symbol | |
112 | PARAMS((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, | |
113 | Elf_Internal_Sym *)); | |
114 | static boolean elf64_alpha_finish_dynamic_sections | |
115 | PARAMS((bfd *, struct bfd_link_info *)); | |
116 | static boolean elf64_alpha_final_link | |
117 | PARAMS((bfd *, struct bfd_link_info *)); | |
118 | ||
119 | \f | |
120 | #define alpha_elf_tdata(bfd) \ | |
121 | ((struct alpha_elf_obj_tdata *)elf_tdata(bfd)->tdata) | |
122 | ||
123 | struct alpha_elf_link_hash_entry | |
124 | { | |
125 | struct elf_link_hash_entry root; | |
126 | ||
127 | /* External symbol information. */ | |
128 | EXTR esym; | |
129 | }; | |
130 | ||
131 | /* Alpha ELF linker hash table. */ | |
132 | ||
133 | struct alpha_elf_link_hash_table | |
134 | { | |
135 | struct elf_link_hash_table root; | |
136 | }; | |
137 | ||
138 | /* Look up an entry in a Alpha ELF linker hash table. */ | |
139 | ||
140 | #define alpha_elf_link_hash_lookup(table, string, create, copy, follow) \ | |
141 | ((struct alpha_elf_link_hash_entry *) \ | |
142 | elf_link_hash_lookup (&(table)->root, (string), (create), \ | |
143 | (copy), (follow))) | |
144 | ||
145 | /* Traverse a Alpha ELF linker hash table. */ | |
146 | ||
147 | #define alpha_elf_link_hash_traverse(table, func, info) \ | |
148 | (elf_link_hash_traverse \ | |
149 | (&(table)->root, \ | |
150 | (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \ | |
151 | (info))) | |
152 | ||
153 | /* Get the Alpha ELF linker hash table from a link_info structure. */ | |
154 | ||
155 | #define alpha_elf_hash_table(p) \ | |
156 | ((struct alpha_elf_link_hash_table *) ((p)->hash)) | |
157 | ||
158 | /* Create an entry in a Alpha ELF linker hash table. */ | |
159 | ||
160 | static struct bfd_hash_entry * | |
161 | elf64_alpha_link_hash_newfunc (entry, table, string) | |
162 | struct bfd_hash_entry *entry; | |
163 | struct bfd_hash_table *table; | |
164 | const char *string; | |
165 | { | |
166 | struct alpha_elf_link_hash_entry *ret = | |
167 | (struct alpha_elf_link_hash_entry *) entry; | |
168 | ||
169 | /* Allocate the structure if it has not already been allocated by a | |
170 | subclass. */ | |
171 | if (ret == (struct alpha_elf_link_hash_entry *) NULL) | |
172 | ret = ((struct alpha_elf_link_hash_entry *) | |
173 | bfd_hash_allocate (table, | |
174 | sizeof (struct alpha_elf_link_hash_entry))); | |
175 | if (ret == (struct alpha_elf_link_hash_entry *) NULL) | |
176 | return (struct bfd_hash_entry *) ret; | |
177 | ||
178 | /* Call the allocation method of the superclass. */ | |
179 | ret = ((struct alpha_elf_link_hash_entry *) | |
180 | _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret, | |
181 | table, string)); | |
182 | if (ret != (struct alpha_elf_link_hash_entry *) NULL) | |
183 | { | |
184 | /* Set local fields. */ | |
185 | memset (&ret->esym, 0, sizeof (EXTR)); | |
186 | /* We use -2 as a marker to indicate that the information has | |
187 | not been set. -1 means there is no associated ifd. */ | |
188 | ret->esym.ifd = -2; | |
189 | } | |
190 | ||
191 | return (struct bfd_hash_entry *) ret; | |
192 | } | |
193 | ||
194 | /* Create a Alpha ELF linker hash table. */ | |
195 | ||
196 | static struct bfd_link_hash_table * | |
197 | elf64_alpha_bfd_link_hash_table_create (abfd) | |
198 | bfd *abfd; | |
199 | { | |
200 | struct alpha_elf_link_hash_table *ret; | |
201 | ||
202 | ret = ((struct alpha_elf_link_hash_table *) | |
203 | bfd_zalloc (abfd, sizeof (struct alpha_elf_link_hash_table))); | |
204 | if (ret == (struct alpha_elf_link_hash_table *) NULL) | |
205 | return NULL; | |
206 | ||
207 | if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, | |
208 | elf64_alpha_link_hash_newfunc)) | |
209 | { | |
210 | bfd_release (abfd, ret); | |
211 | return NULL; | |
212 | } | |
213 | ||
214 | return &ret->root.root; | |
215 | } | |
216 | \f | |
217 | ||
218 | /* In case we're on a 32-bit machine, construct a 64-bit "-1" value | |
219 | from smaller values. Start with zero, widen, *then* decrement. */ | |
220 | #define MINUS_ONE (((bfd_vma)0) - 1) | |
221 | ||
222 | static reloc_howto_type elf64_alpha_howto_table[] = | |
223 | { | |
224 | HOWTO (R_ALPHA_NONE, /* type */ | |
225 | 0, /* rightshift */ | |
226 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
227 | 8, /* bitsize */ | |
228 | true, /* pc_relative */ | |
229 | 0, /* bitpos */ | |
230 | complain_overflow_dont, /* complain_on_overflow */ | |
231 | elf64_alpha_reloc_nil, /* special_function */ | |
232 | "NONE", /* name */ | |
233 | false, /* partial_inplace */ | |
234 | 0, /* src_mask */ | |
235 | 0, /* dst_mask */ | |
236 | true), /* pcrel_offset */ | |
237 | ||
238 | /* A 32 bit reference to a symbol. */ | |
239 | HOWTO (R_ALPHA_REFLONG, /* type */ | |
240 | 0, /* rightshift */ | |
241 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
242 | 32, /* bitsize */ | |
243 | false, /* pc_relative */ | |
244 | 0, /* bitpos */ | |
245 | complain_overflow_bitfield, /* complain_on_overflow */ | |
246 | 0, /* special_function */ | |
247 | "REFLONG", /* name */ | |
248 | false, /* partial_inplace */ | |
249 | 0xffffffff, /* src_mask */ | |
250 | 0xffffffff, /* dst_mask */ | |
251 | false), /* pcrel_offset */ | |
252 | ||
253 | /* A 64 bit reference to a symbol. */ | |
254 | HOWTO (R_ALPHA_REFQUAD, /* type */ | |
255 | 0, /* rightshift */ | |
256 | 4, /* size (0 = byte, 1 = short, 2 = long) */ | |
257 | 64, /* bitsize */ | |
258 | false, /* pc_relative */ | |
259 | 0, /* bitpos */ | |
260 | complain_overflow_bitfield, /* complain_on_overflow */ | |
261 | 0, /* special_function */ | |
262 | "REFQUAD", /* name */ | |
263 | false, /* partial_inplace */ | |
264 | MINUS_ONE, /* src_mask */ | |
265 | MINUS_ONE, /* dst_mask */ | |
266 | false), /* pcrel_offset */ | |
267 | ||
268 | /* A 32 bit GP relative offset. This is just like REFLONG except | |
269 | that when the value is used the value of the gp register will be | |
270 | added in. */ | |
271 | HOWTO (R_ALPHA_GPREL32, /* type */ | |
272 | 0, /* rightshift */ | |
273 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
274 | 32, /* bitsize */ | |
275 | false, /* pc_relative */ | |
276 | 0, /* bitpos */ | |
277 | complain_overflow_bitfield, /* complain_on_overflow */ | |
278 | 0, /* special_function */ | |
279 | "GPREL32", /* name */ | |
280 | false, /* partial_inplace */ | |
281 | 0xffffffff, /* src_mask */ | |
282 | 0xffffffff, /* dst_mask */ | |
283 | false), /* pcrel_offset */ | |
284 | ||
285 | /* Used for an instruction that refers to memory off the GP register. */ | |
286 | HOWTO (R_ALPHA_LITERAL, /* type */ | |
287 | 0, /* rightshift */ | |
288 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
289 | 16, /* bitsize */ | |
290 | false, /* pc_relative */ | |
291 | 0, /* bitpos */ | |
292 | complain_overflow_signed, /* complain_on_overflow */ | |
293 | 0, /* special_function */ | |
294 | "LITERAL", /* name */ | |
295 | false, /* partial_inplace */ | |
296 | 0xffff, /* src_mask */ | |
297 | 0xffff, /* dst_mask */ | |
298 | false), /* pcrel_offset */ | |
299 | ||
300 | /* This reloc only appears immediately following a LITERAL reloc. | |
301 | It identifies a use of the literal. The symbol index is special: | |
302 | 1 means the literal address is in the base register of a memory | |
303 | format instruction; 2 means the literal address is in the byte | |
304 | offset register of a byte-manipulation instruction; 3 means the | |
305 | literal address is in the target register of a jsr instruction. | |
306 | This does not actually do any relocation. */ | |
307 | HOWTO (R_ALPHA_LITUSE, /* type */ | |
308 | 0, /* rightshift */ | |
309 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
310 | 32, /* bitsize */ | |
311 | false, /* pc_relative */ | |
312 | 0, /* bitpos */ | |
313 | complain_overflow_dont, /* complain_on_overflow */ | |
314 | elf64_alpha_reloc_nil, /* special_function */ | |
315 | "LITUSE", /* name */ | |
316 | false, /* partial_inplace */ | |
317 | 0, /* src_mask */ | |
318 | 0, /* dst_mask */ | |
319 | false), /* pcrel_offset */ | |
320 | ||
321 | /* Load the gp register. This is always used for a ldah instruction | |
322 | which loads the upper 16 bits of the gp register. The symbol | |
323 | index of the GPDISP instruction is an offset in bytes to the lda | |
324 | instruction that loads the lower 16 bits. The value to use for | |
325 | the relocation is the difference between the GP value and the | |
326 | current location; the load will always be done against a register | |
327 | holding the current address. | |
328 | ||
329 | NOTE: Unlike ECOFF, partial inplace relocation is not done. If | |
330 | any offset is present in the instructions, it is an offset from | |
331 | the register to the ldah instruction. This lets us avoid any | |
332 | stupid hackery like inventing a gp value to do partial relocation | |
333 | against. Also unlike ECOFF, we do the whole relocation off of | |
334 | the GPDISP rather than a GPDISP_HI16/GPDISP_LO16 pair. An odd, | |
335 | space consuming bit, that, since all the information was present | |
336 | in the GPDISP_HI16 reloc. */ | |
337 | HOWTO (R_ALPHA_GPDISP, /* type */ | |
338 | 16, /* rightshift */ | |
339 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
340 | 16, /* bitsize */ | |
341 | false, /* pc_relative */ | |
342 | 0, /* bitpos */ | |
343 | complain_overflow_dont, /* complain_on_overflow */ | |
344 | elf64_alpha_reloc_gpdisp, /* special_function */ | |
345 | "GPDISP", /* name */ | |
346 | false, /* partial_inplace */ | |
347 | 0xffff, /* src_mask */ | |
348 | 0xffff, /* dst_mask */ | |
349 | true), /* pcrel_offset */ | |
350 | ||
351 | /* A 21 bit branch. */ | |
352 | HOWTO (R_ALPHA_BRADDR, /* type */ | |
353 | 2, /* rightshift */ | |
354 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
355 | 21, /* bitsize */ | |
356 | true, /* pc_relative */ | |
357 | 0, /* bitpos */ | |
358 | complain_overflow_signed, /* complain_on_overflow */ | |
359 | 0, /* special_function */ | |
360 | "BRADDR", /* name */ | |
361 | false, /* partial_inplace */ | |
362 | 0x1fffff, /* src_mask */ | |
363 | 0x1fffff, /* dst_mask */ | |
364 | true), /* pcrel_offset */ | |
365 | ||
366 | /* A hint for a jump to a register. */ | |
367 | HOWTO (R_ALPHA_HINT, /* type */ | |
368 | 2, /* rightshift */ | |
369 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
370 | 14, /* bitsize */ | |
371 | true, /* pc_relative */ | |
372 | 0, /* bitpos */ | |
373 | complain_overflow_dont, /* complain_on_overflow */ | |
374 | 0, /* special_function */ | |
375 | "HINT", /* name */ | |
376 | false, /* partial_inplace */ | |
377 | 0x3fff, /* src_mask */ | |
378 | 0x3fff, /* dst_mask */ | |
379 | true), /* pcrel_offset */ | |
380 | ||
381 | /* 16 bit PC relative offset. */ | |
382 | HOWTO (R_ALPHA_SREL16, /* type */ | |
383 | 0, /* rightshift */ | |
384 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
385 | 16, /* bitsize */ | |
386 | true, /* pc_relative */ | |
387 | 0, /* bitpos */ | |
388 | complain_overflow_signed, /* complain_on_overflow */ | |
389 | 0, /* special_function */ | |
390 | "SREL16", /* name */ | |
391 | false, /* partial_inplace */ | |
392 | 0xffff, /* src_mask */ | |
393 | 0xffff, /* dst_mask */ | |
394 | false), /* pcrel_offset */ | |
395 | ||
396 | /* 32 bit PC relative offset. */ | |
397 | HOWTO (R_ALPHA_SREL32, /* type */ | |
398 | 0, /* rightshift */ | |
399 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
400 | 32, /* bitsize */ | |
401 | true, /* pc_relative */ | |
402 | 0, /* bitpos */ | |
403 | complain_overflow_signed, /* complain_on_overflow */ | |
404 | 0, /* special_function */ | |
405 | "SREL32", /* name */ | |
406 | false, /* partial_inplace */ | |
407 | 0xffffffff, /* src_mask */ | |
408 | 0xffffffff, /* dst_mask */ | |
409 | false), /* pcrel_offset */ | |
410 | ||
411 | /* A 64 bit PC relative offset. */ | |
412 | HOWTO (R_ALPHA_SREL64, /* type */ | |
413 | 0, /* rightshift */ | |
414 | 4, /* size (0 = byte, 1 = short, 2 = long) */ | |
415 | 64, /* bitsize */ | |
416 | true, /* pc_relative */ | |
417 | 0, /* bitpos */ | |
418 | complain_overflow_signed, /* complain_on_overflow */ | |
419 | 0, /* special_function */ | |
420 | "SREL64", /* name */ | |
421 | false, /* partial_inplace */ | |
422 | MINUS_ONE, /* src_mask */ | |
423 | MINUS_ONE, /* dst_mask */ | |
424 | false), /* pcrel_offset */ | |
425 | ||
426 | /* Push a value on the reloc evaluation stack. */ | |
427 | HOWTO (ALPHA_R_OP_PUSH, /* type */ | |
428 | 0, /* rightshift */ | |
429 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
430 | 0, /* bitsize */ | |
431 | false, /* pc_relative */ | |
432 | 0, /* bitpos */ | |
433 | complain_overflow_dont, /* complain_on_overflow */ | |
434 | elf64_alpha_reloc_op_push, /* special_function */ | |
435 | "OP_PUSH", /* name */ | |
436 | false, /* partial_inplace */ | |
437 | 0, /* src_mask */ | |
438 | 0, /* dst_mask */ | |
439 | false), /* pcrel_offset */ | |
440 | ||
441 | /* Store the value from the stack at the given address. Store it in | |
442 | a bitfield of size r_size starting at bit position r_offset. */ | |
443 | HOWTO (ALPHA_R_OP_STORE, /* type */ | |
444 | 0, /* rightshift */ | |
445 | 4, /* size (0 = byte, 1 = short, 2 = long) */ | |
446 | 64, /* bitsize */ | |
447 | false, /* pc_relative */ | |
448 | 0, /* bitpos */ | |
449 | complain_overflow_dont, /* complain_on_overflow */ | |
450 | elf64_alpha_reloc_op_store, /* special_function */ | |
451 | "OP_STORE", /* name */ | |
452 | false, /* partial_inplace */ | |
453 | 0, /* src_mask */ | |
454 | MINUS_ONE, /* dst_mask */ | |
455 | false), /* pcrel_offset */ | |
456 | ||
457 | /* Subtract the reloc address from the value on the top of the | |
458 | relocation stack. */ | |
459 | HOWTO (ALPHA_R_OP_PSUB, /* type */ | |
460 | 0, /* rightshift */ | |
461 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
462 | 0, /* bitsize */ | |
463 | false, /* pc_relative */ | |
464 | 0, /* bitpos */ | |
465 | complain_overflow_dont, /* complain_on_overflow */ | |
466 | elf64_alpha_reloc_op_psub, /* special_function */ | |
467 | "OP_PSUB", /* name */ | |
468 | false, /* partial_inplace */ | |
469 | 0, /* src_mask */ | |
470 | 0, /* dst_mask */ | |
471 | false), /* pcrel_offset */ | |
472 | ||
473 | /* Shift the value on the top of the relocation stack right by the | |
474 | given value. */ | |
475 | HOWTO (ALPHA_R_OP_PRSHIFT, /* type */ | |
476 | 0, /* rightshift */ | |
477 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
478 | 0, /* bitsize */ | |
479 | false, /* pc_relative */ | |
480 | 0, /* bitpos */ | |
481 | complain_overflow_dont, /* complain_on_overflow */ | |
482 | elf64_alpha_reloc_op_prshift, /* special_function */ | |
483 | "OP_PRSHIFT", /* name */ | |
484 | false, /* partial_inplace */ | |
485 | 0, /* src_mask */ | |
486 | 0, /* dst_mask */ | |
487 | false), /* pcrel_offset */ | |
488 | ||
489 | /* Misc ELF relocations. */ | |
490 | HOWTO (R_ALPHA_COPY, | |
491 | 0, | |
492 | 0, | |
493 | 0, | |
494 | false, | |
495 | 0, | |
496 | complain_overflow_dont, | |
497 | bfd_elf_generic_reloc, | |
498 | "COPY", | |
499 | false, | |
500 | 0, | |
501 | 0, | |
502 | true), | |
503 | ||
504 | HOWTO (R_ALPHA_GLOB_DAT, | |
505 | 0, | |
506 | 0, | |
507 | 0, | |
508 | false, | |
509 | 0, | |
510 | complain_overflow_dont, | |
511 | bfd_elf_generic_reloc, | |
512 | "GLOB_DAT", | |
513 | false, | |
514 | 0, | |
515 | 0, | |
516 | true), | |
517 | ||
518 | HOWTO (R_ALPHA_JMP_SLOT, | |
519 | 0, | |
520 | 0, | |
521 | 0, | |
522 | false, | |
523 | 0, | |
524 | complain_overflow_dont, | |
525 | bfd_elf_generic_reloc, | |
526 | "JMP_SLOT", | |
527 | false, | |
528 | 0, | |
529 | 0, | |
530 | true), | |
531 | ||
532 | HOWTO (R_ALPHA_RELATIVE, | |
533 | 0, | |
534 | 0, | |
535 | 0, | |
536 | false, | |
537 | 0, | |
538 | complain_overflow_dont, | |
539 | bfd_elf_generic_reloc, | |
540 | "RELATIVE", | |
541 | false, | |
542 | 0, | |
543 | 0, | |
544 | true) | |
545 | }; | |
546 | ||
547 | static bfd_reloc_status_type | |
548 | elf64_alpha_reloc_nil (abfd, reloc, sym, data, sec, output_bfd, error_message) | |
549 | bfd *abfd; | |
550 | arelent *reloc; | |
551 | asymbol *sym; | |
552 | PTR data; | |
553 | asection *sec; | |
554 | bfd *output_bfd; | |
555 | char **error_message; | |
556 | { | |
557 | if (output_bfd) | |
558 | reloc->address += sec->output_offset; | |
559 | return bfd_reloc_ok; | |
560 | } | |
561 | ||
562 | static bfd_reloc_status_type | |
563 | elf64_alpha_do_reloc_gpdisp (abfd, gpdisp, p_ldah, p_lda) | |
564 | bfd *abfd; | |
565 | bfd_vma gpdisp; | |
566 | bfd_byte *p_ldah, *p_lda; | |
567 | { | |
568 | bfd_reloc_status_type ret = bfd_reloc_ok; | |
569 | bfd_vma addend; | |
570 | unsigned long i_ldah, i_lda; | |
571 | ||
572 | i_ldah = bfd_get_32(abfd, p_ldah); | |
573 | i_lda = bfd_get_32(abfd, p_lda); | |
574 | ||
575 | /* Complain if the instructions are not correct. */ | |
576 | if (((i_ldah >> 26) & 0x3f) != 0x09 | |
577 | || ((i_lda >> 26) & 0x3f) != 0x08) | |
578 | ret = bfd_reloc_dangerous; | |
579 | ||
580 | /* Extract the user-supplied offset, mirroring the sign extensions | |
581 | that the instructions perform. */ | |
582 | addend = ((i_ldah & 0xffff) << 16) | (i_lda & 0xffff); | |
583 | addend = (addend ^ 0x80008000) - 0x80008000; | |
584 | ||
585 | gpdisp += addend; | |
586 | ||
587 | if ((bfd_signed_vma)gpdisp < -(bfd_signed_vma)0x80000000 | |
588 | || gpdisp >= 0x7fff8000) | |
589 | ret = bfd_reloc_overflow; | |
590 | ||
591 | /* compensate for the sign extension again. */ | |
592 | i_ldah = ((i_ldah & 0xffff0000) | |
593 | | (((gpdisp >> 16) + ((gpdisp >> 15) & 1)) & 0xffff)); | |
594 | i_lda = (i_lda & 0xffff0000) | (gpdisp & 0xffff); | |
595 | ||
596 | bfd_put_32 (abfd, i_ldah, p_ldah); | |
597 | bfd_put_32 (abfd, i_lda, p_lda); | |
598 | ||
599 | return ret; | |
600 | } | |
601 | ||
602 | static bfd_reloc_status_type | |
603 | elf64_alpha_reloc_gpdisp (abfd, reloc_entry, sym, data, input_section, | |
604 | output_bfd, err_msg) | |
605 | bfd *abfd; | |
606 | arelent *reloc_entry; | |
607 | asymbol *sym; | |
608 | PTR data; | |
609 | asection *input_section; | |
610 | bfd *output_bfd; | |
611 | char **err_msg; | |
612 | { | |
613 | bfd_reloc_status_type ret; | |
614 | bfd_vma gp, relocation; | |
615 | bfd_byte *p_ldah, *p_lda; | |
616 | ||
617 | /* Don't do anything if we're not doing a final link. */ | |
618 | if (output_bfd) | |
619 | { | |
620 | reloc_entry->address += input_section->output_offset; | |
621 | return bfd_reloc_ok; | |
622 | } | |
623 | ||
624 | if (reloc_entry->address > input_section->_cooked_size || | |
625 | reloc_entry->address + reloc_entry->addend > input_section->_cooked_size) | |
626 | return bfd_reloc_outofrange; | |
627 | ||
628 | /* The gp used in the portion of the output object to which this | |
629 | input object belongs is cached on the input bfd. */ | |
630 | gp = _bfd_get_gp_value (abfd); | |
631 | ||
632 | relocation = (input_section->output_section->vma | |
633 | + input_section->output_offset | |
634 | + reloc_entry->address); | |
635 | ||
636 | p_ldah = (bfd_byte *)data + reloc_entry->address; | |
637 | p_lda = p_ldah + reloc_entry->addend; | |
638 | ||
639 | ret = elf64_alpha_do_reloc_gpdisp (abfd, gp - relocation, p_ldah, p_lda); | |
640 | ||
641 | /* Complain if the instructions are not correct. */ | |
642 | if (ret == bfd_reloc_dangerous) | |
643 | { | |
644 | *err_msg = "GPDISP relocation did not find ldah and lda instructions"; | |
645 | } | |
646 | ||
647 | return ret; | |
648 | } | |
649 | ||
650 | /* Due to the nature of the stack operations, I don't think more | |
651 | that one entry is useful. Test this theory by setting the | |
652 | stack size to a minimum. */ | |
653 | /* FIXME: BFD should not use static variables. */ | |
654 | #define OP_STACK_SIZE 1 | |
655 | static bfd_vma elf64_alpha_op_stack[OP_STACK_SIZE]; | |
656 | static int elf64_alpha_op_tos; | |
657 | ||
658 | static bfd_reloc_status_type | |
659 | elf64_alpha_reloc_op_push (abfd, reloc_entry, sym, data, input_section, | |
660 | output_bfd, err_msg) | |
661 | bfd *abfd; | |
662 | arelent *reloc_entry; | |
663 | asymbol *sym; | |
664 | PTR data; | |
665 | asection *input_section; | |
666 | bfd *output_bfd; | |
667 | char **err_msg; | |
668 | { | |
669 | bfd_reloc_status_type r = bfd_reloc_ok; | |
670 | bfd_vma value; | |
671 | ||
672 | /* Don't do anything if we're not doing a final link. */ | |
673 | if (output_bfd) | |
674 | { | |
675 | reloc_entry->address += input_section->output_offset; | |
676 | return bfd_reloc_ok; | |
677 | } | |
678 | ||
679 | if (elf64_alpha_op_tos >= OP_STACK_SIZE) | |
680 | { | |
681 | *err_msg = "operation stack overflow"; | |
682 | return bfd_reloc_dangerous; | |
683 | } | |
684 | ||
685 | /* Get the symbol value. */ | |
686 | /* FIXME: We should fail if this is a dynamic symbol. Check on that. */ | |
687 | if (bfd_is_und_section (sym->section)) | |
688 | r = bfd_reloc_undefined; | |
689 | if (bfd_is_com_section (sym->section)) | |
690 | value = 0; | |
691 | else | |
692 | value = sym->value; | |
693 | value += sym->section->output_section->vma; | |
694 | value += sym->section->output_offset; | |
695 | value += reloc_entry->addend; | |
696 | ||
697 | elf64_alpha_op_stack[elf64_alpha_op_tos++] = value; | |
698 | ||
699 | return r; | |
700 | } | |
701 | ||
702 | static bfd_reloc_status_type | |
703 | elf64_alpha_reloc_op_store (abfd, reloc_entry, sym, data, input_section, | |
704 | output_bfd, err_msg) | |
705 | bfd *abfd; | |
706 | arelent *reloc_entry; | |
707 | asymbol *sym; | |
708 | PTR data; | |
709 | asection *input_section; | |
710 | bfd *output_bfd; | |
711 | char **err_msg; | |
712 | { | |
713 | int size, offset; | |
714 | bfd_vma value; | |
715 | ||
716 | /* Don't do anything before the final link. */ | |
717 | if (output_bfd) | |
718 | { | |
719 | reloc_entry->address += input_section->output_offset; | |
720 | return bfd_reloc_ok; | |
721 | } | |
722 | ||
723 | if (elf64_alpha_op_tos <= 0) | |
724 | { | |
725 | *err_msg = "operation stack underflow"; | |
726 | return bfd_reloc_dangerous; | |
727 | } | |
728 | ||
729 | /* The offset and size for this reloc are encoded into the addend | |
730 | field by alpha_adjust_reloc_in. */ | |
731 | offset = (reloc_entry->addend >> 8) & 0xff; | |
732 | size = reloc_entry->addend & 0xff; | |
733 | ||
734 | value = bfd_get_64 (abfd, data + reloc_entry->address); | |
735 | value &= ~((((bfd_vma)1 << size) - 1) << offset); | |
736 | value |= (elf64_alpha_op_stack[--elf64_alpha_op_tos] | |
737 | & (((bfd_vma)1 << size) - 1)) << offset; | |
738 | bfd_put_64 (abfd, value, data + reloc_entry->address); | |
739 | ||
740 | return bfd_reloc_ok; | |
741 | } | |
742 | ||
743 | static bfd_reloc_status_type | |
744 | elf64_alpha_reloc_op_psub (abfd, reloc_entry, sym, data, input_section, | |
745 | output_bfd, err_msg) | |
746 | bfd *abfd; | |
747 | arelent *reloc_entry; | |
748 | asymbol *sym; | |
749 | PTR data; | |
750 | asection *input_section; | |
751 | bfd *output_bfd; | |
752 | char **err_msg; | |
753 | { | |
754 | bfd_reloc_status_type r; | |
755 | bfd_vma value; | |
756 | ||
757 | /* Don't do anything before the final link. */ | |
758 | if (output_bfd) | |
759 | { | |
760 | reloc_entry->address += input_section->output_offset; | |
761 | return bfd_reloc_ok; | |
762 | } | |
763 | ||
764 | if (elf64_alpha_op_tos <= 0) | |
765 | { | |
766 | *err_msg = "operation stack underflow"; | |
767 | return bfd_reloc_dangerous; | |
768 | } | |
769 | ||
770 | if (bfd_is_und_section (sym->section)) | |
771 | r = bfd_reloc_undefined; | |
772 | if (bfd_is_com_section (sym->section)) | |
773 | value = 0; | |
774 | else | |
775 | value = sym->value; | |
776 | value += sym->section->output_section->vma; | |
777 | value += sym->section->output_offset; | |
778 | value += reloc_entry->addend; | |
779 | ||
780 | elf64_alpha_op_stack[elf64_alpha_op_tos-1] -= value; | |
781 | ||
782 | return r; | |
783 | } | |
784 | ||
785 | static bfd_reloc_status_type | |
786 | elf64_alpha_reloc_op_prshift (abfd, reloc_entry, sym, data, input_section, | |
787 | output_bfd, err_msg) | |
788 | bfd *abfd; | |
789 | arelent *reloc_entry; | |
790 | asymbol *sym; | |
791 | PTR data; | |
792 | asection *input_section; | |
793 | bfd *output_bfd; | |
794 | char **err_msg; | |
795 | { | |
796 | /* Don't do anything before the final link. */ | |
797 | if (output_bfd) | |
798 | { | |
799 | reloc_entry->address += input_section->output_offset; | |
800 | return bfd_reloc_ok; | |
801 | } | |
802 | ||
803 | if (elf64_alpha_op_tos <= 0) | |
804 | { | |
805 | *err_msg = "operation stack underflow"; | |
806 | return bfd_reloc_dangerous; | |
807 | } | |
808 | ||
809 | elf64_alpha_op_stack[elf64_alpha_op_tos-1] >>= reloc_entry->addend; | |
810 | ||
811 | return bfd_reloc_ok; | |
812 | } | |
813 | ||
814 | /* A mapping from BFD reloc types to Alpha ELF reloc types. */ | |
815 | ||
816 | struct elf_reloc_map | |
817 | { | |
818 | bfd_reloc_code_real_type bfd_reloc_val; | |
819 | int elf_reloc_val; | |
820 | }; | |
821 | ||
822 | static const struct elf_reloc_map elf64_alpha_reloc_map[] = | |
823 | { | |
824 | {BFD_RELOC_NONE, R_ALPHA_NONE}, | |
825 | {BFD_RELOC_32, R_ALPHA_REFLONG}, | |
826 | {BFD_RELOC_64, R_ALPHA_REFQUAD}, | |
827 | {BFD_RELOC_CTOR, R_ALPHA_REFQUAD}, | |
828 | {BFD_RELOC_GPREL32, R_ALPHA_GPREL32}, | |
829 | {BFD_RELOC_ALPHA_LITERAL, R_ALPHA_LITERAL}, | |
830 | {BFD_RELOC_ALPHA_LITUSE, R_ALPHA_LITUSE}, | |
831 | {BFD_RELOC_ALPHA_GPDISP, R_ALPHA_GPDISP}, | |
832 | {BFD_RELOC_23_PCREL_S2, R_ALPHA_BRADDR}, | |
833 | {BFD_RELOC_ALPHA_HINT, R_ALPHA_HINT}, | |
834 | {BFD_RELOC_16_PCREL, R_ALPHA_SREL16}, | |
835 | {BFD_RELOC_32_PCREL, R_ALPHA_SREL32}, | |
836 | {BFD_RELOC_64_PCREL, R_ALPHA_SREL64}, | |
837 | #if 0 | |
838 | {BFD_RELOC_ALPHA_OP_PUSH, R_ALPHA_OP_PUSH}, | |
839 | {BFD_RELOC_ALPHA_OP_STORE, R_ALPHA_OP_STORE}, | |
840 | {BFD_RELOC_ALPHA_OP_PSUB, R_ALPHA_OP_PSUB}, | |
841 | {BFD_RELOC_ALPHA_OP_PRSHIFT, R_ALPHA_OP_PRSHIFT} | |
842 | #endif | |
843 | }; | |
844 | ||
845 | /* Given a BFD reloc type, return a HOWTO structure. */ | |
846 | ||
847 | static reloc_howto_type * | |
848 | elf64_alpha_bfd_reloc_type_lookup (abfd, code) | |
849 | bfd *abfd; | |
850 | bfd_reloc_code_real_type code; | |
851 | { | |
852 | const struct elf_reloc_map *i, *e; | |
853 | i = e = elf64_alpha_reloc_map; | |
854 | e += sizeof (elf64_alpha_reloc_map) / sizeof (struct elf_reloc_map); | |
855 | for (; i != e; ++i) | |
856 | { | |
857 | if (i->bfd_reloc_val == code) | |
858 | return &elf64_alpha_howto_table[i->elf_reloc_val]; | |
859 | } | |
860 | return 0; | |
861 | } | |
862 | ||
863 | /* Given an Alpha ELF reloc type, fill in an arelent structure. */ | |
864 | ||
865 | static void | |
866 | elf64_alpha_info_to_howto (abfd, cache_ptr, dst) | |
867 | bfd *abfd; | |
868 | arelent *cache_ptr; | |
869 | Elf64_Internal_Rela *dst; | |
870 | { | |
871 | unsigned r_type; | |
872 | ||
873 | r_type = ELF64_R_TYPE(dst->r_info); | |
874 | BFD_ASSERT (r_type < (unsigned int) R_ALPHA_max); | |
875 | cache_ptr->howto = &elf64_alpha_howto_table[r_type]; | |
876 | } | |
877 | \f | |
878 | /* PLT/GOT Stuff */ | |
879 | #define PLT_HEADER_SIZE 32 | |
880 | #define PLT_HEADER_WORD1 0xc3600000 /* br $27,.+4 */ | |
881 | #define PLT_HEADER_WORD2 0xa77b000c /* ldq $27,12($27) */ | |
882 | #define PLT_HEADER_WORD3 0x47ff041f /* nop */ | |
883 | #define PLT_HEADER_WORD4 0x6b7b0000 /* jmp $27,($27) */ | |
884 | ||
885 | #define PLT_ENTRY_SIZE 12 | |
886 | #define PLT_ENTRY_WORD1 0x279f0000 /* ldah $28, 0($31) */ | |
887 | #define PLT_ENTRY_WORD2 0x239c0000 /* lda $28, 0($28) */ | |
888 | #define PLT_ENTRY_WORD3 0xc3e00000 /* br $31, plt0 */ | |
889 | ||
890 | #define RESERVED_GOT_ENTRIES 1 | |
891 | ||
892 | #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so" | |
893 | \f | |
894 | /* Set the right machine number for an Alpha ELF file. */ | |
895 | ||
896 | static boolean | |
897 | elf64_alpha_object_p (abfd) | |
898 | bfd *abfd; | |
899 | { | |
900 | return bfd_default_set_arch_mach (abfd, bfd_arch_alpha, 0); | |
901 | } | |
902 | \f | |
903 | /* Handle a alpha specific section when reading an object file. This | |
904 | is called when elfcode.h finds a section with an unknown type. | |
905 | FIXME: We need to handle the SHF_MIPS_GPREL flag, but I'm not sure | |
906 | how to. */ | |
907 | ||
908 | static boolean | |
909 | elf64_alpha_section_from_shdr (abfd, hdr, name) | |
910 | bfd *abfd; | |
911 | Elf64_Internal_Shdr *hdr; | |
912 | char *name; | |
913 | { | |
914 | asection *newsect; | |
915 | ||
916 | /* There ought to be a place to keep ELF backend specific flags, but | |
917 | at the moment there isn't one. We just keep track of the | |
918 | sections by their name, instead. Fortunately, the ABI gives | |
919 | suggested names for all the MIPS specific sections, so we will | |
920 | probably get away with this. */ | |
921 | switch (hdr->sh_type) | |
922 | { | |
923 | case SHT_ALPHA_DEBUG: | |
924 | if (strcmp (name, ".mdebug") != 0) | |
925 | return false; | |
926 | break; | |
927 | #ifdef ERIC_neverdef | |
928 | case SHT_ALPHA_REGINFO: | |
929 | if (strcmp (name, ".reginfo") != 0 | |
930 | || hdr->sh_size != sizeof (Elf64_External_RegInfo)) | |
931 | return false; | |
932 | break; | |
933 | #endif | |
934 | default: | |
935 | return false; | |
936 | } | |
937 | ||
938 | if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name)) | |
939 | return false; | |
940 | newsect = hdr->bfd_section; | |
941 | ||
942 | if (hdr->sh_type == SHT_ALPHA_DEBUG) | |
943 | { | |
944 | if (! bfd_set_section_flags (abfd, newsect, | |
945 | (bfd_get_section_flags (abfd, newsect) | |
946 | | SEC_DEBUGGING))) | |
947 | return false; | |
948 | } | |
949 | ||
950 | #ifdef ERIC_neverdef | |
951 | /* For a .reginfo section, set the gp value in the tdata information | |
952 | from the contents of this section. We need the gp value while | |
953 | processing relocs, so we just get it now. */ | |
954 | if (hdr->sh_type == SHT_ALPHA_REGINFO) | |
955 | { | |
956 | Elf64_External_RegInfo ext; | |
957 | Elf64_RegInfo s; | |
958 | ||
959 | if (! bfd_get_section_contents (abfd, newsect, (PTR) &ext, | |
960 | (file_ptr) 0, sizeof ext)) | |
961 | return false; | |
962 | bfd_alpha_elf64_swap_reginfo_in (abfd, &ext, &s); | |
963 | elf_gp (abfd) = s.ri_gp_value; | |
964 | } | |
965 | #endif | |
966 | ||
967 | return true; | |
968 | } | |
969 | ||
970 | /* Set the correct type for an Alpha ELF section. We do this by the | |
971 | section name, which is a hack, but ought to work. */ | |
972 | ||
973 | static boolean | |
974 | elf64_alpha_fake_sections (abfd, hdr, sec) | |
975 | bfd *abfd; | |
976 | Elf64_Internal_Shdr *hdr; | |
977 | asection *sec; | |
978 | { | |
979 | register const char *name; | |
980 | ||
981 | name = bfd_get_section_name (abfd, sec); | |
982 | ||
983 | if (strcmp (name, ".mdebug") == 0) | |
984 | { | |
985 | hdr->sh_type = SHT_ALPHA_DEBUG; | |
986 | /* In a shared object on Irix 5.3, the .mdebug section has an | |
987 | entsize of 0. FIXME: Does this matter? */ | |
988 | if ((abfd->flags & DYNAMIC) != 0 ) | |
989 | hdr->sh_entsize = 0; | |
990 | else | |
991 | hdr->sh_entsize = 1; | |
992 | } | |
993 | #ifdef ERIC_neverdef | |
994 | else if (strcmp (name, ".reginfo") == 0) | |
995 | { | |
996 | hdr->sh_type = SHT_ALPHA_REGINFO; | |
997 | /* In a shared object on Irix 5.3, the .reginfo section has an | |
998 | entsize of 0x18. FIXME: Does this matter? */ | |
999 | if ((abfd->flags & DYNAMIC) != 0) | |
1000 | hdr->sh_entsize = sizeof (Elf64_External_RegInfo); | |
1001 | else | |
1002 | hdr->sh_entsize = 1; | |
1003 | ||
1004 | /* Force the section size to the correct value, even if the | |
1005 | linker thinks it is larger. The link routine below will only | |
1006 | write out this much data for .reginfo. */ | |
1007 | hdr->sh_size = sec->_raw_size = sizeof (Elf64_External_RegInfo); | |
1008 | } | |
1009 | else if (strcmp (name, ".hash") == 0 | |
1010 | || strcmp (name, ".dynamic") == 0 | |
1011 | || strcmp (name, ".dynstr") == 0) | |
1012 | { | |
1013 | hdr->sh_entsize = 0; | |
1014 | hdr->sh_info = SIZEOF_ALPHA_DYNSYM_SECNAMES; | |
1015 | } | |
1016 | else if (strcmp (name, ".sdata") == 0 | |
1017 | || strcmp (name, ".sbss") == 0 | |
1018 | || strcmp (name, ".lit4") == 0 | |
1019 | || strcmp (name, ".lit8") == 0) | |
1020 | hdr->sh_flags |= SHF_ALPHA_GPREL; | |
1021 | #endif | |
1022 | ||
1023 | return true; | |
1024 | } | |
1025 | ||
1026 | static int | |
1027 | elf64_alpha_additional_program_headers (abfd) | |
1028 | bfd *abfd; | |
1029 | { | |
1030 | asection *s; | |
1031 | int ret; | |
1032 | ||
1033 | ret = 0; | |
1034 | ||
1035 | s = bfd_get_section_by_name (abfd, ".reginfo"); | |
1036 | if (s != NULL && (s->flags & SEC_LOAD) != 0) | |
1037 | { | |
1038 | /* We need a PT_ALPHA_REGINFO segment. */ | |
1039 | ++ret; | |
1040 | } | |
1041 | ||
1042 | if (bfd_get_section_by_name (abfd, ".dynamic") != NULL | |
1043 | && bfd_get_section_by_name (abfd, ".mdebug") != NULL) | |
1044 | { | |
1045 | /* We need a PT_ALPHA_RTPROC segment. */ | |
1046 | ++ret; | |
1047 | } | |
1048 | ||
1049 | return ret; | |
1050 | } | |
1051 | ||
1052 | static boolean | |
1053 | elf64_alpha_create_got_section(abfd, info) | |
1054 | bfd *abfd; | |
1055 | struct bfd_link_info *info; | |
1056 | { | |
1057 | asection *s; | |
1058 | struct elf_link_hash_entry *h; | |
1059 | ||
1060 | if (bfd_get_section_by_name (abfd, ".got")) | |
1061 | return true; | |
1062 | ||
1063 | s = bfd_make_section(abfd, ".rela.got"); | |
1064 | if (s == NULL | |
1065 | || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD | |
1066 | | SEC_HAS_CONTENTS | SEC_IN_MEMORY | |
1067 | | SEC_READONLY)) | |
1068 | || !bfd_set_section_alignment (abfd, s, 3)) | |
1069 | return false; | |
1070 | ||
1071 | s = bfd_make_section(abfd, ".got"); | |
1072 | if (s == NULL | |
1073 | || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD | |
1074 | | SEC_HAS_CONTENTS | SEC_IN_MEMORY)) | |
1075 | || !bfd_set_section_alignment (abfd, s, 3)) | |
1076 | return false; | |
1077 | ||
1078 | s->_raw_size = RESERVED_GOT_ENTRIES * 8; | |
1079 | ||
1080 | /* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the .got | |
1081 | (or .got.plt) section. We don't do this in the linker script | |
1082 | because we don't want to define the symbol if we are not creating | |
1083 | a global offset table. */ | |
1084 | h = NULL; | |
1085 | if (!(_bfd_generic_link_add_one_symbol | |
1086 | (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s, (bfd_vma) 0, | |
1087 | (const char *) NULL, false, get_elf_backend_data (abfd)->collect, | |
1088 | (struct bfd_link_hash_entry **) &h))) | |
1089 | return false; | |
1090 | h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; | |
1091 | h->type = STT_OBJECT; | |
1092 | ||
1093 | if (info->shared | |
1094 | && ! _bfd_elf_link_record_dynamic_symbol (info, h)) | |
1095 | return false; | |
1096 | ||
1097 | elf_hash_table (info)->hgot = h; | |
1098 | ||
1099 | return true; | |
1100 | } | |
1101 | ||
1102 | static boolean | |
1103 | elf64_alpha_create_dynamic_sections (abfd, info) | |
1104 | bfd *abfd; | |
1105 | struct bfd_link_info *info; | |
1106 | { | |
1107 | register asection *s; | |
1108 | struct elf_link_hash_entry *h; | |
1109 | ||
1110 | /* We need to create .plt, .rela.plt, .got, and .rela.got sections. */ | |
1111 | ||
1112 | s = bfd_make_section (abfd, ".plt"); | |
1113 | if (s == NULL | |
1114 | || ! bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD | |
1115 | | SEC_HAS_CONTENTS | SEC_IN_MEMORY | |
1116 | | SEC_CODE)) | |
1117 | || ! bfd_set_section_alignment (abfd, s, 3)) | |
1118 | return false; | |
1119 | ||
1120 | /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the | |
1121 | .plt section. */ | |
1122 | h = NULL; | |
1123 | if (! (_bfd_generic_link_add_one_symbol | |
1124 | (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s, | |
1125 | (bfd_vma) 0, (const char *) NULL, false, | |
1126 | get_elf_backend_data (abfd)->collect, | |
1127 | (struct bfd_link_hash_entry **) &h))) | |
1128 | return false; | |
1129 | h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; | |
1130 | h->type = STT_OBJECT; | |
1131 | ||
1132 | if (info->shared | |
1133 | && ! _bfd_elf_link_record_dynamic_symbol (info, h)) | |
1134 | return false; | |
1135 | ||
1136 | s = bfd_make_section (abfd, ".rela.plt"); | |
1137 | if (s == NULL | |
1138 | || !bfd_set_section_flags (abfd, s, (SEC_ALLOC | SEC_LOAD | |
1139 | | SEC_HAS_CONTENTS | SEC_IN_MEMORY | |
1140 | | SEC_READONLY)) | |
1141 | || ! bfd_set_section_alignment (abfd, s, 3)) | |
1142 | return false; | |
1143 | ||
1144 | if (!elf64_alpha_create_got_section (abfd, info)) | |
1145 | return false; | |
1146 | ||
1147 | return true; | |
1148 | } | |
1149 | ||
1150 | /* The structure of the runtile procedure descriptor created by the | |
1151 | loader for use by the static exception system. */ | |
1152 | ||
1153 | /* FIXME */ | |
1154 | \f | |
1155 | /* Read ECOFF debugging information from a .mdebug section into a | |
1156 | ecoff_debug_info structure. */ | |
1157 | ||
1158 | static boolean | |
1159 | elf64_alpha_read_ecoff_info (abfd, section, debug) | |
1160 | bfd *abfd; | |
1161 | asection *section; | |
1162 | struct ecoff_debug_info *debug; | |
1163 | { | |
1164 | HDRR *symhdr; | |
1165 | const struct ecoff_debug_swap *swap; | |
1166 | char *ext_hdr = NULL; | |
1167 | ||
1168 | swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap; | |
1169 | ||
1170 | ext_hdr = (char *) bfd_malloc ((size_t) swap->external_hdr_size); | |
1171 | if (ext_hdr == NULL && swap->external_hdr_size != 0) | |
1172 | goto error_return; | |
1173 | ||
1174 | if (bfd_get_section_contents (abfd, section, ext_hdr, (file_ptr) 0, | |
1175 | swap->external_hdr_size) | |
1176 | == false) | |
1177 | goto error_return; | |
1178 | ||
1179 | symhdr = &debug->symbolic_header; | |
1180 | (*swap->swap_hdr_in) (abfd, ext_hdr, symhdr); | |
1181 | ||
1182 | /* The symbolic header contains absolute file offsets and sizes to | |
1183 | read. */ | |
1184 | #define READ(ptr, offset, count, size, type) \ | |
1185 | if (symhdr->count == 0) \ | |
1186 | debug->ptr = NULL; \ | |
1187 | else \ | |
1188 | { \ | |
1189 | debug->ptr = (type) bfd_malloc ((size_t) (size * symhdr->count)); \ | |
1190 | if (debug->ptr == NULL) \ | |
1191 | goto error_return; \ | |
1192 | if (bfd_seek (abfd, (file_ptr) symhdr->offset, SEEK_SET) != 0 \ | |
1193 | || (bfd_read (debug->ptr, size, symhdr->count, \ | |
1194 | abfd) != size * symhdr->count)) \ | |
1195 | goto error_return; \ | |
1196 | } | |
1197 | ||
1198 | READ (line, cbLineOffset, cbLine, sizeof (unsigned char), unsigned char *); | |
1199 | READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, PTR); | |
1200 | READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, PTR); | |
1201 | READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size, PTR); | |
1202 | READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size, PTR); | |
1203 | READ (external_aux, cbAuxOffset, iauxMax, sizeof (union aux_ext), | |
1204 | union aux_ext *); | |
1205 | READ (ss, cbSsOffset, issMax, sizeof (char), char *); | |
1206 | READ (ssext, cbSsExtOffset, issExtMax, sizeof (char), char *); | |
1207 | READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, PTR); | |
1208 | READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, PTR); | |
1209 | READ (external_ext, cbExtOffset, iextMax, swap->external_ext_size, PTR); | |
1210 | #undef READ | |
1211 | ||
1212 | debug->fdr = NULL; | |
1213 | debug->adjust = NULL; | |
1214 | ||
1215 | return true; | |
1216 | ||
1217 | error_return: | |
1218 | if (ext_hdr != NULL) | |
1219 | free (ext_hdr); | |
1220 | if (debug->line != NULL) | |
1221 | free (debug->line); | |
1222 | if (debug->external_dnr != NULL) | |
1223 | free (debug->external_dnr); | |
1224 | if (debug->external_pdr != NULL) | |
1225 | free (debug->external_pdr); | |
1226 | if (debug->external_sym != NULL) | |
1227 | free (debug->external_sym); | |
1228 | if (debug->external_opt != NULL) | |
1229 | free (debug->external_opt); | |
1230 | if (debug->external_aux != NULL) | |
1231 | free (debug->external_aux); | |
1232 | if (debug->ss != NULL) | |
1233 | free (debug->ss); | |
1234 | if (debug->ssext != NULL) | |
1235 | free (debug->ssext); | |
1236 | if (debug->external_fdr != NULL) | |
1237 | free (debug->external_fdr); | |
1238 | if (debug->external_rfd != NULL) | |
1239 | free (debug->external_rfd); | |
1240 | if (debug->external_ext != NULL) | |
1241 | free (debug->external_ext); | |
1242 | return false; | |
1243 | } | |
1244 | ||
1245 | /* Alpha ELF local labels start with '$'. */ | |
1246 | ||
1247 | static boolean | |
1248 | elf64_alpha_is_local_label (abfd, symbol) | |
1249 | bfd *abfd; | |
1250 | asymbol *symbol; | |
1251 | { | |
1252 | return symbol->name[0] == '$'; | |
1253 | } | |
1254 | ||
1255 | /* Alpha ELF follows MIPS ELF in using a special find_nearest_line | |
1256 | routine in order to handle the ECOFF debugging information. We | |
1257 | still call this mips_elf_find_line because of the slot | |
1258 | find_line_info in elf_obj_tdata is declared that way. */ | |
1259 | ||
1260 | struct mips_elf_find_line | |
1261 | { | |
1262 | struct ecoff_debug_info d; | |
1263 | struct ecoff_find_line i; | |
1264 | }; | |
1265 | ||
1266 | static boolean | |
1267 | elf64_alpha_find_nearest_line (abfd, section, symbols, offset, filename_ptr, | |
1268 | functionname_ptr, line_ptr) | |
1269 | bfd *abfd; | |
1270 | asection *section; | |
1271 | asymbol **symbols; | |
1272 | bfd_vma offset; | |
1273 | const char **filename_ptr; | |
1274 | const char **functionname_ptr; | |
1275 | unsigned int *line_ptr; | |
1276 | { | |
1277 | asection *msec; | |
1278 | ||
1279 | msec = bfd_get_section_by_name (abfd, ".mdebug"); | |
1280 | if (msec != NULL) | |
1281 | { | |
1282 | flagword origflags; | |
1283 | struct mips_elf_find_line *fi; | |
1284 | const struct ecoff_debug_swap * const swap = | |
1285 | get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap; | |
1286 | ||
1287 | /* If we are called during a link, alpha_elf_final_link may have | |
1288 | cleared the SEC_HAS_CONTENTS field. We force it back on here | |
1289 | if appropriate (which it normally will be). */ | |
1290 | origflags = msec->flags; | |
1291 | if (elf_section_data (msec)->this_hdr.sh_type != SHT_NOBITS) | |
1292 | msec->flags |= SEC_HAS_CONTENTS; | |
1293 | ||
1294 | fi = elf_tdata (abfd)->find_line_info; | |
1295 | if (fi == NULL) | |
1296 | { | |
1297 | bfd_size_type external_fdr_size; | |
1298 | char *fraw_src; | |
1299 | char *fraw_end; | |
1300 | struct fdr *fdr_ptr; | |
1301 | ||
1302 | fi = ((struct mips_elf_find_line *) | |
1303 | bfd_zalloc (abfd, sizeof (struct mips_elf_find_line))); | |
1304 | if (fi == NULL) | |
1305 | { | |
1306 | msec->flags = origflags; | |
1307 | return false; | |
1308 | } | |
1309 | ||
1310 | if (!elf64_alpha_read_ecoff_info (abfd, msec, &fi->d)) | |
1311 | { | |
1312 | msec->flags = origflags; | |
1313 | return false; | |
1314 | } | |
1315 | ||
1316 | /* Swap in the FDR information. */ | |
1317 | fi->d.fdr = ((struct fdr *) | |
1318 | bfd_alloc (abfd, | |
1319 | (fi->d.symbolic_header.ifdMax * | |
1320 | sizeof (struct fdr)))); | |
1321 | if (fi->d.fdr == NULL) | |
1322 | { | |
1323 | msec->flags = origflags; | |
1324 | return false; | |
1325 | } | |
1326 | external_fdr_size = swap->external_fdr_size; | |
1327 | fdr_ptr = fi->d.fdr; | |
1328 | fraw_src = (char *) fi->d.external_fdr; | |
1329 | fraw_end = (fraw_src | |
1330 | + fi->d.symbolic_header.ifdMax * external_fdr_size); | |
1331 | for (; fraw_src < fraw_end; fraw_src += external_fdr_size, fdr_ptr++) | |
1332 | (*swap->swap_fdr_in) (abfd, (PTR) fraw_src, fdr_ptr); | |
1333 | ||
1334 | elf_tdata (abfd)->find_line_info = fi; | |
1335 | ||
1336 | /* Note that we don't bother to ever free this information. | |
1337 | find_nearest_line is either called all the time, as in | |
1338 | objdump -l, so the information should be saved, or it is | |
1339 | rarely called, as in ld error messages, so the memory | |
1340 | wasted is unimportant. Still, it would probably be a | |
1341 | good idea for free_cached_info to throw it away. */ | |
1342 | } | |
1343 | ||
1344 | if (_bfd_ecoff_locate_line (abfd, section, offset, &fi->d, swap, | |
1345 | &fi->i, filename_ptr, functionname_ptr, | |
1346 | line_ptr)) | |
1347 | { | |
1348 | msec->flags = origflags; | |
1349 | return true; | |
1350 | } | |
1351 | ||
1352 | msec->flags = origflags; | |
1353 | } | |
1354 | ||
1355 | /* Fall back on the generic ELF find_nearest_line routine. */ | |
1356 | ||
1357 | return _bfd_elf_find_nearest_line (abfd, section, symbols, offset, | |
1358 | filename_ptr, functionname_ptr, | |
1359 | line_ptr); | |
1360 | } | |
1361 | \f | |
1362 | /* Structure used to pass information to alpha_elf_output_extsym. */ | |
1363 | ||
1364 | struct extsym_info | |
1365 | { | |
1366 | bfd *abfd; | |
1367 | struct bfd_link_info *info; | |
1368 | struct ecoff_debug_info *debug; | |
1369 | const struct ecoff_debug_swap *swap; | |
1370 | boolean failed; | |
1371 | }; | |
1372 | ||
1373 | static boolean | |
1374 | elf64_alpha_output_extsym (h, data) | |
1375 | struct alpha_elf_link_hash_entry *h; | |
1376 | PTR data; | |
1377 | { | |
1378 | struct extsym_info *einfo = (struct extsym_info *) data; | |
1379 | boolean strip; | |
1380 | asection *sec, *output_section; | |
1381 | ||
1382 | if (h->root.indx == -2) | |
1383 | strip = false; | |
1384 | else if (((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0 | |
1385 | || (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0) | |
1386 | && (h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0 | |
1387 | && (h->root.elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0) | |
1388 | strip = true; | |
1389 | else if (einfo->info->strip == strip_all | |
1390 | || (einfo->info->strip == strip_some | |
1391 | && bfd_hash_lookup (einfo->info->keep_hash, | |
1392 | h->root.root.root.string, | |
1393 | false, false) == NULL)) | |
1394 | strip = true; | |
1395 | else | |
1396 | strip = false; | |
1397 | ||
1398 | if (strip) | |
1399 | return true; | |
1400 | ||
1401 | if (h->esym.ifd == -2) | |
1402 | { | |
1403 | h->esym.jmptbl = 0; | |
1404 | h->esym.cobol_main = 0; | |
1405 | h->esym.weakext = 0; | |
1406 | h->esym.reserved = 0; | |
1407 | h->esym.ifd = ifdNil; | |
1408 | h->esym.asym.value = 0; | |
1409 | h->esym.asym.st = stGlobal; | |
1410 | ||
1411 | if (h->root.root.type != bfd_link_hash_defined | |
1412 | && h->root.root.type != bfd_link_hash_defweak) | |
1413 | h->esym.asym.sc = scAbs; | |
1414 | else | |
1415 | { | |
1416 | const char *name; | |
1417 | ||
1418 | sec = h->root.root.u.def.section; | |
1419 | output_section = sec->output_section; | |
1420 | ||
1421 | /* When making a shared library and symbol h is the one from | |
1422 | the another shared library, OUTPUT_SECTION may be null. */ | |
1423 | if (output_section == NULL) | |
1424 | h->esym.asym.sc = scUndefined; | |
1425 | else | |
1426 | { | |
1427 | name = bfd_section_name (output_section->owner, output_section); | |
1428 | ||
1429 | if (strcmp (name, ".text") == 0) | |
1430 | h->esym.asym.sc = scText; | |
1431 | else if (strcmp (name, ".data") == 0) | |
1432 | h->esym.asym.sc = scData; | |
1433 | else if (strcmp (name, ".sdata") == 0) | |
1434 | h->esym.asym.sc = scSData; | |
1435 | else if (strcmp (name, ".rodata") == 0 | |
1436 | || strcmp (name, ".rdata") == 0) | |
1437 | h->esym.asym.sc = scRData; | |
1438 | else if (strcmp (name, ".bss") == 0) | |
1439 | h->esym.asym.sc = scBss; | |
1440 | else if (strcmp (name, ".sbss") == 0) | |
1441 | h->esym.asym.sc = scSBss; | |
1442 | else if (strcmp (name, ".init") == 0) | |
1443 | h->esym.asym.sc = scInit; | |
1444 | else if (strcmp (name, ".fini") == 0) | |
1445 | h->esym.asym.sc = scFini; | |
1446 | else | |
1447 | h->esym.asym.sc = scAbs; | |
1448 | } | |
1449 | } | |
1450 | ||
1451 | h->esym.asym.reserved = 0; | |
1452 | h->esym.asym.index = indexNil; | |
1453 | } | |
1454 | ||
1455 | if (h->root.root.type == bfd_link_hash_common) | |
1456 | h->esym.asym.value = h->root.root.u.c.size; | |
1457 | else if (h->root.root.type == bfd_link_hash_defined | |
1458 | || h->root.root.type == bfd_link_hash_defweak) | |
1459 | { | |
1460 | if (h->esym.asym.sc == scCommon) | |
1461 | h->esym.asym.sc = scBss; | |
1462 | else if (h->esym.asym.sc == scSCommon) | |
1463 | h->esym.asym.sc = scSBss; | |
1464 | ||
1465 | sec = h->root.root.u.def.section; | |
1466 | output_section = sec->output_section; | |
1467 | if (output_section != NULL) | |
1468 | h->esym.asym.value = (h->root.root.u.def.value | |
1469 | + sec->output_offset | |
1470 | + output_section->vma); | |
1471 | else | |
1472 | h->esym.asym.value = 0; | |
1473 | } | |
1474 | else if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0) | |
1475 | { | |
1476 | /* Set type and value for a symbol with a function stub. */ | |
1477 | h->esym.asym.st = stProc; | |
1478 | sec = h->root.root.u.def.section; | |
1479 | if (sec == NULL) | |
1480 | h->esym.asym.value = 0; | |
1481 | else | |
1482 | { | |
1483 | output_section = sec->output_section; | |
1484 | if (output_section != NULL) | |
1485 | h->esym.asym.value = (h->root.plt_offset | |
1486 | + sec->output_offset | |
1487 | + output_section->vma); | |
1488 | else | |
1489 | h->esym.asym.value = 0; | |
1490 | } | |
1491 | #if 0 /* FIXME? */ | |
1492 | h->esym.ifd = 0; | |
1493 | #endif | |
1494 | } | |
1495 | ||
1496 | if (! bfd_ecoff_debug_one_external (einfo->abfd, einfo->debug, einfo->swap, | |
1497 | h->root.root.root.string, | |
1498 | &h->esym)) | |
1499 | { | |
1500 | einfo->failed = true; | |
1501 | return false; | |
1502 | } | |
1503 | ||
1504 | return true; | |
1505 | } | |
1506 | ||
1507 | /* FIXME: Create a runtime procedure table from the .mdebug section. | |
1508 | ||
1509 | static boolean | |
1510 | mips_elf_create_procedure_table (handle, abfd, info, s, debug) | |
1511 | PTR handle; | |
1512 | bfd *abfd; | |
1513 | struct bfd_link_info *info; | |
1514 | asection *s; | |
1515 | struct ecoff_debug_info *debug; | |
1516 | */ | |
1517 | ||
1518 | \f | |
1519 | static boolean | |
1520 | elf64_alpha_check_relocs (abfd, info, sec, relocs) | |
1521 | bfd *abfd; | |
1522 | struct bfd_link_info *info; | |
1523 | asection *sec; | |
1524 | const Elf_Internal_Rela *relocs; | |
1525 | { | |
1526 | bfd *dynobj; | |
1527 | asection *sgot; | |
1528 | asection *srelgot; | |
1529 | asection *sreloc; | |
1530 | Elf_Internal_Shdr *symtab_hdr; | |
1531 | struct elf_link_hash_entry **sym_hashes; | |
1532 | const Elf_Internal_Rela *rel, *relend; | |
1533 | ||
1534 | if (info->relocateable) | |
1535 | return true; | |
1536 | ||
1537 | sgot = srelgot = sreloc = NULL; | |
1538 | symtab_hdr = &elf_tdata(abfd)->symtab_hdr; | |
1539 | sym_hashes = elf_sym_hashes(abfd); | |
1540 | dynobj = elf_hash_table(info)->dynobj; | |
1541 | if (dynobj) | |
1542 | { | |
1543 | sgot = bfd_get_section_by_name(dynobj, ".got"); | |
1544 | srelgot = bfd_get_section_by_name(dynobj, ".rela.got"); | |
1545 | } | |
1546 | ||
1547 | relend = relocs + sec->reloc_count; | |
1548 | for (rel = relocs; rel < relend; ++rel) | |
1549 | { | |
1550 | unsigned long r_symndx; | |
1551 | struct elf_link_hash_entry *h; | |
1552 | ||
1553 | r_symndx = ELF64_R_SYM(rel->r_info); | |
1554 | if (r_symndx < symtab_hdr->sh_info) | |
1555 | h = NULL; | |
1556 | else | |
1557 | h = sym_hashes[r_symndx - symtab_hdr->sh_info]; | |
1558 | ||
1559 | switch (ELF64_R_TYPE(rel->r_info)) | |
1560 | { | |
1561 | case R_ALPHA_LITERAL: | |
1562 | /* If this is a load of a function symbol and we are building a | |
1563 | shared library or calling a shared library, then we need a | |
1564 | .plt entry as well. | |
1565 | ||
1566 | We can tell if it is a function either by noticing the | |
1567 | type of the symbol, or, if the type is undefined, by | |
1568 | noticing that we have a LITUSE(3) reloc next. | |
1569 | ||
1570 | Note that it is not fatal to be wrong guessing that a symbol | |
1571 | is an object, but it is fatal to be wrong guessing that a | |
1572 | symbol is a function. | |
1573 | ||
1574 | Furthermore, the .plt trampoline cannot abide by weak | |
1575 | symbols that turn out to be undefined. */ | |
1576 | ||
1577 | if (h | |
1578 | && h->root.type != bfd_link_hash_undefweak | |
1579 | && (info->shared | |
1580 | || !(h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)) | |
1581 | && (h->type == STT_FUNC | |
1582 | || (h->type == STT_NOTYPE | |
1583 | && rel+1 < relend | |
1584 | && ELF64_R_TYPE(rel[1].r_info) == R_ALPHA_LITUSE | |
1585 | && rel[1].r_addend == 3))) | |
1586 | { | |
1587 | h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; | |
1588 | } | |
1589 | ||
1590 | if (dynobj == NULL) | |
1591 | { | |
1592 | elf_hash_table(info)->dynobj = dynobj = abfd; | |
1593 | ||
1594 | /* Create the .got section. */ | |
1595 | if (!elf64_alpha_create_got_section(dynobj, info)) | |
1596 | return false; | |
1597 | ||
1598 | sgot = bfd_get_section_by_name(dynobj, ".got"); | |
1599 | srelgot = bfd_get_section_by_name(dynobj, ".rela.got"); | |
1600 | } | |
1601 | ||
1602 | if (h != NULL) | |
1603 | { | |
1604 | if (h->got_offset != MINUS_ONE) | |
1605 | { | |
1606 | /* We have already allocated space in this .got. */ | |
1607 | break; | |
1608 | } | |
1609 | ||
1610 | /* Make sure this becomes a dynamic symbol. */ | |
1611 | if (h->dynindx == -1 | |
1612 | && !_bfd_elf_link_record_dynamic_symbol(info, h)) | |
1613 | return false; | |
1614 | ||
1615 | /* Reserve space for a reloc even if we won't use it. */ | |
1616 | srelgot->_raw_size += sizeof(Elf64_External_Rela); | |
1617 | ||
1618 | /* Create the relocation in adjust_dynamic_symbol */ | |
1619 | ||
1620 | h->got_offset = sgot->_raw_size; | |
1621 | sgot->_raw_size += 8; | |
1622 | } | |
1623 | else | |
1624 | { | |
1625 | bfd_vma *lgotoff = elf_local_got_offsets(abfd); | |
1626 | if (lgotoff == NULL) | |
1627 | { | |
1628 | size_t size; | |
1629 | ||
1630 | size = elf_tdata(abfd)->symtab_hdr.sh_info * sizeof(bfd_vma); | |
1631 | lgotoff = (bfd_vma *)bfd_alloc(abfd, size); | |
1632 | if (lgotoff == NULL) | |
1633 | return false; | |
1634 | ||
1635 | elf_local_got_offsets(abfd) = lgotoff; | |
1636 | memset(lgotoff, -1, size); | |
1637 | } | |
1638 | ||
1639 | if (lgotoff[ELF64_R_SYM(rel->r_info)] != MINUS_ONE) | |
1640 | { | |
1641 | /* We have already allocated space in the .got. */ | |
1642 | break; | |
1643 | } | |
1644 | lgotoff[ELF64_R_SYM(rel->r_info)] = sgot->_raw_size; | |
1645 | sgot->_raw_size += 8; | |
1646 | ||
1647 | if (info->shared) | |
1648 | { | |
1649 | /* If we are generating a shared object, we need to | |
1650 | output a R_ALPHA_RELATIVE reloc so that the dynamic | |
1651 | linker can adjust this GOT entry. */ | |
1652 | srelgot->_raw_size += sizeof(Elf64_External_Rela); | |
1653 | } | |
1654 | } | |
1655 | break; | |
1656 | ||
1657 | case R_ALPHA_SREL16: | |
1658 | case R_ALPHA_SREL32: | |
1659 | case R_ALPHA_SREL64: | |
1660 | if (h == NULL) | |
1661 | break; | |
1662 | /* FALLTHRU */ | |
1663 | ||
1664 | case R_ALPHA_REFLONG: | |
1665 | case R_ALPHA_REFQUAD: | |
1666 | if (info->shared | |
1667 | || (h && !(h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))) | |
1668 | { | |
1669 | /* When creating a shared object or referring to a symbol in | |
1670 | a shared object, we must copy these relocs into the | |
1671 | object file. We create a reloc section in dynobj and | |
1672 | make room for the reloc. */ | |
1673 | if (sreloc == NULL) | |
1674 | { | |
1675 | const char *name; | |
1676 | name = (bfd_elf_string_from_elf_section | |
1677 | (abfd, elf_elfheader(abfd)->e_shstrndx, | |
1678 | elf_section_data(sec)->rel_hdr.sh_name)); | |
1679 | if (name == NULL) | |
1680 | return false; | |
1681 | ||
1682 | BFD_ASSERT(strncmp(name, ".rela", 5) == 0 | |
1683 | && strcmp(bfd_get_section_name(abfd, sec), | |
1684 | name+5) == 0); | |
1685 | ||
1686 | sreloc = bfd_get_section_by_name(dynobj, name); | |
1687 | if (sreloc == NULL) | |
1688 | { | |
1689 | sreloc = bfd_make_section(dynobj, name); | |
1690 | if (sreloc == NULL | |
1691 | || !bfd_set_section_flags(dynobj, sreloc, | |
1692 | (SEC_ALLOC|SEC_LOAD | |
1693 | |SEC_HAS_CONTENTS | |
1694 | |SEC_IN_MEMORY | |
1695 | |SEC_READONLY)) | |
1696 | || !bfd_set_section_alignment(dynobj, sreloc, 3)) | |
1697 | return false; | |
1698 | } | |
1699 | } | |
1700 | sreloc->_raw_size += sizeof(Elf64_External_Rela); | |
1701 | } | |
1702 | break; | |
1703 | } | |
1704 | } | |
1705 | ||
1706 | return true; | |
1707 | } | |
1708 | ||
1709 | /* Adjust a symbol defined by a dynamic object and referenced by a | |
1710 | regular object. The current definition is in some section of the | |
1711 | dynamic object, but we're not including those sections. We have to | |
1712 | change the definition to something the rest of the link can | |
1713 | understand. */ | |
1714 | ||
1715 | static boolean | |
1716 | elf64_alpha_adjust_dynamic_symbol (info, h) | |
1717 | struct bfd_link_info *info; | |
1718 | struct elf_link_hash_entry *h; | |
1719 | { | |
1720 | bfd *dynobj; | |
1721 | asection *s; | |
1722 | ||
1723 | dynobj = elf_hash_table(info)->dynobj; | |
1724 | ||
1725 | /* If this is a function, put it in the procedure linkage table. We | |
1726 | will fill in the contents of the procedure linkage table later, | |
1727 | though we could actually do it here. */ | |
1728 | ||
1729 | if (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) | |
1730 | { | |
1731 | /* We hadn't seen all of the input symbols when we guessed that we | |
1732 | needed a .plt entry. Revise our decision. */ | |
1733 | if (!info->shared | |
1734 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)) | |
1735 | { | |
1736 | h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; | |
1737 | return true; | |
1738 | } | |
1739 | ||
1740 | s = bfd_get_section_by_name(dynobj, ".plt"); | |
1741 | BFD_ASSERT(s != NULL); | |
1742 | ||
1743 | /* The first bit of the .plt is reserved. */ | |
1744 | if (s->_raw_size == 0) | |
1745 | s->_raw_size = PLT_HEADER_SIZE; | |
1746 | ||
1747 | h->plt_offset = s->_raw_size; | |
1748 | ||
1749 | /* If this symbol is not defined in a regular file, and we are not | |
1750 | generating a shared library, then set the symbol to the location | |
1751 | in the .plt. This is required to make function pointers compare | |
1752 | equal between the normal executable and the shared library. */ | |
1753 | if (!info->shared) | |
1754 | { | |
1755 | h->root.u.def.section = s; | |
1756 | h->root.u.def.value = s->_raw_size; | |
1757 | } | |
1758 | ||
1759 | s->_raw_size += PLT_ENTRY_SIZE; | |
1760 | ||
1761 | /* We also need an entry in the .rela.plt section. */ | |
1762 | s = bfd_get_section_by_name(dynobj, ".rela.plt"); | |
1763 | BFD_ASSERT(s != NULL); | |
1764 | s->_raw_size += sizeof(Elf64_External_Rela); | |
1765 | ||
1766 | return true; | |
1767 | } | |
1768 | ||
1769 | /* If this is a weak symbol, and there is a real definition, the | |
1770 | processor independent code will have arranged for us to see the | |
1771 | real definition first, and we can just use the same value. */ | |
1772 | if (h->weakdef != NULL) | |
1773 | { | |
1774 | BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined | |
1775 | || h->weakdef->root.type == bfd_link_hash_defweak); | |
1776 | h->root.u.def.section = h->weakdef->root.u.def.section; | |
1777 | h->root.u.def.value = h->weakdef->root.u.def.value; | |
1778 | return true; | |
1779 | } | |
1780 | ||
1781 | /* This is a reference to a symbol defined by a dynamic object which | |
1782 | is not a function. The Alpha, since it uses .got entries for | |
1783 | symbols even in regular objects, does not need the hackery of a | |
1784 | .dynbss section and COPY dynamic relocations. */ | |
1785 | ||
1786 | return true; | |
1787 | } | |
1788 | ||
1789 | /* Set the sizes of the dynamic sections. */ | |
1790 | ||
1791 | static boolean | |
1792 | elf64_alpha_size_dynamic_sections (output_bfd, info) | |
1793 | bfd *output_bfd; | |
1794 | struct bfd_link_info *info; | |
1795 | { | |
1796 | bfd *dynobj; | |
1797 | asection *s; | |
1798 | boolean reltext; | |
1799 | boolean relplt; | |
1800 | ||
1801 | dynobj = elf_hash_table(info)->dynobj; | |
1802 | BFD_ASSERT(dynobj != NULL); | |
1803 | ||
1804 | if (elf_hash_table(info)->dynamic_sections_created) | |
1805 | { | |
1806 | /* Set the contents of the .interp section to the interpreter. */ | |
1807 | if (!info->shared) | |
1808 | { | |
1809 | s = bfd_get_section_by_name(dynobj, ".interp"); | |
1810 | BFD_ASSERT(s != NULL); | |
1811 | s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; | |
1812 | s->contents = (unsigned char *)ELF_DYNAMIC_INTERPRETER; | |
1813 | } | |
1814 | } | |
1815 | else | |
1816 | { | |
1817 | /* We may have created entries in the .rela.got section. | |
1818 | However, if we are not creating the dynamic sections, we will | |
1819 | not actually use these entries. Reset the size of .rel.got, | |
1820 | which will cause it to get stripped from the output file | |
1821 | below. */ | |
1822 | s = bfd_get_section_by_name (dynobj, ".rela.got"); | |
1823 | if (s != NULL) | |
1824 | s->_raw_size = 0; | |
1825 | } | |
1826 | ||
1827 | /* The check_relocs and adjust_dynamic_symbol entry points have | |
1828 | determined the sizes of the various dynamic sections. Allocate | |
1829 | memory for them. */ | |
1830 | reltext = false; | |
1831 | relplt = false; | |
1832 | for (s = dynobj->sections; s != NULL; s = s->next) | |
1833 | { | |
1834 | const char *name; | |
1835 | boolean strip; | |
1836 | ||
1837 | if (!(s->flags & SEC_IN_MEMORY)) | |
1838 | continue; | |
1839 | ||
1840 | /* It's OK to base decisions on the section name, because none | |
1841 | of the dynobj section names depend upon the input files. */ | |
1842 | name = bfd_get_section_name(dynobj, s); | |
1843 | ||
1844 | /* If we don't need this section, strip it from the output file. | |
1845 | This is to handle .rela.bss and .rela.plt. We must create it | |
1846 | in create_dynamic_sections, because it must be created before | |
1847 | the linker maps input sections to output sections. The | |
1848 | linker does that before adjust_dynamic_symbol is called, and | |
1849 | it is that function which decides whether anything needs to | |
1850 | go into these sections. */ | |
1851 | ||
1852 | strip = false; | |
1853 | ||
1854 | if (strncmp(name, ".rela", 5) == 0) | |
1855 | { | |
1856 | strip = (s->_raw_size == 0); | |
1857 | ||
1858 | if (!strip) | |
1859 | { | |
1860 | asection *target; | |
1861 | ||
1862 | /* If this relocation section applies to a read only | |
1863 | section, then we probably need a DT_TEXTREL entry. */ | |
1864 | target = bfd_get_section_by_name (output_bfd, name + 5); | |
1865 | if (target != NULL | |
1866 | && (target->flags & SEC_READONLY) != 0) | |
1867 | reltext = true; | |
1868 | ||
1869 | if (strcmp(name, ".rela.plt") == 0) | |
1870 | relplt = true; | |
1871 | ||
1872 | /* We use the reloc_count field as a counter if we need | |
1873 | to copy relocs into the output file. */ | |
1874 | s->reloc_count = 0; | |
1875 | } | |
1876 | } | |
1877 | else if (strcmp(name, ".got") == 0) | |
1878 | { | |
1879 | /* If we are generating a shared library, we generate a | |
1880 | section symbol for each output section. These are local | |
1881 | symbols, which means that they must come first in the | |
1882 | dynamic symbol table. That means we must increment the | |
1883 | dynamic symbol index of every other dynamic symbol. */ | |
1884 | if (info->shared) | |
1885 | { | |
1886 | long c[2], i; | |
1887 | asection *p; | |
1888 | ||
1889 | c[0] = 0; | |
1890 | c[1] = bfd_count_sections(output_bfd); | |
1891 | ||
1892 | elf_link_hash_traverse (elf_hash_table(info), | |
1893 | elf64_alpha_adjust_dynindx, | |
1894 | (PTR)c); | |
1895 | elf_hash_table (info)->dynsymcount += c[1]; | |
1896 | ||
1897 | for (i = 3, p = output_bfd->sections; | |
1898 | p != NULL; | |
1899 | p = p->next, i++) | |
1900 | { | |
1901 | elf_section_data (p)->dynindx = i; | |
1902 | /* These symbols will have no names, so we don't need to | |
1903 | fiddle with dynstr_index. */ | |
1904 | } | |
1905 | } | |
1906 | } | |
1907 | else if (strcmp (name, ".plt") != 0) | |
1908 | { | |
1909 | /* It's not one of our sections, so don't allocate space. */ | |
1910 | continue; | |
1911 | } | |
1912 | ||
1913 | if (strip) | |
1914 | { | |
1915 | asection **spp; | |
1916 | ||
1917 | for (spp = &s->output_section->owner->sections; | |
1918 | *spp != s->output_section; | |
1919 | spp = &(*spp)->next) | |
1920 | continue; | |
1921 | *spp = s->output_section->next; | |
1922 | --s->output_section->owner->section_count; | |
1923 | ||
1924 | continue; | |
1925 | } | |
1926 | ||
1927 | /* Allocate memory for the section contents. */ | |
1928 | s->contents = (bfd_byte *) bfd_zalloc(dynobj, s->_raw_size); | |
1929 | if (s->contents == NULL && s->_raw_size != 0) | |
1930 | return false; | |
1931 | } | |
1932 | ||
1933 | if (elf_hash_table (info)->dynamic_sections_created) | |
1934 | { | |
1935 | /* Add some entries to the .dynamic section. We fill in the | |
1936 | values later, in elf64_alpha_finish_dynamic_sections, but we | |
1937 | must add the entries now so that we get the correct size for | |
1938 | the .dynamic section. The DT_DEBUG entry is filled in by the | |
1939 | dynamic linker and used by the debugger. */ | |
1940 | if (!info->shared) | |
1941 | { | |
1942 | if (!bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0)) | |
1943 | return false; | |
1944 | } | |
1945 | ||
1946 | if (! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0)) | |
1947 | return false; | |
1948 | ||
1949 | if (relplt) | |
1950 | { | |
1951 | if (! bfd_elf64_add_dynamic_entry (info, DT_PLTRELSZ, 0) | |
1952 | || ! bfd_elf64_add_dynamic_entry (info, DT_PLTREL, DT_RELA) | |
1953 | || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0)) | |
1954 | return false; | |
1955 | } | |
1956 | ||
1957 | if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0) | |
1958 | || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0) | |
1959 | || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT, | |
1960 | sizeof(Elf64_External_Rela))) | |
1961 | return false; | |
1962 | ||
1963 | if (reltext) | |
1964 | { | |
1965 | if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0)) | |
1966 | return false; | |
1967 | } | |
1968 | } | |
1969 | ||
1970 | return true; | |
1971 | } | |
1972 | ||
1973 | /* Increment the index of a dynamic symbol by a given amount. Called | |
1974 | via elf_link_hash_traverse. */ | |
1975 | ||
1976 | static boolean | |
1977 | elf64_alpha_adjust_dynindx (h, cparg) | |
1978 | struct elf_link_hash_entry *h; | |
1979 | PTR cparg; | |
1980 | { | |
1981 | long *cp = (long *)cparg; | |
1982 | ||
1983 | if (h->dynindx >= cp[0]) | |
1984 | h->dynindx += cp[1]; | |
1985 | ||
1986 | return true; | |
1987 | } | |
1988 | ||
1989 | /* Relocate an Alpha ELF section. */ | |
1990 | ||
1991 | static boolean | |
1992 | elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, | |
1993 | contents, relocs, local_syms, local_sections) | |
1994 | bfd *output_bfd; | |
1995 | struct bfd_link_info *info; | |
1996 | bfd *input_bfd; | |
1997 | asection *input_section; | |
1998 | bfd_byte *contents; | |
1999 | Elf_Internal_Rela *relocs; | |
2000 | Elf_Internal_Sym *local_syms; | |
2001 | asection **local_sections; | |
2002 | { | |
2003 | Elf_Internal_Shdr *symtab_hdr; | |
2004 | Elf_Internal_Rela *rel; | |
2005 | Elf_Internal_Rela *relend; | |
2006 | asection *sec, *sgot, *splt; | |
2007 | bfd *dynobj; | |
2008 | bfd_vma gp; | |
2009 | ||
2010 | symtab_hdr = &elf_tdata(input_bfd)->symtab_hdr; | |
2011 | ||
2012 | /* Find the gp value for this input bfd. */ | |
2013 | sgot = NULL; | |
2014 | gp = 0; | |
2015 | dynobj = elf_hash_table(info)->dynobj; | |
2016 | if (dynobj) | |
2017 | { | |
2018 | sgot = bfd_get_section_by_name (dynobj, ".got"); | |
2019 | splt = bfd_get_section_by_name (dynobj, ".plt"); | |
2020 | ||
2021 | gp = _bfd_get_gp_value(dynobj); | |
2022 | if (gp == 0) | |
2023 | { | |
2024 | gp = (sgot->output_section->vma | |
2025 | + sgot->output_offset | |
2026 | + 0x8000); | |
2027 | _bfd_set_gp_value(dynobj, gp); | |
2028 | } | |
2029 | } | |
2030 | ||
2031 | rel = relocs; | |
2032 | relend = relocs + input_section->reloc_count; | |
2033 | for (; rel < relend; rel++) | |
2034 | { | |
2035 | int r_type; | |
2036 | reloc_howto_type *howto; | |
2037 | unsigned long r_symndx; | |
2038 | struct elf_link_hash_entry *h; | |
2039 | Elf_Internal_Sym *sym; | |
2040 | bfd_vma relocation; | |
2041 | bfd_vma addend; | |
2042 | bfd_reloc_status_type r; | |
2043 | ||
2044 | r_type = ELF64_R_TYPE(rel->r_info); | |
2045 | if (r_type < 0 || r_type >= (int) R_ALPHA_max) | |
2046 | { | |
2047 | bfd_set_error (bfd_error_bad_value); | |
2048 | return false; | |
2049 | } | |
2050 | howto = elf64_alpha_howto_table + r_type; | |
2051 | ||
2052 | r_symndx = ELF64_R_SYM(rel->r_info); | |
2053 | ||
2054 | if (info->relocateable) | |
2055 | { | |
2056 | /* This is a relocateable link. We don't have to change | |
2057 | anything, unless the reloc is against a section symbol, | |
2058 | in which case we have to adjust according to where the | |
2059 | section symbol winds up in the output section. */ | |
2060 | if (r_symndx < symtab_hdr->sh_info) | |
2061 | { | |
2062 | sym = local_syms + r_symndx; | |
2063 | if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) | |
2064 | { | |
2065 | sec = local_sections[r_symndx]; | |
2066 | rel->r_addend += sec->output_offset + sym->st_value; | |
2067 | } | |
2068 | } | |
2069 | ||
2070 | continue; | |
2071 | } | |
2072 | ||
2073 | /* This is a final link. */ | |
2074 | ||
2075 | h = NULL; | |
2076 | sym = NULL; | |
2077 | sec = NULL; | |
2078 | ||
2079 | if (r_symndx < symtab_hdr->sh_info) | |
2080 | { | |
2081 | sym = local_syms + r_symndx; | |
2082 | sec = local_sections[r_symndx]; | |
2083 | relocation = (sec->output_section->vma | |
2084 | + sec->output_offset | |
2085 | + sym->st_value); | |
2086 | } | |
2087 | else | |
2088 | { | |
2089 | h = elf_sym_hashes(input_bfd)[r_symndx - symtab_hdr->sh_info]; | |
2090 | ||
2091 | while (h->root.type == bfd_link_hash_indirect | |
2092 | || h->root.type == bfd_link_hash_warning) | |
2093 | h = (struct elf_link_hash_entry *)h->root.u.i.link; | |
2094 | ||
2095 | if (h->root.type == bfd_link_hash_defined | |
2096 | || h->root.type == bfd_link_hash_defweak) | |
2097 | { | |
2098 | sec = h->root.u.def.section; | |
2099 | ||
2100 | /* If the symbol was defined as a common symbol in a | |
2101 | regular object file, and there was no definition in | |
2102 | any dynamic object, then the linker will have | |
2103 | allocated space for the symbol in a common section | |
2104 | but the ELF_LINK_HASH_DEF_REGULAR flag will not have | |
2105 | been set. This is done for dynamic symbols in | |
2106 | elf_adjust_dynamic_symbol but this is not done for | |
2107 | non-dynamic symbols, somehow. */ | |
2108 | if ((h->elf_link_hash_flags | |
2109 | & (ELF_LINK_HASH_DEF_REGULAR | |
2110 | | ELF_LINK_HASH_REF_REGULAR | |
2111 | | ELF_LINK_HASH_DEF_DYNAMIC)) | |
2112 | == ELF_LINK_HASH_REF_REGULAR | |
2113 | && !(sec->owner->flags & DYNAMIC)) | |
2114 | h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; | |
2115 | ||
2116 | #if rth_notdef | |
2117 | if ((r_type == R_ALPHA_LITERAL | |
2118 | && elf_hash_table(info)->dynamic_sections_created | |
2119 | && (!info->shared | |
2120 | || !info->symbolic | |
2121 | || !(h->elf_link_hash_flags | |
2122 | & ELF_LINK_HASH_DEF_REGULAR))) | |
2123 | || (info->shared | |
2124 | && (!info->symbolic | |
2125 | || !(h->elf_link_hash_flags | |
2126 | & ELF_LINK_HASH_DEF_REGULAR)) | |
2127 | && (input_section->flags & SEC_ALLOC) | |
2128 | && (r_type == R_ALPHA_REFLONG | |
2129 | || r_type == R_ALPHA_REFQUAD | |
2130 | || r_type == R_ALPHA_LITERAL))) | |
2131 | { | |
2132 | /* In these cases, we don't need the relocation value. | |
2133 | We check specially because in some obscure cases | |
2134 | sec->output_section will be NULL. */ | |
2135 | relocation = 0; | |
2136 | } | |
2137 | #else | |
2138 | /* FIXME: Are not these obscure cases simply bugs? Let's | |
2139 | get something working and come back to this. */ | |
2140 | if (sec->output_section == NULL) | |
2141 | relocation = 0; | |
2142 | #endif /* rth_notdef */ | |
2143 | else | |
2144 | { | |
2145 | relocation = (h->root.u.def.value | |
2146 | + sec->output_section->vma | |
2147 | + sec->output_offset); | |
2148 | } | |
2149 | } | |
2150 | else if (h->root.type == bfd_link_hash_undefweak) | |
2151 | relocation = 0; | |
2152 | else if (info->shared && !info->symbolic) | |
2153 | relocation = 0; | |
2154 | else | |
2155 | { | |
2156 | if (!((*info->callbacks->undefined_symbol) | |
2157 | (info, h->root.root.string, input_bfd, | |
2158 | input_section, rel->r_offset))) | |
2159 | return false; | |
2160 | relocation = 0; | |
2161 | } | |
2162 | } | |
2163 | addend = rel->r_addend; | |
2164 | ||
2165 | switch (r_type) | |
2166 | { | |
2167 | case R_ALPHA_GPDISP: | |
2168 | { | |
2169 | bfd_byte *p_ldah, *p_lda; | |
2170 | ||
2171 | relocation = (input_section->output_section->vma | |
2172 | + input_section->output_offset | |
2173 | + rel->r_offset); | |
2174 | ||
2175 | p_ldah = contents + rel->r_offset - input_section->vma; | |
2176 | p_lda = p_ldah + rel->r_addend; | |
2177 | ||
2178 | r = elf64_alpha_do_reloc_gpdisp (input_bfd, gp - relocation, | |
2179 | p_ldah, p_lda); | |
2180 | } | |
2181 | break; | |
2182 | ||
2183 | case R_ALPHA_OP_PUSH: | |
2184 | case R_ALPHA_OP_STORE: | |
2185 | case R_ALPHA_OP_PSUB: | |
2186 | case R_ALPHA_OP_PRSHIFT: | |
2187 | /* FIXME */ | |
2188 | abort(); | |
2189 | ||
2190 | case R_ALPHA_LITERAL: | |
2191 | { | |
2192 | bfd_vma gotoff; | |
2193 | ||
2194 | BFD_ASSERT(gp != 0); | |
2195 | BFD_ASSERT(sgot != NULL); | |
2196 | if (h != NULL) | |
2197 | { | |
2198 | gotoff = h->got_offset; | |
2199 | } | |
2200 | else | |
2201 | { | |
2202 | gotoff = elf_local_got_offsets (input_bfd)[r_symndx]; | |
2203 | ||
2204 | /* Use the lsb as a flag indicating that we've already | |
2205 | output the relocation entry. */ | |
2206 | if (info->shared) | |
2207 | if (gotoff & 1) | |
2208 | gotoff &= ~(bfd_vma)1; | |
2209 | else | |
2210 | { | |
2211 | asection *srel; | |
2212 | Elf_Internal_Rela outrel; | |
2213 | ||
2214 | srel = bfd_get_section_by_name (dynobj, ".rela.got"); | |
2215 | BFD_ASSERT(srel != NULL); | |
2216 | ||
2217 | outrel.r_offset = (sgot->output_section->vma | |
2218 | + sgot->output_offset + gotoff); | |
2219 | outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE); | |
2220 | outrel.r_addend = 0; | |
2221 | ||
2222 | bfd_elf64_swap_reloca_out (output_bfd, &outrel, | |
2223 | ((Elf64_External_Rela *) | |
2224 | srel->contents) | |
2225 | + srel->reloc_count++); | |
2226 | ||
2227 | elf_local_got_offsets (input_bfd)[r_symndx] |= 1; | |
2228 | } | |
2229 | } | |
2230 | ||
2231 | /* Initialize the .got entry. */ | |
2232 | bfd_put_64 (output_bfd, relocation, sgot->contents + gotoff); | |
2233 | ||
2234 | /* Figure the gprel relocation. */ | |
2235 | addend = 0; | |
2236 | relocation = (sgot->output_section->vma | |
2237 | + sgot->output_offset | |
2238 | + gotoff); | |
2239 | relocation -= gp; | |
2240 | } | |
2241 | /* overflow handled by _bfd_final_link_relocate */ | |
2242 | goto default_reloc; | |
2243 | ||
2244 | case R_ALPHA_GPREL32: | |
2245 | BFD_ASSERT(gp != 0); | |
2246 | relocation -= gp; | |
2247 | goto default_reloc; | |
2248 | ||
2249 | case R_ALPHA_BRADDR: | |
2250 | case R_ALPHA_HINT: | |
2251 | /* The regular PC-relative stuff measures from the start of | |
2252 | the instruction rather than the end. */ | |
2253 | addend -= 4; | |
2254 | goto default_reloc; | |
2255 | ||
2256 | case R_ALPHA_REFLONG: | |
2257 | case R_ALPHA_REFQUAD: | |
2258 | if (info->shared | |
2259 | || (h && !(h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))) | |
2260 | { | |
2261 | asection *srel; | |
2262 | const char *name; | |
2263 | Elf_Internal_Rela outrel; | |
2264 | ||
2265 | name = (bfd_elf_string_from_elf_section | |
2266 | (input_bfd, elf_elfheader(input_bfd)->e_shstrndx, | |
2267 | elf_section_data(input_section)->rel_hdr.sh_name)); | |
2268 | BFD_ASSERT(name != NULL); | |
2269 | ||
2270 | srel = bfd_get_section_by_name(dynobj, name); | |
2271 | BFD_ASSERT(srel != NULL); | |
2272 | ||
2273 | outrel.r_offset = (input_section->output_section->vma | |
2274 | + input_section->output_offset | |
2275 | + rel->r_offset); | |
2276 | outrel.r_addend = 0; | |
2277 | if (h) | |
2278 | { | |
2279 | BFD_ASSERT(h->dynindx != -1); | |
2280 | outrel.r_info = ELF64_R_INFO(h->dynindx, r_type); | |
2281 | relocation = 0; | |
2282 | } | |
2283 | else | |
2284 | { | |
2285 | outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE); | |
2286 | } | |
2287 | ||
2288 | bfd_elf64_swap_reloca_out (output_bfd, &outrel, | |
2289 | ((Elf64_External_Rela *) | |
2290 | srel->contents) | |
2291 | + srel->reloc_count++); | |
2292 | } | |
2293 | goto default_reloc; | |
2294 | ||
2295 | default: | |
2296 | default_reloc: | |
2297 | r = _bfd_final_link_relocate (howto, input_bfd, input_section, | |
2298 | contents, rel->r_offset, relocation, | |
2299 | addend); | |
2300 | break; | |
2301 | } | |
2302 | ||
2303 | switch (r) | |
2304 | { | |
2305 | case bfd_reloc_ok: | |
2306 | break; | |
2307 | ||
2308 | case bfd_reloc_overflow: | |
2309 | { | |
2310 | const char *name; | |
2311 | ||
2312 | if (h != NULL) | |
2313 | name = h->root.root.string; | |
2314 | else | |
2315 | { | |
2316 | name = (bfd_elf_string_from_elf_section | |
2317 | (input_bfd, symtab_hdr->sh_link, sym->st_name)); | |
2318 | if (name == NULL) | |
2319 | return false; | |
2320 | if (*name == '\0') | |
2321 | name = bfd_section_name (input_bfd, sec); | |
2322 | } | |
2323 | if (! ((*info->callbacks->reloc_overflow) | |
2324 | (info, name, howto->name, (bfd_vma) 0, | |
2325 | input_bfd, input_section, rel->r_offset))) | |
2326 | return false; | |
2327 | } | |
2328 | break; | |
2329 | ||
2330 | default: | |
2331 | case bfd_reloc_outofrange: | |
2332 | abort (); | |
2333 | } | |
2334 | } | |
2335 | ||
2336 | return true; | |
2337 | } | |
2338 | ||
2339 | /* Finish up dynamic symbol handling. We set the contents of various | |
2340 | dynamic sections here. */ | |
2341 | ||
2342 | static boolean | |
2343 | elf64_alpha_finish_dynamic_symbol (output_bfd, info, h, sym) | |
2344 | bfd *output_bfd; | |
2345 | struct bfd_link_info *info; | |
2346 | struct elf_link_hash_entry *h; | |
2347 | Elf_Internal_Sym *sym; | |
2348 | { | |
2349 | bfd *dynobj = elf_hash_table(info)->dynobj; | |
2350 | ||
2351 | if (h->plt_offset != MINUS_ONE) | |
2352 | { | |
2353 | asection *splt, *sgot, *srel; | |
2354 | Elf_Internal_Rela outrel; | |
2355 | bfd_vma got_addr, plt_addr; | |
2356 | bfd_vma plt_index; | |
2357 | ||
2358 | /* This symbol has an entry in the procedure linkage table. */ | |
2359 | ||
2360 | BFD_ASSERT(h->dynindx != -1); | |
2361 | BFD_ASSERT(h->got_offset != MINUS_ONE); | |
2362 | ||
2363 | splt = bfd_get_section_by_name(dynobj, ".plt"); | |
2364 | BFD_ASSERT(splt != NULL); | |
2365 | srel = bfd_get_section_by_name(dynobj, ".rela.plt"); | |
2366 | BFD_ASSERT(srel != NULL); | |
2367 | sgot = bfd_get_section_by_name(dynobj, ".got"); | |
2368 | BFD_ASSERT(sgot != NULL); | |
2369 | ||
2370 | got_addr = (sgot->output_section->vma | |
2371 | + sgot->output_offset | |
2372 | + h->got_offset); | |
2373 | plt_addr = (splt->output_section->vma | |
2374 | + splt->output_offset | |
2375 | + h->plt_offset); | |
2376 | ||
2377 | plt_index = (h->plt_offset - PLT_HEADER_SIZE) / PLT_ENTRY_SIZE; | |
2378 | ||
2379 | /* Fill in the entry in the procedure linkage table. */ | |
2380 | { | |
2381 | unsigned insn1, insn2, insn3; | |
2382 | long hi, lo; | |
2383 | ||
2384 | /* decompose the reloc offset for the plt for ldah+lda */ | |
2385 | hi = plt_index * sizeof(Elf64_External_Rela); | |
2386 | lo = ((hi & 0xffff) ^ 0x8000) - 0x8000; | |
2387 | hi = (hi - lo) >> 16; | |
2388 | ||
2389 | insn1 = PLT_ENTRY_WORD1 | (hi & 0xffff); | |
2390 | insn2 = PLT_ENTRY_WORD2 | (lo & 0xffff); | |
2391 | insn3 = PLT_ENTRY_WORD3 | ((-(h->plt_offset + 12) >> 2) & 0x1fffff); | |
2392 | ||
2393 | bfd_put_32 (output_bfd, insn1, splt->contents + h->plt_offset); | |
2394 | bfd_put_32 (output_bfd, insn2, splt->contents + h->plt_offset + 4); | |
2395 | bfd_put_32 (output_bfd, insn3, splt->contents + h->plt_offset + 8); | |
2396 | } | |
2397 | ||
2398 | /* Fill in the entry in the .rela.plt section. */ | |
2399 | outrel.r_offset = got_addr; | |
2400 | outrel.r_info = ELF64_R_INFO(h->dynindx, R_ALPHA_JMP_SLOT); | |
2401 | outrel.r_addend = 0; | |
2402 | ||
2403 | bfd_elf64_swap_reloca_out (output_bfd, &outrel, | |
2404 | ((Elf64_External_Rela *)srel->contents | |
2405 | + plt_index)); | |
2406 | ||
2407 | if (!(h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)) | |
2408 | { | |
2409 | /* Mark the symbol as undefined, rather than as defined in the | |
2410 | .plt section. Leave the value alone. */ | |
2411 | sym->st_shndx = SHN_UNDEF; | |
2412 | } | |
2413 | ||
2414 | /* Fill in the entry in the global offset table. */ | |
2415 | bfd_put_64 (output_bfd, plt_addr, sgot->contents + h->got_offset); | |
2416 | } | |
2417 | else if (h->got_offset != MINUS_ONE) | |
2418 | { | |
2419 | asection *sgot, *srel; | |
2420 | Elf_Internal_Rela outrel; | |
2421 | ||
2422 | BFD_ASSERT(h->dynindx != -1); | |
2423 | ||
2424 | sgot = bfd_get_section_by_name (dynobj, ".got"); | |
2425 | BFD_ASSERT (sgot != NULL); | |
2426 | srel = bfd_get_section_by_name (dynobj, ".rela.got"); | |
2427 | BFD_ASSERT (srel != NULL); | |
2428 | ||
2429 | outrel.r_offset = (sgot->output_section->vma | |
2430 | + sgot->output_offset | |
2431 | + h->got_offset); | |
2432 | outrel.r_addend = 0; | |
2433 | if (info->shared | |
2434 | && info->symbolic | |
2435 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)) | |
2436 | outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE); | |
2437 | else | |
2438 | { | |
2439 | bfd_put_64(output_bfd, (bfd_vma)0, sgot->contents + h->got_offset); | |
2440 | outrel.r_info = ELF64_R_INFO(h->dynindx, R_ALPHA_GLOB_DAT); | |
2441 | } | |
2442 | ||
2443 | bfd_elf64_swap_reloca_out (output_bfd, &outrel, | |
2444 | ((Elf64_External_Rela *)srel->contents | |
2445 | + srel->reloc_count++)); | |
2446 | } | |
2447 | ||
2448 | /* Mark some specially defined symbols as absolute. */ | |
2449 | if (strcmp (h->root.root.string, "_DYNAMIC") == 0 | |
2450 | || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0 | |
2451 | || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0) | |
2452 | sym->st_shndx = SHN_ABS; | |
2453 | ||
2454 | return true; | |
2455 | } | |
2456 | ||
2457 | /* Finish up the dynamic sections. */ | |
2458 | ||
2459 | static boolean | |
2460 | elf64_alpha_finish_dynamic_sections (output_bfd, info) | |
2461 | bfd *output_bfd; | |
2462 | struct bfd_link_info *info; | |
2463 | { | |
2464 | bfd *dynobj; | |
2465 | asection *sdyn; | |
2466 | asection *sgot; | |
2467 | ||
2468 | dynobj = elf_hash_table (info)->dynobj; | |
2469 | sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); | |
2470 | ||
2471 | if (elf_hash_table (info)->dynamic_sections_created) | |
2472 | { | |
2473 | asection *splt; | |
2474 | Elf64_External_Dyn *dyncon, *dynconend; | |
2475 | ||
2476 | splt = bfd_get_section_by_name (dynobj, ".plt"); | |
2477 | BFD_ASSERT (splt != NULL && sdyn != NULL); | |
2478 | ||
2479 | dyncon = (Elf64_External_Dyn *) sdyn->contents; | |
2480 | dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size); | |
2481 | for (; dyncon < dynconend; dyncon++) | |
2482 | { | |
2483 | Elf_Internal_Dyn dyn; | |
2484 | const char *name; | |
2485 | asection *s; | |
2486 | ||
2487 | bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn); | |
2488 | ||
2489 | switch (dyn.d_tag) | |
2490 | { | |
2491 | case DT_PLTGOT: | |
2492 | name = ".plt"; | |
2493 | goto get_vma; | |
2494 | case DT_PLTRELSZ: | |
2495 | name = ".rela.plt"; | |
2496 | goto get_size; | |
2497 | case DT_JMPREL: | |
2498 | name = ".rela.plt"; | |
2499 | goto get_vma; | |
2500 | ||
2501 | case DT_RELASZ: | |
2502 | /* My interpretation of the TIS v1.1 ELF document indicates | |
2503 | that RELASZ should not include JMPREL. This is not what | |
2504 | the rest of the BFD does. It is, however, what the | |
2505 | glibc ld.so wants. Do this fixup here until we found | |
2506 | out who is right. */ | |
2507 | s = bfd_get_section_by_name (output_bfd, ".rela.plt"); | |
2508 | if (s) | |
2509 | { | |
2510 | dyn.d_un.d_val -= | |
2511 | (s->_cooked_size ? s->_cooked_size : s->_raw_size); | |
2512 | } | |
2513 | break; | |
2514 | ||
2515 | get_vma: | |
2516 | s = bfd_get_section_by_name (output_bfd, name); | |
2517 | dyn.d_un.d_ptr = (s ? s->vma : 0); | |
2518 | break; | |
2519 | ||
2520 | get_size: | |
2521 | s = bfd_get_section_by_name (output_bfd, name); | |
2522 | dyn.d_un.d_val = | |
2523 | (s->_cooked_size ? s->_cooked_size : s->_raw_size); | |
2524 | break; | |
2525 | } | |
2526 | ||
2527 | bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); | |
2528 | } | |
2529 | ||
2530 | /* Initialize the PLT0 entry */ | |
2531 | if (splt->_raw_size > 0) | |
2532 | { | |
2533 | bfd_put_32 (output_bfd, PLT_HEADER_WORD1, splt->contents); | |
2534 | bfd_put_32 (output_bfd, PLT_HEADER_WORD2, splt->contents + 4); | |
2535 | bfd_put_32 (output_bfd, PLT_HEADER_WORD3, splt->contents + 8); | |
2536 | bfd_put_32 (output_bfd, PLT_HEADER_WORD4, splt->contents + 12); | |
2537 | ||
2538 | /* The next two words will be filled in by ld.so */ | |
2539 | bfd_put_64 (output_bfd, 0, splt->contents + 16); | |
2540 | bfd_put_64 (output_bfd, 0, splt->contents + 24); | |
2541 | ||
2542 | elf_section_data (splt->output_section)->this_hdr.sh_entsize = | |
2543 | PLT_HEADER_SIZE; | |
2544 | } | |
2545 | } | |
2546 | ||
2547 | /* Set the first entry in the global offset table to the address of | |
2548 | the dynamic section. */ | |
2549 | sgot = bfd_get_section_by_name (dynobj, ".got"); | |
2550 | if (sgot && sgot->_raw_size > 0) | |
2551 | { | |
2552 | if (sdyn == NULL) | |
2553 | bfd_put_64 (output_bfd, (bfd_vma)0, sgot->contents); | |
2554 | else | |
2555 | bfd_put_64 (output_bfd, | |
2556 | sdyn->output_section->vma + sdyn->output_offset, | |
2557 | sgot->contents); | |
2558 | ||
2559 | elf_section_data (sgot->output_section)->this_hdr.sh_entsize = | |
2560 | 8 * RESERVED_GOT_ENTRIES; | |
2561 | } | |
2562 | ||
2563 | if (info->shared) | |
2564 | { | |
2565 | asection *sdynsym; | |
2566 | asection *s; | |
2567 | Elf_Internal_Sym sym; | |
2568 | ||
2569 | /* Set up the section symbols for the output sections. */ | |
2570 | ||
2571 | sdynsym = bfd_get_section_by_name (dynobj, ".dynsym"); | |
2572 | BFD_ASSERT (sdynsym != NULL); | |
2573 | ||
2574 | sym.st_size = 0; | |
2575 | sym.st_name = 0; | |
2576 | sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION); | |
2577 | sym.st_other = 0; | |
2578 | ||
2579 | for (s = output_bfd->sections; s != NULL; s = s->next) | |
2580 | { | |
2581 | int indx; | |
2582 | ||
2583 | sym.st_value = s->vma; | |
2584 | ||
2585 | indx = elf_section_data (s)->this_idx; | |
2586 | BFD_ASSERT (indx > 0); | |
2587 | sym.st_shndx = indx; | |
2588 | ||
2589 | bfd_elf64_swap_symbol_out (output_bfd, &sym, | |
2590 | (PTR) (((Elf64_External_Sym *) | |
2591 | sdynsym->contents) | |
2592 | + elf_section_data (s)->dynindx)); | |
2593 | } | |
2594 | ||
2595 | /* Set the sh_info field of the output .dynsym section to the | |
2596 | index of the first global symbol. */ | |
2597 | elf_section_data (sdynsym->output_section)->this_hdr.sh_info = | |
2598 | bfd_count_sections (output_bfd) + 1; | |
2599 | } | |
2600 | ||
2601 | return true; | |
2602 | } | |
2603 | ||
2604 | /* We need to use a special link routine to handle the .reginfo and | |
2605 | the .mdebug sections. We need to merge all instances of these | |
2606 | sections together, not write them all out sequentially. */ | |
2607 | ||
2608 | static boolean | |
2609 | elf64_alpha_final_link (abfd, info) | |
2610 | bfd *abfd; | |
2611 | struct bfd_link_info *info; | |
2612 | { | |
2613 | asection *o; | |
2614 | struct bfd_link_order *p; | |
2615 | asection *reginfo_sec, *mdebug_sec, *gptab_data_sec, *gptab_bss_sec; | |
2616 | struct ecoff_debug_info debug; | |
2617 | const struct ecoff_debug_swap *swap | |
2618 | = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap; | |
2619 | HDRR *symhdr = &debug.symbolic_header; | |
2620 | PTR mdebug_handle = NULL; | |
2621 | ||
2622 | /* Go through the sections and collect the .reginfo and .mdebug | |
2623 | information. */ | |
2624 | reginfo_sec = NULL; | |
2625 | mdebug_sec = NULL; | |
2626 | gptab_data_sec = NULL; | |
2627 | gptab_bss_sec = NULL; | |
2628 | for (o = abfd->sections; o != (asection *) NULL; o = o->next) | |
2629 | { | |
2630 | #ifdef ERIC_neverdef | |
2631 | if (strcmp (o->name, ".reginfo") == 0) | |
2632 | { | |
2633 | memset (®info, 0, sizeof reginfo); | |
2634 | ||
2635 | /* We have found the .reginfo section in the output file. | |
2636 | Look through all the link_orders comprising it and merge | |
2637 | the information together. */ | |
2638 | for (p = o->link_order_head; | |
2639 | p != (struct bfd_link_order *) NULL; | |
2640 | p = p->next) | |
2641 | { | |
2642 | asection *input_section; | |
2643 | bfd *input_bfd; | |
2644 | Elf64_External_RegInfo ext; | |
2645 | Elf64_RegInfo sub; | |
2646 | ||
2647 | if (p->type != bfd_indirect_link_order) | |
2648 | { | |
2649 | if (p->type == bfd_fill_link_order) | |
2650 | continue; | |
2651 | abort (); | |
2652 | } | |
2653 | ||
2654 | input_section = p->u.indirect.section; | |
2655 | input_bfd = input_section->owner; | |
2656 | ||
2657 | /* The linker emulation code has probably clobbered the | |
2658 | size to be zero bytes. */ | |
2659 | if (input_section->_raw_size == 0) | |
2660 | input_section->_raw_size = sizeof (Elf64_External_RegInfo); | |
2661 | ||
2662 | if (! bfd_get_section_contents (input_bfd, input_section, | |
2663 | (PTR) &ext, | |
2664 | (file_ptr) 0, | |
2665 | sizeof ext)) | |
2666 | return false; | |
2667 | ||
2668 | bfd_alpha_elf64_swap_reginfo_in (input_bfd, &ext, &sub); | |
2669 | ||
2670 | reginfo.ri_gprmask |= sub.ri_gprmask; | |
2671 | reginfo.ri_cprmask[0] |= sub.ri_cprmask[0]; | |
2672 | reginfo.ri_cprmask[1] |= sub.ri_cprmask[1]; | |
2673 | reginfo.ri_cprmask[2] |= sub.ri_cprmask[2]; | |
2674 | reginfo.ri_cprmask[3] |= sub.ri_cprmask[3]; | |
2675 | ||
2676 | /* ri_gp_value is set by the function | |
2677 | alpha_elf_section_processing when the section is | |
2678 | finally written out. */ | |
2679 | ||
2680 | /* Hack: reset the SEC_HAS_CONTENTS flag so that | |
2681 | elf_link_input_bfd ignores this section. */ | |
2682 | input_section->flags &=~ SEC_HAS_CONTENTS; | |
2683 | } | |
2684 | ||
2685 | /* Force the section size to the value we want. */ | |
2686 | o->_raw_size = sizeof (Elf64_External_RegInfo); | |
2687 | ||
2688 | /* Skip this section later on (I don't think this currently | |
2689 | matters, but someday it might). */ | |
2690 | o->link_order_head = (struct bfd_link_order *) NULL; | |
2691 | ||
2692 | reginfo_sec = o; | |
2693 | } | |
2694 | #endif | |
2695 | ||
2696 | if (strcmp (o->name, ".mdebug") == 0) | |
2697 | { | |
2698 | struct extsym_info einfo; | |
2699 | ||
2700 | /* We have found the .mdebug section in the output file. | |
2701 | Look through all the link_orders comprising it and merge | |
2702 | the information together. */ | |
2703 | symhdr->magic = swap->sym_magic; | |
2704 | /* FIXME: What should the version stamp be? */ | |
2705 | symhdr->vstamp = 0; | |
2706 | symhdr->ilineMax = 0; | |
2707 | symhdr->cbLine = 0; | |
2708 | symhdr->idnMax = 0; | |
2709 | symhdr->ipdMax = 0; | |
2710 | symhdr->isymMax = 0; | |
2711 | symhdr->ioptMax = 0; | |
2712 | symhdr->iauxMax = 0; | |
2713 | symhdr->issMax = 0; | |
2714 | symhdr->issExtMax = 0; | |
2715 | symhdr->ifdMax = 0; | |
2716 | symhdr->crfd = 0; | |
2717 | symhdr->iextMax = 0; | |
2718 | ||
2719 | /* We accumulate the debugging information itself in the | |
2720 | debug_info structure. */ | |
2721 | debug.line = NULL; | |
2722 | debug.external_dnr = NULL; | |
2723 | debug.external_pdr = NULL; | |
2724 | debug.external_sym = NULL; | |
2725 | debug.external_opt = NULL; | |
2726 | debug.external_aux = NULL; | |
2727 | debug.ss = NULL; | |
2728 | debug.ssext = debug.ssext_end = NULL; | |
2729 | debug.external_fdr = NULL; | |
2730 | debug.external_rfd = NULL; | |
2731 | debug.external_ext = debug.external_ext_end = NULL; | |
2732 | ||
2733 | mdebug_handle = bfd_ecoff_debug_init (abfd, &debug, swap, info); | |
2734 | if (mdebug_handle == (PTR) NULL) | |
2735 | return false; | |
2736 | ||
2737 | if (1) | |
2738 | { | |
2739 | asection *s; | |
2740 | EXTR esym; | |
2741 | bfd_vma last; | |
2742 | unsigned int i; | |
2743 | static const char * const name[] = | |
2744 | { | |
2745 | ".text", ".init", ".fini", ".data", | |
2746 | ".rodata", ".sdata", ".sbss", ".bss" | |
2747 | }; | |
2748 | static const int sc[] = { scText, scInit, scFini, scData, | |
2749 | scRData, scSData, scSBss, scBss }; | |
2750 | ||
2751 | esym.jmptbl = 0; | |
2752 | esym.cobol_main = 0; | |
2753 | esym.weakext = 0; | |
2754 | esym.reserved = 0; | |
2755 | esym.ifd = ifdNil; | |
2756 | esym.asym.iss = issNil; | |
2757 | esym.asym.st = stLocal; | |
2758 | esym.asym.reserved = 0; | |
2759 | esym.asym.index = indexNil; | |
2760 | for (i = 0; i < 8; i++) | |
2761 | { | |
2762 | esym.asym.sc = sc[i]; | |
2763 | s = bfd_get_section_by_name (abfd, name[i]); | |
2764 | if (s != NULL) | |
2765 | { | |
2766 | esym.asym.value = s->vma; | |
2767 | last = s->vma + s->_raw_size; | |
2768 | } | |
2769 | else | |
2770 | esym.asym.value = last; | |
2771 | ||
2772 | if (! bfd_ecoff_debug_one_external (abfd, &debug, swap, | |
2773 | name[i], &esym)) | |
2774 | return false; | |
2775 | } | |
2776 | } | |
2777 | ||
2778 | for (p = o->link_order_head; | |
2779 | p != (struct bfd_link_order *) NULL; | |
2780 | p = p->next) | |
2781 | { | |
2782 | asection *input_section; | |
2783 | bfd *input_bfd; | |
2784 | const struct ecoff_debug_swap *input_swap; | |
2785 | struct ecoff_debug_info input_debug; | |
2786 | char *eraw_src; | |
2787 | char *eraw_end; | |
2788 | ||
2789 | if (p->type != bfd_indirect_link_order) | |
2790 | { | |
2791 | if (p->type == bfd_fill_link_order) | |
2792 | continue; | |
2793 | abort (); | |
2794 | } | |
2795 | ||
2796 | input_section = p->u.indirect.section; | |
2797 | input_bfd = input_section->owner; | |
2798 | ||
2799 | if (bfd_get_flavour (input_bfd) != bfd_target_elf_flavour | |
2800 | || (get_elf_backend_data (input_bfd) | |
2801 | ->elf_backend_ecoff_debug_swap) == NULL) | |
2802 | { | |
2803 | /* I don't know what a non ALPHA ELF bfd would be | |
2804 | doing with a .mdebug section, but I don't really | |
2805 | want to deal with it. */ | |
2806 | continue; | |
2807 | } | |
2808 | ||
2809 | input_swap = (get_elf_backend_data (input_bfd) | |
2810 | ->elf_backend_ecoff_debug_swap); | |
2811 | ||
2812 | BFD_ASSERT (p->size == input_section->_raw_size); | |
2813 | ||
2814 | /* The ECOFF linking code expects that we have already | |
2815 | read in the debugging information and set up an | |
2816 | ecoff_debug_info structure, so we do that now. */ | |
2817 | if (!elf64_alpha_read_ecoff_info (input_bfd, input_section, | |
2818 | &input_debug)) | |
2819 | return false; | |
2820 | ||
2821 | if (! (bfd_ecoff_debug_accumulate | |
2822 | (mdebug_handle, abfd, &debug, swap, input_bfd, | |
2823 | &input_debug, input_swap, info))) | |
2824 | return false; | |
2825 | ||
2826 | /* Loop through the external symbols. For each one with | |
2827 | interesting information, try to find the symbol in | |
2828 | the linker global hash table and save the information | |
2829 | for the output external symbols. */ | |
2830 | eraw_src = input_debug.external_ext; | |
2831 | eraw_end = (eraw_src | |
2832 | + (input_debug.symbolic_header.iextMax | |
2833 | * input_swap->external_ext_size)); | |
2834 | for (; | |
2835 | eraw_src < eraw_end; | |
2836 | eraw_src += input_swap->external_ext_size) | |
2837 | { | |
2838 | EXTR ext; | |
2839 | const char *name; | |
2840 | struct alpha_elf_link_hash_entry *h; | |
2841 | ||
2842 | (*input_swap->swap_ext_in) (input_bfd, (PTR) eraw_src, &ext); | |
2843 | if (ext.asym.sc == scNil | |
2844 | || ext.asym.sc == scUndefined | |
2845 | || ext.asym.sc == scSUndefined) | |
2846 | continue; | |
2847 | ||
2848 | name = input_debug.ssext + ext.asym.iss; | |
2849 | h = alpha_elf_link_hash_lookup (alpha_elf_hash_table (info), | |
2850 | name, false, false, true); | |
2851 | if (h == NULL || h->esym.ifd != -2) | |
2852 | continue; | |
2853 | ||
2854 | if (ext.ifd != -1) | |
2855 | { | |
2856 | BFD_ASSERT (ext.ifd | |
2857 | < input_debug.symbolic_header.ifdMax); | |
2858 | ext.ifd = input_debug.ifdmap[ext.ifd]; | |
2859 | } | |
2860 | ||
2861 | h->esym = ext; | |
2862 | } | |
2863 | ||
2864 | /* Free up the information we just read. */ | |
2865 | free (input_debug.line); | |
2866 | free (input_debug.external_dnr); | |
2867 | free (input_debug.external_pdr); | |
2868 | free (input_debug.external_sym); | |
2869 | free (input_debug.external_opt); | |
2870 | free (input_debug.external_aux); | |
2871 | free (input_debug.ss); | |
2872 | free (input_debug.ssext); | |
2873 | free (input_debug.external_fdr); | |
2874 | free (input_debug.external_rfd); | |
2875 | free (input_debug.external_ext); | |
2876 | ||
2877 | /* Hack: reset the SEC_HAS_CONTENTS flag so that | |
2878 | elf_link_input_bfd ignores this section. */ | |
2879 | input_section->flags &=~ SEC_HAS_CONTENTS; | |
2880 | } | |
2881 | ||
2882 | #ifdef ERIC_neverdef | |
2883 | if (info->shared) | |
2884 | { | |
2885 | /* Create .rtproc section. */ | |
2886 | rtproc_sec = bfd_get_section_by_name (abfd, ".rtproc"); | |
2887 | if (rtproc_sec == NULL) | |
2888 | { | |
2889 | flagword flags = (SEC_HAS_CONTENTS | SEC_IN_MEMORY | |
2890 | | SEC_READONLY); | |
2891 | ||
2892 | rtproc_sec = bfd_make_section (abfd, ".rtproc"); | |
2893 | if (rtproc_sec == NULL | |
2894 | || ! bfd_set_section_flags (abfd, rtproc_sec, flags) | |
2895 | || ! bfd_set_section_alignment (abfd, rtproc_sec, 12)) | |
2896 | return false; | |
2897 | } | |
2898 | ||
2899 | if (! alpha_elf_create_procedure_table (mdebug_handle, abfd, | |
2900 | info, rtproc_sec, &debug)) | |
2901 | return false; | |
2902 | } | |
2903 | #endif | |
2904 | ||
2905 | ||
2906 | /* Build the external symbol information. */ | |
2907 | einfo.abfd = abfd; | |
2908 | einfo.info = info; | |
2909 | einfo.debug = &debug; | |
2910 | einfo.swap = swap; | |
2911 | einfo.failed = false; | |
2912 | elf_link_hash_traverse (elf_hash_table (info), | |
2913 | elf64_alpha_output_extsym, | |
2914 | (PTR) &einfo); | |
2915 | if (einfo.failed) | |
2916 | return false; | |
2917 | ||
2918 | /* Set the size of the .mdebug section. */ | |
2919 | o->_raw_size = bfd_ecoff_debug_size (abfd, &debug, swap); | |
2920 | ||
2921 | /* Skip this section later on (I don't think this currently | |
2922 | matters, but someday it might). */ | |
2923 | o->link_order_head = (struct bfd_link_order *) NULL; | |
2924 | ||
2925 | mdebug_sec = o; | |
2926 | } | |
2927 | ||
2928 | #ifdef ERIC_neverdef | |
2929 | if (strncmp (o->name, ".gptab.", sizeof ".gptab." - 1) == 0) | |
2930 | { | |
2931 | const char *subname; | |
2932 | unsigned int c; | |
2933 | Elf64_gptab *tab; | |
2934 | Elf64_External_gptab *ext_tab; | |
2935 | unsigned int i; | |
2936 | ||
2937 | /* The .gptab.sdata and .gptab.sbss sections hold | |
2938 | information describing how the small data area would | |
2939 | change depending upon the -G switch. These sections | |
2940 | not used in executables files. */ | |
2941 | if (! info->relocateable) | |
2942 | { | |
2943 | asection **secpp; | |
2944 | ||
2945 | for (p = o->link_order_head; | |
2946 | p != (struct bfd_link_order *) NULL; | |
2947 | p = p->next) | |
2948 | { | |
2949 | asection *input_section; | |
2950 | ||
2951 | if (p->type != bfd_indirect_link_order) | |
2952 | { | |
2953 | if (p->type == bfd_fill_link_order) | |
2954 | continue; | |
2955 | abort (); | |
2956 | } | |
2957 | ||
2958 | input_section = p->u.indirect.section; | |
2959 | ||
2960 | /* Hack: reset the SEC_HAS_CONTENTS flag so that | |
2961 | elf_link_input_bfd ignores this section. */ | |
2962 | input_section->flags &=~ SEC_HAS_CONTENTS; | |
2963 | } | |
2964 | ||
2965 | /* Skip this section later on (I don't think this | |
2966 | currently matters, but someday it might). */ | |
2967 | o->link_order_head = (struct bfd_link_order *) NULL; | |
2968 | ||
2969 | /* Really remove the section. */ | |
2970 | for (secpp = &abfd->sections; | |
2971 | *secpp != o; | |
2972 | secpp = &(*secpp)->next) | |
2973 | ; | |
2974 | *secpp = (*secpp)->next; | |
2975 | --abfd->section_count; | |
2976 | ||
2977 | continue; | |
2978 | } | |
2979 | ||
2980 | /* There is one gptab for initialized data, and one for | |
2981 | uninitialized data. */ | |
2982 | if (strcmp (o->name, ".gptab.sdata") == 0) | |
2983 | gptab_data_sec = o; | |
2984 | else if (strcmp (o->name, ".gptab.sbss") == 0) | |
2985 | gptab_bss_sec = o; | |
2986 | else | |
2987 | { | |
2988 | (*_bfd_error_handler) | |
2989 | ("%s: illegal section name `%s'", | |
2990 | bfd_get_filename (abfd), o->name); | |
2991 | bfd_set_error (bfd_error_nonrepresentable_section); | |
2992 | return false; | |
2993 | } | |
2994 | ||
2995 | /* The linker script always combines .gptab.data and | |
2996 | .gptab.sdata into .gptab.sdata, and likewise for | |
2997 | .gptab.bss and .gptab.sbss. It is possible that there is | |
2998 | no .sdata or .sbss section in the output file, in which | |
2999 | case we must change the name of the output section. */ | |
3000 | subname = o->name + sizeof ".gptab" - 1; | |
3001 | if (bfd_get_section_by_name (abfd, subname) == NULL) | |
3002 | { | |
3003 | if (o == gptab_data_sec) | |
3004 | o->name = ".gptab.data"; | |
3005 | else | |
3006 | o->name = ".gptab.bss"; | |
3007 | subname = o->name + sizeof ".gptab" - 1; | |
3008 | BFD_ASSERT (bfd_get_section_by_name (abfd, subname) != NULL); | |
3009 | } | |
3010 | ||
3011 | /* Set up the first entry. */ | |
3012 | c = 1; | |
3013 | tab = (Elf64_gptab *) bfd_malloc (c * sizeof (Elf64_gptab)); | |
3014 | if (tab == NULL) | |
3015 | return false; | |
3016 | tab[0].gt_header.gt_current_g_value = elf_gp_size (abfd); | |
3017 | tab[0].gt_header.gt_unused = 0; | |
3018 | ||
3019 | /* Combine the input sections. */ | |
3020 | for (p = o->link_order_head; | |
3021 | p != (struct bfd_link_order *) NULL; | |
3022 | p = p->next) | |
3023 | { | |
3024 | asection *input_section; | |
3025 | bfd *input_bfd; | |
3026 | bfd_size_type size; | |
3027 | unsigned long last; | |
3028 | bfd_size_type gpentry; | |
3029 | ||
3030 | if (p->type != bfd_indirect_link_order) | |
3031 | { | |
3032 | if (p->type == bfd_fill_link_order) | |
3033 | continue; | |
3034 | abort (); | |
3035 | } | |
3036 | ||
3037 | input_section = p->u.indirect.section; | |
3038 | input_bfd = input_section->owner; | |
3039 | ||
3040 | /* Combine the gptab entries for this input section one | |
3041 | by one. We know that the input gptab entries are | |
3042 | sorted by ascending -G value. */ | |
3043 | size = bfd_section_size (input_bfd, input_section); | |
3044 | last = 0; | |
3045 | for (gpentry = sizeof (Elf64_External_gptab); | |
3046 | gpentry < size; | |
3047 | gpentry += sizeof (Elf64_External_gptab)) | |
3048 | { | |
3049 | Elf64_External_gptab ext_gptab; | |
3050 | Elf64_gptab int_gptab; | |
3051 | unsigned long val; | |
3052 | unsigned long add; | |
3053 | boolean exact; | |
3054 | unsigned int look; | |
3055 | ||
3056 | if (! (bfd_get_section_contents | |
3057 | (input_bfd, input_section, (PTR) &ext_gptab, | |
3058 | gpentry, sizeof (Elf64_External_gptab)))) | |
3059 | { | |
3060 | free (tab); | |
3061 | return false; | |
3062 | } | |
3063 | ||
3064 | bfd_alpha_elf64_swap_gptab_in (input_bfd, &ext_gptab, | |
3065 | &int_gptab); | |
3066 | val = int_gptab.gt_entry.gt_g_value; | |
3067 | add = int_gptab.gt_entry.gt_bytes - last; | |
3068 | ||
3069 | exact = false; | |
3070 | for (look = 1; look < c; look++) | |
3071 | { | |
3072 | if (tab[look].gt_entry.gt_g_value >= val) | |
3073 | tab[look].gt_entry.gt_bytes += add; | |
3074 | ||
3075 | if (tab[look].gt_entry.gt_g_value == val) | |
3076 | exact = true; | |
3077 | } | |
3078 | ||
3079 | if (! exact) | |
3080 | { | |
3081 | Elf64_gptab *new_tab; | |
3082 | unsigned int max; | |
3083 | ||
3084 | /* We need a new table entry. */ | |
3085 | new_tab = ((Elf64_gptab *) | |
3086 | bfd_realloc ((PTR) tab, | |
3087 | (c + 1) * sizeof (Elf64_gptab))); | |
3088 | if (new_tab == NULL) | |
3089 | { | |
3090 | free (tab); | |
3091 | return false; | |
3092 | } | |
3093 | tab = new_tab; | |
3094 | tab[c].gt_entry.gt_g_value = val; | |
3095 | tab[c].gt_entry.gt_bytes = add; | |
3096 | ||
3097 | /* Merge in the size for the next smallest -G | |
3098 | value, since that will be implied by this new | |
3099 | value. */ | |
3100 | max = 0; | |
3101 | for (look = 1; look < c; look++) | |
3102 | { | |
3103 | if (tab[look].gt_entry.gt_g_value < val | |
3104 | && (max == 0 | |
3105 | || (tab[look].gt_entry.gt_g_value | |
3106 | > tab[max].gt_entry.gt_g_value))) | |
3107 | max = look; | |
3108 | } | |
3109 | if (max != 0) | |
3110 | tab[c].gt_entry.gt_bytes += | |
3111 | tab[max].gt_entry.gt_bytes; | |
3112 | ||
3113 | ++c; | |
3114 | } | |
3115 | ||
3116 | last = int_gptab.gt_entry.gt_bytes; | |
3117 | } | |
3118 | ||
3119 | /* Hack: reset the SEC_HAS_CONTENTS flag so that | |
3120 | elf_link_input_bfd ignores this section. */ | |
3121 | input_section->flags &=~ SEC_HAS_CONTENTS; | |
3122 | } | |
3123 | ||
3124 | /* The table must be sorted by -G value. */ | |
3125 | if (c > 2) | |
3126 | qsort (tab + 1, c - 1, sizeof (tab[0]), gptab_compare); | |
3127 | ||
3128 | /* Swap out the table. */ | |
3129 | ext_tab = ((Elf64_External_gptab *) | |
3130 | bfd_alloc (abfd, c * sizeof (Elf64_External_gptab))); | |
3131 | if (ext_tab == NULL) | |
3132 | { | |
3133 | free (tab); | |
3134 | return false; | |
3135 | } | |
3136 | ||
3137 | for (i = 0; i < c; i++) | |
3138 | bfd_alpha_elf64_swap_gptab_out (abfd, tab + i, ext_tab + i); | |
3139 | free (tab); | |
3140 | ||
3141 | o->_raw_size = c * sizeof (Elf64_External_gptab); | |
3142 | o->contents = (bfd_byte *) ext_tab; | |
3143 | ||
3144 | /* Skip this section later on (I don't think this currently | |
3145 | matters, but someday it might). */ | |
3146 | o->link_order_head = (struct bfd_link_order *) NULL; | |
3147 | } | |
3148 | #endif | |
3149 | ||
3150 | } | |
3151 | ||
3152 | /* Invoke the regular ELF backend linker to do all the work. */ | |
3153 | if (! bfd_elf64_bfd_final_link (abfd, info)) | |
3154 | return false; | |
3155 | ||
3156 | /* Now write out the computed sections. */ | |
3157 | ||
3158 | #ifdef ERIC_neverdef | |
3159 | if (reginfo_sec != (asection *) NULL) | |
3160 | { | |
3161 | Elf64_External_RegInfo ext; | |
3162 | ||
3163 | bfd_alpha_elf64_swap_reginfo_out (abfd, ®info, &ext); | |
3164 | if (! bfd_set_section_contents (abfd, reginfo_sec, (PTR) &ext, | |
3165 | (file_ptr) 0, sizeof ext)) | |
3166 | return false; | |
3167 | } | |
3168 | #endif | |
3169 | ||
3170 | if (mdebug_sec != (asection *) NULL) | |
3171 | { | |
3172 | BFD_ASSERT (abfd->output_has_begun); | |
3173 | if (! bfd_ecoff_write_accumulated_debug (mdebug_handle, abfd, &debug, | |
3174 | swap, info, | |
3175 | mdebug_sec->filepos)) | |
3176 | return false; | |
3177 | ||
3178 | bfd_ecoff_debug_free (mdebug_handle, abfd, &debug, swap, info); | |
3179 | } | |
3180 | ||
3181 | if (gptab_data_sec != (asection *) NULL) | |
3182 | { | |
3183 | if (! bfd_set_section_contents (abfd, gptab_data_sec, | |
3184 | gptab_data_sec->contents, | |
3185 | (file_ptr) 0, | |
3186 | gptab_data_sec->_raw_size)) | |
3187 | return false; | |
3188 | } | |
3189 | ||
3190 | if (gptab_bss_sec != (asection *) NULL) | |
3191 | { | |
3192 | if (! bfd_set_section_contents (abfd, gptab_bss_sec, | |
3193 | gptab_bss_sec->contents, | |
3194 | (file_ptr) 0, | |
3195 | gptab_bss_sec->_raw_size)) | |
3196 | return false; | |
3197 | } | |
3198 | ||
3199 | return true; | |
3200 | } | |
3201 | \f | |
3202 | /* ECOFF swapping routines. These are used when dealing with the | |
3203 | .mdebug section, which is in the ECOFF debugging format. Copied | |
3204 | from elf32-mips.c. */ | |
3205 | static const struct ecoff_debug_swap | |
3206 | elf64_alpha_ecoff_debug_swap = | |
3207 | { | |
3208 | /* Symbol table magic number. */ | |
3209 | magicSym2, | |
3210 | /* Alignment of debugging information. E.g., 4. */ | |
3211 | 8, | |
3212 | /* Sizes of external symbolic information. */ | |
3213 | sizeof (struct hdr_ext), | |
3214 | sizeof (struct dnr_ext), | |
3215 | sizeof (struct pdr_ext), | |
3216 | sizeof (struct sym_ext), | |
3217 | sizeof (struct opt_ext), | |
3218 | sizeof (struct fdr_ext), | |
3219 | sizeof (struct rfd_ext), | |
3220 | sizeof (struct ext_ext), | |
3221 | /* Functions to swap in external symbolic data. */ | |
3222 | ecoff_swap_hdr_in, | |
3223 | ecoff_swap_dnr_in, | |
3224 | ecoff_swap_pdr_in, | |
3225 | ecoff_swap_sym_in, | |
3226 | ecoff_swap_opt_in, | |
3227 | ecoff_swap_fdr_in, | |
3228 | ecoff_swap_rfd_in, | |
3229 | ecoff_swap_ext_in, | |
3230 | _bfd_ecoff_swap_tir_in, | |
3231 | _bfd_ecoff_swap_rndx_in, | |
3232 | /* Functions to swap out external symbolic data. */ | |
3233 | ecoff_swap_hdr_out, | |
3234 | ecoff_swap_dnr_out, | |
3235 | ecoff_swap_pdr_out, | |
3236 | ecoff_swap_sym_out, | |
3237 | ecoff_swap_opt_out, | |
3238 | ecoff_swap_fdr_out, | |
3239 | ecoff_swap_rfd_out, | |
3240 | ecoff_swap_ext_out, | |
3241 | _bfd_ecoff_swap_tir_out, | |
3242 | _bfd_ecoff_swap_rndx_out, | |
3243 | /* Function to read in symbolic data. */ | |
3244 | elf64_alpha_read_ecoff_info | |
3245 | }; | |
3246 | \f | |
3247 | #define TARGET_LITTLE_SYM bfd_elf64_alpha_vec | |
3248 | #define TARGET_LITTLE_NAME "elf64-alpha" | |
3249 | #define ELF_ARCH bfd_arch_alpha | |
3250 | #define ELF_MACHINE_CODE EM_ALPHA | |
3251 | #define ELF_MAXPAGESIZE 0x100000 | |
3252 | ||
3253 | #define bfd_elf64_bfd_link_hash_table_create \ | |
3254 | elf64_alpha_bfd_link_hash_table_create | |
3255 | ||
3256 | #define bfd_elf64_bfd_reloc_type_lookup \ | |
3257 | elf64_alpha_bfd_reloc_type_lookup | |
3258 | #define elf_info_to_howto \ | |
3259 | elf64_alpha_info_to_howto | |
3260 | ||
3261 | #define elf_backend_object_p \ | |
3262 | elf64_alpha_object_p | |
3263 | #define elf_backend_section_from_shdr \ | |
3264 | elf64_alpha_section_from_shdr | |
3265 | #define elf_backend_fake_sections \ | |
3266 | elf64_alpha_fake_sections | |
3267 | #define elf_backend_additional_program_headers \ | |
3268 | elf64_alpha_additional_program_headers | |
3269 | ||
3270 | #define bfd_elf64_bfd_is_local_label \ | |
3271 | elf64_alpha_is_local_label | |
3272 | #define bfd_elf64_find_nearest_line \ | |
3273 | elf64_alpha_find_nearest_line | |
3274 | ||
3275 | #define elf_backend_check_relocs \ | |
3276 | elf64_alpha_check_relocs | |
3277 | #define elf_backend_create_dynamic_sections \ | |
3278 | elf64_alpha_create_dynamic_sections | |
3279 | #define elf_backend_adjust_dynamic_symbol \ | |
3280 | elf64_alpha_adjust_dynamic_symbol | |
3281 | #define elf_backend_size_dynamic_sections \ | |
3282 | elf64_alpha_size_dynamic_sections | |
3283 | #define elf_backend_relocate_section \ | |
3284 | elf64_alpha_relocate_section | |
3285 | #define elf_backend_finish_dynamic_symbol \ | |
3286 | elf64_alpha_finish_dynamic_symbol | |
3287 | #define elf_backend_finish_dynamic_sections \ | |
3288 | elf64_alpha_finish_dynamic_sections | |
3289 | #define bfd_elf64_bfd_final_link \ | |
3290 | elf64_alpha_final_link | |
3291 | ||
3292 | #define elf_backend_ecoff_debug_swap \ | |
3293 | &elf64_alpha_ecoff_debug_swap | |
3294 | ||
3295 | /* | |
3296 | * A few constants that determine how the .plt section is set up. | |
3297 | */ | |
3298 | #define elf_backend_want_got_plt 0 | |
3299 | #define elf_backend_plt_readonly 0 | |
3300 | #define elf_backend_want_plt_sym 1 | |
3301 | ||
3302 | #include "elf64-target.h" |