Commit | Line | Data |
---|---|---|
90ace9e9 JT |
1 | /* VAX series support for 32-bit ELF |
2 | Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 | |
3 | Free Software Foundation, Inc. | |
4 | Contributed by Matt Thomas <matt@3am-software.com>. | |
5 | ||
6 | This file is part of BFD, the Binary File Descriptor library. | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 2 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program; if not, write to the Free Software | |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | #include "bfd.h" | |
23 | #include "sysdep.h" | |
24 | #include "bfdlink.h" | |
25 | #include "libbfd.h" | |
26 | #include "elf-bfd.h" | |
27 | #include "elf/vax.h" | |
28 | ||
29 | static reloc_howto_type *reloc_type_lookup | |
30 | PARAMS ((bfd *, bfd_reloc_code_real_type)); | |
31 | static void rtype_to_howto | |
32 | PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *)); | |
33 | static struct bfd_hash_entry *elf_vax_link_hash_newfunc | |
34 | PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); | |
35 | static struct bfd_link_hash_table *elf_vax_link_hash_table_create | |
36 | PARAMS ((bfd *)); | |
37 | static boolean elf_vax_check_relocs | |
38 | PARAMS ((bfd *, struct bfd_link_info *, asection *, | |
39 | const Elf_Internal_Rela *)); | |
40 | static asection *elf_vax_gc_mark_hook | |
1e2f5b6e | 41 | PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, |
90ace9e9 JT |
42 | struct elf_link_hash_entry *, Elf_Internal_Sym *)); |
43 | static boolean elf_vax_gc_sweep_hook | |
44 | PARAMS ((bfd *, struct bfd_link_info *, asection *, | |
45 | const Elf_Internal_Rela *)); | |
46 | static boolean elf_vax_adjust_dynamic_symbol | |
47 | PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); | |
48 | static boolean elf_vax_size_dynamic_sections | |
49 | PARAMS ((bfd *, struct bfd_link_info *)); | |
50 | static boolean elf_vax_relocate_section | |
51 | PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, | |
52 | Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); | |
53 | static boolean elf_vax_finish_dynamic_symbol | |
54 | PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, | |
55 | Elf_Internal_Sym *)); | |
56 | static boolean elf_vax_finish_dynamic_sections | |
57 | PARAMS ((bfd *, struct bfd_link_info *)); | |
58 | ||
59 | static boolean elf32_vax_set_private_flags | |
60 | PARAMS ((bfd *, flagword)); | |
61 | static boolean elf32_vax_merge_private_bfd_data | |
62 | PARAMS ((bfd *, bfd *)); | |
63 | static boolean elf32_vax_print_private_bfd_data | |
64 | PARAMS ((bfd *, PTR)); | |
65 | ||
66 | static reloc_howto_type howto_table[] = { | |
67 | HOWTO (R_VAX_NONE, /* type */ | |
68 | 0, /* rightshift */ | |
69 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
70 | 0, /* bitsize */ | |
71 | false, /* pc_relative */ | |
72 | 0, /* bitpos */ | |
73 | complain_overflow_dont, /* complain_on_overflow */ | |
74 | bfd_elf_generic_reloc, /* special_function */ | |
75 | "R_VAX_NONE", /* name */ | |
76 | false, /* partial_inplace */ | |
77 | 0, /* src_mask */ | |
78 | 0x00000000, /* dst_mask */ | |
79 | false), /* pcrel_offset */ | |
80 | ||
81 | HOWTO (R_VAX_32, /* type */ | |
82 | 0, /* rightshift */ | |
83 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
84 | 32, /* bitsize */ | |
85 | false, /* pc_relative */ | |
86 | 0, /* bitpos */ | |
87 | complain_overflow_bitfield, /* complain_on_overflow */ | |
88 | bfd_elf_generic_reloc, /* special_function */ | |
89 | "R_VAX_32", /* name */ | |
90 | false, /* partial_inplace */ | |
91 | 0, /* src_mask */ | |
92 | 0xffffffff, /* dst_mask */ | |
93 | false), /* pcrel_offset */ | |
94 | ||
95 | HOWTO (R_VAX_16, /* type */ | |
96 | 0, /* rightshift */ | |
97 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
98 | 16, /* bitsize */ | |
99 | false, /* pc_relative */ | |
100 | 0, /* bitpos */ | |
101 | complain_overflow_bitfield, /* complain_on_overflow */ | |
102 | bfd_elf_generic_reloc, /* special_function */ | |
103 | "R_VAX_16", /* name */ | |
104 | false, /* partial_inplace */ | |
105 | 0, /* src_mask */ | |
106 | 0x0000ffff, /* dst_mask */ | |
107 | false), /* pcrel_offset */ | |
108 | ||
109 | HOWTO (R_VAX_8, /* type */ | |
110 | 0, /* rightshift */ | |
111 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
112 | 8, /* bitsize */ | |
113 | false, /* pc_relative */ | |
114 | 0, /* bitpos */ | |
115 | complain_overflow_bitfield, /* complain_on_overflow */ | |
116 | bfd_elf_generic_reloc, /* special_function */ | |
117 | "R_VAX_8", /* name */ | |
118 | false, /* partial_inplace */ | |
119 | 0, /* src_mask */ | |
120 | 0x000000ff, /* dst_mask */ | |
121 | false), /* pcrel_offset */ | |
122 | ||
123 | HOWTO (R_VAX_PC32, /* type */ | |
124 | 0, /* rightshift */ | |
125 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
126 | 32, /* bitsize */ | |
127 | true, /* pc_relative */ | |
128 | 0, /* bitpos */ | |
129 | complain_overflow_bitfield, /* complain_on_overflow */ | |
130 | bfd_elf_generic_reloc, /* special_function */ | |
131 | "R_VAX_PC32", /* name */ | |
132 | false, /* partial_inplace */ | |
133 | 0, /* src_mask */ | |
134 | 0xffffffff, /* dst_mask */ | |
135 | true), /* pcrel_offset */ | |
136 | ||
137 | HOWTO (R_VAX_PC16, /* type */ | |
138 | 0, /* rightshift */ | |
139 | 1, /* size (0 = byte, 1 = short, 2 = long) */ | |
140 | 16, /* bitsize */ | |
141 | true, /* pc_relative */ | |
142 | 0, /* bitpos */ | |
143 | complain_overflow_signed, /* complain_on_overflow */ | |
144 | bfd_elf_generic_reloc, /* special_function */ | |
145 | "R_VAX_PC16", /* name */ | |
146 | false, /* partial_inplace */ | |
147 | 0, /* src_mask */ | |
148 | 0x0000ffff, /* dst_mask */ | |
149 | true), /* pcrel_offset */ | |
150 | ||
151 | HOWTO (R_VAX_PC8, /* type */ | |
152 | 0, /* rightshift */ | |
153 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
154 | 8, /* bitsize */ | |
155 | true, /* pc_relative */ | |
156 | 0, /* bitpos */ | |
157 | complain_overflow_signed, /* complain_on_overflow */ | |
158 | bfd_elf_generic_reloc, /* special_function */ | |
159 | "R_VAX_PC8", /* name */ | |
160 | false, /* partial_inplace */ | |
161 | 0, /* src_mask */ | |
162 | 0x000000ff, /* dst_mask */ | |
163 | true), /* pcrel_offset */ | |
164 | ||
165 | HOWTO (R_VAX_GOT32, /* type */ | |
166 | 0, /* rightshift */ | |
167 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
168 | 32, /* bitsize */ | |
169 | true, /* pc_relative */ | |
170 | 0, /* bitpos */ | |
171 | complain_overflow_bitfield, /* complain_on_overflow */ | |
172 | bfd_elf_generic_reloc, /* special_function */ | |
173 | "R_VAX_GOT32", /* name */ | |
174 | false, /* partial_inplace */ | |
175 | 0, /* src_mask */ | |
176 | 0xffffffff, /* dst_mask */ | |
177 | true), /* pcrel_offset */ | |
178 | ||
179 | EMPTY_HOWTO (-1), | |
180 | EMPTY_HOWTO (-1), | |
181 | EMPTY_HOWTO (-1), | |
182 | EMPTY_HOWTO (-1), | |
183 | EMPTY_HOWTO (-1), | |
184 | ||
185 | HOWTO (R_VAX_PLT32, /* type */ | |
186 | 0, /* rightshift */ | |
187 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
188 | 32, /* bitsize */ | |
189 | true, /* pc_relative */ | |
190 | 0, /* bitpos */ | |
191 | complain_overflow_bitfield, /* complain_on_overflow */ | |
192 | bfd_elf_generic_reloc, /* special_function */ | |
193 | "R_VAX_PLT32", /* name */ | |
194 | false, /* partial_inplace */ | |
195 | 0, /* src_mask */ | |
196 | 0xffffffff, /* dst_mask */ | |
197 | true), /* pcrel_offset */ | |
198 | ||
199 | EMPTY_HOWTO (-1), | |
200 | EMPTY_HOWTO (-1), | |
201 | EMPTY_HOWTO (-1), | |
202 | EMPTY_HOWTO (-1), | |
203 | EMPTY_HOWTO (-1), | |
204 | ||
205 | HOWTO (R_VAX_COPY, /* type */ | |
206 | 0, /* rightshift */ | |
207 | 0, /* size (0 = byte, 1 = short, 2 = long) */ | |
208 | 0, /* bitsize */ | |
209 | false, /* pc_relative */ | |
210 | 0, /* bitpos */ | |
211 | complain_overflow_dont, /* complain_on_overflow */ | |
212 | bfd_elf_generic_reloc, /* special_function */ | |
213 | "R_VAX_COPY", /* name */ | |
214 | false, /* partial_inplace */ | |
215 | 0, /* src_mask */ | |
216 | 0xffffffff, /* dst_mask */ | |
217 | false), /* pcrel_offset */ | |
218 | ||
219 | HOWTO (R_VAX_GLOB_DAT, /* type */ | |
220 | 0, /* rightshift */ | |
221 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
222 | 32, /* bitsize */ | |
223 | false, /* pc_relative */ | |
224 | 0, /* bitpos */ | |
225 | complain_overflow_dont, /* complain_on_overflow */ | |
226 | bfd_elf_generic_reloc, /* special_function */ | |
227 | "R_VAX_GLOB_DAT", /* name */ | |
228 | false, /* partial_inplace */ | |
229 | 0, /* src_mask */ | |
230 | 0xffffffff, /* dst_mask */ | |
231 | false), /* pcrel_offset */ | |
232 | ||
233 | HOWTO (R_VAX_JMP_SLOT, /* type */ | |
234 | 0, /* rightshift */ | |
235 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
236 | 32, /* bitsize */ | |
237 | false, /* pc_relative */ | |
238 | 0, /* bitpos */ | |
239 | complain_overflow_dont, /* complain_on_overflow */ | |
240 | bfd_elf_generic_reloc, /* special_function */ | |
241 | "R_VAX_JMP_SLOT", /* name */ | |
242 | false, /* partial_inplace */ | |
243 | 0, /* src_mask */ | |
244 | 0xffffffff, /* dst_mask */ | |
245 | false), /* pcrel_offset */ | |
246 | ||
247 | HOWTO (R_VAX_RELATIVE, /* type */ | |
248 | 0, /* rightshift */ | |
249 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
250 | 32, /* bitsize */ | |
251 | false, /* pc_relative */ | |
252 | 0, /* bitpos */ | |
253 | complain_overflow_dont, /* complain_on_overflow */ | |
254 | bfd_elf_generic_reloc, /* special_function */ | |
255 | "R_VAX_RELATIVE", /* name */ | |
256 | false, /* partial_inplace */ | |
257 | 0, /* src_mask */ | |
258 | 0xffffffff, /* dst_mask */ | |
259 | false), /* pcrel_offset */ | |
260 | ||
261 | /* GNU extension to record C++ vtable hierarchy */ | |
262 | HOWTO (R_VAX_GNU_VTINHERIT, /* type */ | |
263 | 0, /* rightshift */ | |
264 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
265 | 0, /* bitsize */ | |
266 | false, /* pc_relative */ | |
267 | 0, /* bitpos */ | |
268 | complain_overflow_dont, /* complain_on_overflow */ | |
269 | NULL, /* special_function */ | |
270 | "R_VAX_GNU_VTINHERIT", /* name */ | |
271 | false, /* partial_inplace */ | |
272 | 0, /* src_mask */ | |
273 | 0, /* dst_mask */ | |
274 | false), /* pcrel_offset */ | |
275 | ||
276 | /* GNU extension to record C++ vtable member usage */ | |
277 | HOWTO (R_VAX_GNU_VTENTRY, /* type */ | |
278 | 0, /* rightshift */ | |
279 | 2, /* size (0 = byte, 1 = short, 2 = long) */ | |
280 | 0, /* bitsize */ | |
281 | false, /* pc_relative */ | |
282 | 0, /* bitpos */ | |
283 | complain_overflow_dont, /* complain_on_overflow */ | |
284 | _bfd_elf_rel_vtable_reloc_fn, /* special_function */ | |
285 | "R_VAX_GNU_VTENTRY", /* name */ | |
286 | false, /* partial_inplace */ | |
287 | 0, /* src_mask */ | |
288 | 0, /* dst_mask */ | |
289 | false), /* pcrel_offset */ | |
290 | }; | |
291 | ||
292 | static void | |
293 | rtype_to_howto (abfd, cache_ptr, dst) | |
294 | bfd *abfd ATTRIBUTE_UNUSED; | |
295 | arelent *cache_ptr; | |
296 | Elf_Internal_Rela *dst; | |
297 | { | |
298 | BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_VAX_max); | |
299 | cache_ptr->howto = &howto_table[ELF32_R_TYPE(dst->r_info)]; | |
300 | } | |
301 | ||
302 | #define elf_info_to_howto rtype_to_howto | |
303 | ||
304 | static const struct | |
305 | { | |
306 | bfd_reloc_code_real_type bfd_val; | |
307 | int elf_val; | |
308 | } reloc_map[] = { | |
309 | { BFD_RELOC_NONE, R_VAX_NONE }, | |
310 | { BFD_RELOC_32, R_VAX_32 }, | |
311 | { BFD_RELOC_16, R_VAX_16 }, | |
312 | { BFD_RELOC_8, R_VAX_8 }, | |
313 | { BFD_RELOC_32_PCREL, R_VAX_PC32 }, | |
314 | { BFD_RELOC_16_PCREL, R_VAX_PC16 }, | |
315 | { BFD_RELOC_8_PCREL, R_VAX_PC8 }, | |
316 | { BFD_RELOC_32_GOT_PCREL, R_VAX_GOT32 }, | |
317 | { BFD_RELOC_32_PLT_PCREL, R_VAX_PLT32 }, | |
318 | { BFD_RELOC_NONE, R_VAX_COPY }, | |
319 | { BFD_RELOC_VAX_GLOB_DAT, R_VAX_GLOB_DAT }, | |
320 | { BFD_RELOC_VAX_JMP_SLOT, R_VAX_JMP_SLOT }, | |
321 | { BFD_RELOC_VAX_RELATIVE, R_VAX_RELATIVE }, | |
322 | { BFD_RELOC_CTOR, R_VAX_32 }, | |
323 | { BFD_RELOC_VTABLE_INHERIT, R_VAX_GNU_VTINHERIT }, | |
324 | { BFD_RELOC_VTABLE_ENTRY, R_VAX_GNU_VTENTRY }, | |
325 | }; | |
326 | ||
327 | static reloc_howto_type * | |
328 | reloc_type_lookup (abfd, code) | |
329 | bfd *abfd ATTRIBUTE_UNUSED; | |
330 | bfd_reloc_code_real_type code; | |
331 | { | |
332 | unsigned int i; | |
333 | for (i = 0; i < sizeof (reloc_map) / sizeof (reloc_map[0]); i++) | |
334 | { | |
335 | if (reloc_map[i].bfd_val == code) | |
336 | return &howto_table[reloc_map[i].elf_val]; | |
337 | } | |
338 | return 0; | |
339 | } | |
340 | ||
341 | #define bfd_elf32_bfd_reloc_type_lookup reloc_type_lookup | |
342 | #define ELF_ARCH bfd_arch_vax | |
343 | /* end code generated by elf.el */ | |
344 | ||
345 | #define USE_RELA | |
346 | \f | |
347 | /* Functions for the VAX ELF linker. */ | |
348 | ||
349 | /* The name of the dynamic interpreter. This is put in the .interp | |
350 | section. */ | |
351 | ||
352 | #define ELF_DYNAMIC_INTERPRETER "/usr/libexec/ld.elf_so" | |
353 | ||
354 | /* The size in bytes of an entry in the procedure linkage table. */ | |
355 | ||
356 | #define PLT_ENTRY_SIZE 12 | |
357 | ||
358 | /* The first entry in a procedure linkage table looks like this. See | |
359 | the SVR4 ABI VAX supplement to see how this works. */ | |
360 | ||
361 | static const bfd_byte elf_vax_plt0_entry[PLT_ENTRY_SIZE] = | |
362 | { | |
363 | 0xdd, 0xef, /* pushl l^ */ | |
364 | 0, 0, 0, 0, /* offset to .plt.got + 4 */ | |
365 | 0x17, 0xff, /* jmp @L^(pc) */ | |
366 | 0, 0, 0, 0, /* offset to .plt.got + 8 */ | |
367 | }; | |
368 | ||
369 | /* Subsequent entries in a procedure linkage table look like this. */ | |
370 | ||
371 | static const bfd_byte elf_vax_plt_entry[PLT_ENTRY_SIZE] = | |
372 | { | |
373 | 0x40, 0x00, /* .word ^M<r6> */ | |
374 | 0x16, 0xef, /* jsb L^(pc) */ | |
375 | 0, 0, 0, 0, /* replaced with offset to start of .plt */ | |
376 | 0, 0, 0, 0, /* index into .rela.plt */ | |
377 | }; | |
378 | ||
379 | /* The VAX linker needs to keep track of the number of relocs that it | |
380 | decides to copy in check_relocs for each symbol. This is so that it | |
381 | can discard PC relative relocs if it doesn't need them when linking | |
382 | with -Bsymbolic. We store the information in a field extending the | |
383 | regular ELF linker hash table. */ | |
384 | ||
385 | /* This structure keeps track of the number of PC relative relocs we have | |
386 | copied for a given symbol. */ | |
387 | ||
388 | struct elf_vax_pcrel_relocs_copied | |
389 | { | |
390 | /* Next section. */ | |
391 | struct elf_vax_pcrel_relocs_copied *next; | |
392 | /* A section in dynobj. */ | |
393 | asection *section; | |
394 | /* Number of relocs copied in this section. */ | |
395 | bfd_size_type count; | |
396 | }; | |
397 | ||
398 | /* VAX ELF linker hash entry. */ | |
399 | ||
400 | struct elf_vax_link_hash_entry | |
401 | { | |
402 | struct elf_link_hash_entry root; | |
403 | ||
404 | /* Number of PC relative relocs copied for this symbol. */ | |
405 | struct elf_vax_pcrel_relocs_copied *pcrel_relocs_copied; | |
406 | ||
407 | bfd_vma got_addend; | |
408 | }; | |
409 | ||
410 | /* VAX ELF linker hash table. */ | |
411 | ||
412 | struct elf_vax_link_hash_table | |
413 | { | |
414 | struct elf_link_hash_table root; | |
415 | }; | |
416 | ||
417 | /* Declare this now that the above structures are defined. */ | |
418 | ||
419 | static boolean elf_vax_discard_copies | |
420 | PARAMS ((struct elf_vax_link_hash_entry *, PTR)); | |
421 | ||
422 | /* Traverse an VAX ELF linker hash table. */ | |
423 | ||
424 | #define elf_vax_link_hash_traverse(table, func, info) \ | |
425 | (elf_link_hash_traverse \ | |
426 | (&(table)->root, \ | |
427 | (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \ | |
428 | (info))) | |
429 | ||
430 | /* Get the VAX ELF linker hash table from a link_info structure. */ | |
431 | ||
432 | #define elf_vax_hash_table(p) \ | |
433 | ((struct elf_vax_link_hash_table *) (p)->hash) | |
434 | ||
435 | /* Create an entry in an VAX ELF linker hash table. */ | |
436 | ||
437 | static struct bfd_hash_entry * | |
438 | elf_vax_link_hash_newfunc (entry, table, string) | |
439 | struct bfd_hash_entry *entry; | |
440 | struct bfd_hash_table *table; | |
441 | const char *string; | |
442 | { | |
443 | struct elf_vax_link_hash_entry *ret = | |
444 | (struct elf_vax_link_hash_entry *) entry; | |
445 | ||
446 | /* Allocate the structure if it has not already been allocated by a | |
447 | subclass. */ | |
448 | if (ret == (struct elf_vax_link_hash_entry *) NULL) | |
449 | ret = ((struct elf_vax_link_hash_entry *) | |
450 | bfd_hash_allocate (table, | |
451 | sizeof (struct elf_vax_link_hash_entry))); | |
452 | if (ret == (struct elf_vax_link_hash_entry *) NULL) | |
453 | return (struct bfd_hash_entry *) ret; | |
454 | ||
455 | /* Call the allocation method of the superclass. */ | |
456 | ret = ((struct elf_vax_link_hash_entry *) | |
457 | _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret, | |
458 | table, string)); | |
459 | if (ret != (struct elf_vax_link_hash_entry *) NULL) | |
460 | { | |
461 | ret->pcrel_relocs_copied = NULL; | |
462 | } | |
463 | ||
464 | return (struct bfd_hash_entry *) ret; | |
465 | } | |
466 | ||
467 | /* Create an VAX ELF linker hash table. */ | |
468 | ||
469 | static struct bfd_link_hash_table * | |
470 | elf_vax_link_hash_table_create (abfd) | |
471 | bfd *abfd; | |
472 | { | |
473 | struct elf_vax_link_hash_table *ret; | |
474 | bfd_size_type amt = sizeof (struct elf_vax_link_hash_table); | |
475 | ||
476 | ret = (struct elf_vax_link_hash_table *) bfd_malloc (amt); | |
477 | if (ret == (struct elf_vax_link_hash_table *) NULL) | |
478 | return NULL; | |
479 | ||
480 | if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, | |
481 | elf_vax_link_hash_newfunc)) | |
482 | { | |
483 | free (ret); | |
484 | return NULL; | |
485 | } | |
486 | ||
487 | return &ret->root.root; | |
488 | } | |
489 | ||
490 | /* Keep vax-specific flags in the ELF header */ | |
491 | static boolean | |
492 | elf32_vax_set_private_flags (abfd, flags) | |
493 | bfd *abfd; | |
494 | flagword flags; | |
495 | { | |
496 | elf_elfheader (abfd)->e_flags = flags; | |
497 | elf_flags_init (abfd) = true; | |
498 | return true; | |
499 | } | |
500 | ||
501 | /* Merge backend specific data from an object file to the output | |
502 | object file when linking. */ | |
503 | static boolean | |
504 | elf32_vax_merge_private_bfd_data (ibfd, obfd) | |
505 | bfd *ibfd; | |
506 | bfd *obfd; | |
507 | { | |
508 | flagword out_flags; | |
509 | flagword in_flags; | |
510 | ||
511 | if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour | |
512 | || bfd_get_flavour (obfd) != bfd_target_elf_flavour) | |
513 | return true; | |
514 | ||
515 | in_flags = elf_elfheader (ibfd)->e_flags; | |
516 | out_flags = elf_elfheader (obfd)->e_flags; | |
517 | ||
518 | if (!elf_flags_init (obfd)) | |
519 | { | |
520 | elf_flags_init (obfd) = true; | |
521 | elf_elfheader (obfd)->e_flags = in_flags; | |
522 | } | |
523 | ||
524 | return true; | |
525 | } | |
526 | ||
527 | /* Display the flags field */ | |
528 | static boolean | |
529 | elf32_vax_print_private_bfd_data (abfd, ptr) | |
530 | bfd *abfd; | |
531 | PTR ptr; | |
532 | { | |
533 | FILE *file = (FILE *) ptr; | |
534 | ||
535 | BFD_ASSERT (abfd != NULL && ptr != NULL); | |
536 | ||
537 | /* Print normal ELF private data. */ | |
538 | _bfd_elf_print_private_bfd_data (abfd, ptr); | |
539 | ||
540 | /* Ignore init flag - it may not be set, despite the flags field containing valid data. */ | |
541 | ||
542 | /* xgettext:c-format */ | |
543 | fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags); | |
544 | ||
179d3252 | 545 | if (elf_elfheader (abfd)->e_flags & EF_VAX_NONPIC) |
90ace9e9 JT |
546 | fprintf (file, _(" [nonpic]")); |
547 | ||
179d3252 | 548 | if (elf_elfheader (abfd)->e_flags & EF_VAX_DFLOAT) |
90ace9e9 JT |
549 | fprintf (file, _(" [d-float]")); |
550 | ||
179d3252 | 551 | if (elf_elfheader (abfd)->e_flags & EF_VAX_GFLOAT) |
90ace9e9 JT |
552 | fprintf (file, _(" [g-float]")); |
553 | ||
554 | fputc ('\n', file); | |
555 | ||
556 | return true; | |
557 | } | |
558 | /* Look through the relocs for a section during the first phase, and | |
559 | allocate space in the global offset table or procedure linkage | |
560 | table. */ | |
561 | ||
562 | static boolean | |
563 | elf_vax_check_relocs (abfd, info, sec, relocs) | |
564 | bfd *abfd; | |
565 | struct bfd_link_info *info; | |
566 | asection *sec; | |
567 | const Elf_Internal_Rela *relocs; | |
568 | { | |
569 | bfd *dynobj; | |
570 | Elf_Internal_Shdr *symtab_hdr; | |
571 | struct elf_link_hash_entry **sym_hashes; | |
572 | bfd_signed_vma *local_got_refcounts; | |
573 | const Elf_Internal_Rela *rel; | |
574 | const Elf_Internal_Rela *rel_end; | |
575 | asection *sgot; | |
576 | asection *srelgot; | |
577 | asection *sreloc; | |
578 | ||
579 | if (info->relocateable) | |
580 | return true; | |
581 | ||
582 | dynobj = elf_hash_table (info)->dynobj; | |
583 | symtab_hdr = &elf_tdata (abfd)->symtab_hdr; | |
584 | sym_hashes = elf_sym_hashes (abfd); | |
585 | local_got_refcounts = elf_local_got_refcounts (abfd); | |
586 | ||
587 | sgot = NULL; | |
588 | srelgot = NULL; | |
589 | sreloc = NULL; | |
590 | ||
591 | rel_end = relocs + sec->reloc_count; | |
592 | for (rel = relocs; rel < rel_end; rel++) | |
593 | { | |
594 | unsigned long r_symndx; | |
595 | struct elf_link_hash_entry *h; | |
596 | ||
597 | r_symndx = ELF32_R_SYM (rel->r_info); | |
598 | ||
599 | if (r_symndx < symtab_hdr->sh_info) | |
600 | h = NULL; | |
601 | else | |
602 | h = sym_hashes[r_symndx - symtab_hdr->sh_info]; | |
603 | ||
604 | switch (ELF32_R_TYPE (rel->r_info)) | |
605 | { | |
606 | case R_VAX_GOT32: | |
607 | if (h != NULL | |
608 | && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) | |
609 | break; | |
610 | ||
611 | /* This symbol requires a global offset table entry. */ | |
612 | ||
613 | if (dynobj == NULL) | |
614 | { | |
615 | /* Create the .got section. */ | |
616 | elf_hash_table (info)->dynobj = dynobj = abfd; | |
617 | if (!_bfd_elf_create_got_section (dynobj, info)) | |
618 | return false; | |
619 | } | |
620 | ||
621 | if (sgot == NULL) | |
622 | { | |
623 | sgot = bfd_get_section_by_name (dynobj, ".got"); | |
624 | BFD_ASSERT (sgot != NULL); | |
625 | } | |
626 | ||
627 | if (srelgot == NULL | |
628 | && (h != NULL || info->shared)) | |
629 | { | |
630 | srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); | |
631 | if (srelgot == NULL) | |
632 | { | |
633 | srelgot = bfd_make_section (dynobj, ".rela.got"); | |
634 | if (srelgot == NULL | |
635 | || !bfd_set_section_flags (dynobj, srelgot, | |
636 | (SEC_ALLOC | |
637 | | SEC_LOAD | |
638 | | SEC_HAS_CONTENTS | |
639 | | SEC_IN_MEMORY | |
640 | | SEC_LINKER_CREATED | |
641 | | SEC_READONLY)) | |
642 | || !bfd_set_section_alignment (dynobj, srelgot, 2)) | |
643 | return false; | |
644 | } | |
645 | } | |
646 | ||
647 | if (h != NULL) | |
648 | { | |
649 | struct elf_vax_link_hash_entry *eh; | |
650 | ||
651 | eh = (struct elf_vax_link_hash_entry *) h; | |
652 | if (h->got.refcount == -1) | |
653 | { | |
654 | h->got.refcount = 1; | |
655 | eh->got_addend = rel->r_addend; | |
656 | ||
657 | /* Make sure this symbol is output as a dynamic symbol. */ | |
658 | if (h->dynindx == -1) | |
659 | { | |
660 | if (!bfd_elf32_link_record_dynamic_symbol (info, h)) | |
661 | return false; | |
662 | } | |
663 | ||
664 | /* Allocate space in the .got section. */ | |
665 | sgot->_raw_size += 4; | |
666 | /* Allocate relocation space. */ | |
667 | srelgot->_raw_size += sizeof (Elf32_External_Rela); | |
668 | } | |
669 | else | |
670 | { | |
671 | h->got.refcount++; | |
672 | if (eh->got_addend != (bfd_vma) rel->r_addend) | |
673 | (*_bfd_error_handler) | |
674 | (_("%s: warning: GOT addend of %ld to `%s' does not match previous GOT addend of %ld"), | |
675 | bfd_get_filename (abfd), rel->r_addend, | |
676 | h->root.root.string, | |
677 | eh->got_addend); | |
cedb70c5 | 678 | |
90ace9e9 JT |
679 | } |
680 | } | |
681 | break; | |
682 | ||
683 | case R_VAX_PLT32: | |
684 | /* This symbol requires a procedure linkage table entry. We | |
685 | actually build the entry in adjust_dynamic_symbol, | |
686 | because this might be a case of linking PIC code which is | |
687 | never referenced by a dynamic object, in which case we | |
688 | don't need to generate a procedure linkage table entry | |
689 | after all. */ | |
690 | ||
691 | /* If this is a local symbol, we resolve it directly without | |
692 | creating a procedure linkage table entry. */ | |
693 | if (h == NULL) | |
694 | continue; | |
695 | ||
696 | h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; | |
697 | if (h->plt.refcount == -1) | |
698 | h->plt.refcount = 1; | |
699 | else | |
700 | h->plt.refcount++; | |
701 | break; | |
702 | ||
703 | case R_VAX_PC8: | |
704 | case R_VAX_PC16: | |
705 | case R_VAX_PC32: | |
706 | /* If we are creating a shared library and this is not a local | |
707 | symbol, we need to copy the reloc into the shared library. | |
708 | However when linking with -Bsymbolic and this is a global | |
709 | symbol which is defined in an object we are including in the | |
710 | link (i.e., DEF_REGULAR is set), then we can resolve the | |
711 | reloc directly. At this point we have not seen all the input | |
712 | files, so it is possible that DEF_REGULAR is not set now but | |
713 | will be set later (it is never cleared). We account for that | |
714 | possibility below by storing information in the | |
715 | pcrel_relocs_copied field of the hash table entry. */ | |
716 | if (!(info->shared | |
717 | && (sec->flags & SEC_ALLOC) != 0 | |
718 | && h != NULL | |
719 | && (!info->symbolic | |
720 | || (h->elf_link_hash_flags | |
721 | & ELF_LINK_HASH_DEF_REGULAR) == 0))) | |
722 | { | |
723 | if (h != NULL) | |
724 | { | |
725 | /* Make sure a plt entry is created for this symbol if | |
726 | it turns out to be a function defined by a dynamic | |
727 | object. */ | |
728 | if (h->plt.refcount == -1) | |
729 | h->plt.refcount = 1; | |
730 | else | |
731 | h->plt.refcount++; | |
732 | } | |
733 | break; | |
734 | } | |
735 | /* Fall through. */ | |
736 | case R_VAX_8: | |
737 | case R_VAX_16: | |
738 | case R_VAX_32: | |
739 | if (h != NULL) | |
740 | { | |
741 | /* Make sure a plt entry is created for this symbol if it | |
742 | turns out to be a function defined by a dynamic object. */ | |
743 | if (h->plt.refcount == -1) | |
744 | h->plt.refcount = 1; | |
745 | else | |
746 | h->plt.refcount++; | |
747 | } | |
748 | ||
749 | /* If we are creating a shared library, we need to copy the | |
750 | reloc into the shared library. */ | |
751 | if (info->shared | |
752 | && (sec->flags & SEC_ALLOC) != 0) | |
753 | { | |
754 | /* When creating a shared object, we must copy these | |
755 | reloc types into the output file. We create a reloc | |
756 | section in dynobj and make room for this reloc. */ | |
757 | if (sreloc == NULL) | |
758 | { | |
759 | const char *name; | |
760 | ||
761 | name = (bfd_elf_string_from_elf_section | |
762 | (abfd, | |
763 | elf_elfheader (abfd)->e_shstrndx, | |
764 | elf_section_data (sec)->rel_hdr.sh_name)); | |
765 | if (name == NULL) | |
766 | return false; | |
767 | ||
768 | BFD_ASSERT (strncmp (name, ".rela", 5) == 0 | |
769 | && strcmp (bfd_get_section_name (abfd, sec), | |
770 | name + 5) == 0); | |
771 | ||
772 | sreloc = bfd_get_section_by_name (dynobj, name); | |
773 | if (sreloc == NULL) | |
774 | { | |
775 | sreloc = bfd_make_section (dynobj, name); | |
776 | if (sreloc == NULL | |
777 | || !bfd_set_section_flags (dynobj, sreloc, | |
778 | (SEC_ALLOC | |
779 | | SEC_LOAD | |
780 | | SEC_HAS_CONTENTS | |
781 | | SEC_IN_MEMORY | |
782 | | SEC_LINKER_CREATED | |
783 | | SEC_READONLY)) | |
784 | || !bfd_set_section_alignment (dynobj, sreloc, 2)) | |
785 | return false; | |
786 | } | |
787 | if (sec->flags & SEC_READONLY) | |
788 | info->flags |= DF_TEXTREL; | |
789 | } | |
790 | ||
791 | sreloc->_raw_size += sizeof (Elf32_External_Rela); | |
792 | ||
793 | /* If we are linking with -Bsymbolic, we count the number of | |
794 | PC relative relocations we have entered for this symbol, | |
795 | so that we can discard them again if the symbol is later | |
796 | defined by a regular object. Note that this function is | |
797 | only called if we are using an vaxelf linker hash table, | |
798 | which means that h is really a pointer to an | |
799 | elf_vax_link_hash_entry. */ | |
800 | if ((ELF32_R_TYPE (rel->r_info) == R_VAX_PC8 | |
801 | || ELF32_R_TYPE (rel->r_info) == R_VAX_PC16 | |
802 | || ELF32_R_TYPE (rel->r_info) == R_VAX_PC32) | |
803 | && info->symbolic) | |
804 | { | |
805 | struct elf_vax_link_hash_entry *eh; | |
806 | struct elf_vax_pcrel_relocs_copied *p; | |
807 | ||
808 | eh = (struct elf_vax_link_hash_entry *) h; | |
809 | ||
810 | for (p = eh->pcrel_relocs_copied; p != NULL; p = p->next) | |
811 | if (p->section == sreloc) | |
812 | break; | |
813 | ||
814 | if (p == NULL) | |
815 | { | |
816 | p = ((struct elf_vax_pcrel_relocs_copied *) | |
817 | bfd_alloc (dynobj, (bfd_size_type) sizeof *p)); | |
818 | if (p == NULL) | |
819 | return false; | |
820 | p->next = eh->pcrel_relocs_copied; | |
821 | eh->pcrel_relocs_copied = p; | |
822 | p->section = sreloc; | |
823 | p->count = 0; | |
824 | } | |
825 | ||
826 | ++p->count; | |
827 | } | |
828 | } | |
829 | ||
830 | break; | |
831 | ||
832 | /* This relocation describes the C++ object vtable hierarchy. | |
833 | Reconstruct it for later use during GC. */ | |
834 | case R_VAX_GNU_VTINHERIT: | |
835 | if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) | |
836 | return false; | |
837 | break; | |
838 | ||
839 | /* This relocation describes which C++ vtable entries are actually | |
840 | used. Record for later use during GC. */ | |
841 | case R_VAX_GNU_VTENTRY: | |
842 | if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend)) | |
843 | return false; | |
844 | break; | |
845 | ||
846 | default: | |
847 | break; | |
848 | } | |
849 | } | |
850 | ||
851 | return true; | |
852 | } | |
853 | ||
854 | /* Return the section that should be marked against GC for a given | |
855 | relocation. */ | |
856 | ||
857 | static asection * | |
1e2f5b6e AM |
858 | elf_vax_gc_mark_hook (sec, info, rel, h, sym) |
859 | asection *sec; | |
90ace9e9 JT |
860 | struct bfd_link_info *info ATTRIBUTE_UNUSED; |
861 | Elf_Internal_Rela *rel; | |
862 | struct elf_link_hash_entry *h; | |
863 | Elf_Internal_Sym *sym; | |
864 | { | |
865 | if (h != NULL) | |
866 | { | |
867 | switch (ELF32_R_TYPE (rel->r_info)) | |
868 | { | |
869 | case R_VAX_GNU_VTINHERIT: | |
870 | case R_VAX_GNU_VTENTRY: | |
871 | break; | |
872 | ||
873 | default: | |
874 | switch (h->root.type) | |
875 | { | |
876 | default: | |
877 | break; | |
878 | ||
879 | case bfd_link_hash_defined: | |
880 | case bfd_link_hash_defweak: | |
881 | return h->root.u.def.section; | |
882 | ||
883 | case bfd_link_hash_common: | |
884 | return h->root.u.c.p->section; | |
885 | } | |
886 | } | |
887 | } | |
888 | else | |
1e2f5b6e | 889 | return bfd_section_from_elf_index (sec->owner, sym->st_shndx); |
90ace9e9 JT |
890 | |
891 | return NULL; | |
892 | } | |
893 | ||
894 | /* Update the got entry reference counts for the section being removed. */ | |
895 | ||
896 | static boolean | |
897 | elf_vax_gc_sweep_hook (abfd, info, sec, relocs) | |
898 | bfd *abfd; | |
899 | struct bfd_link_info *info; | |
900 | asection *sec; | |
901 | const Elf_Internal_Rela *relocs; | |
902 | { | |
903 | Elf_Internal_Shdr *symtab_hdr; | |
904 | struct elf_link_hash_entry **sym_hashes; | |
905 | bfd_signed_vma *local_got_refcounts; | |
906 | const Elf_Internal_Rela *rel, *relend; | |
907 | unsigned long r_symndx; | |
908 | struct elf_link_hash_entry *h; | |
909 | bfd *dynobj; | |
910 | asection *sgot; | |
911 | asection *srelgot; | |
912 | ||
913 | symtab_hdr = &elf_tdata (abfd)->symtab_hdr; | |
914 | sym_hashes = elf_sym_hashes (abfd); | |
915 | local_got_refcounts = elf_local_got_refcounts (abfd); | |
916 | ||
917 | dynobj = elf_hash_table (info)->dynobj; | |
918 | if (dynobj == NULL) | |
919 | return true; | |
920 | ||
921 | sgot = bfd_get_section_by_name (dynobj, ".got"); | |
922 | srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); | |
923 | ||
924 | relend = relocs + sec->reloc_count; | |
925 | for (rel = relocs; rel < relend; rel++) | |
926 | { | |
927 | switch (ELF32_R_TYPE (rel->r_info)) | |
928 | { | |
929 | case R_VAX_GOT32: | |
930 | r_symndx = ELF32_R_SYM (rel->r_info); | |
931 | if (r_symndx >= symtab_hdr->sh_info) | |
932 | { | |
933 | h = sym_hashes[r_symndx - symtab_hdr->sh_info]; | |
934 | if (h->got.refcount > 0) | |
935 | { | |
936 | --h->got.refcount; | |
937 | if (h->got.refcount == 0) | |
938 | { | |
939 | /* We don't need the .got entry any more. */ | |
940 | sgot->_raw_size -= 4; | |
941 | srelgot->_raw_size -= sizeof (Elf32_External_Rela); | |
942 | } | |
943 | } | |
944 | } | |
945 | else if (local_got_refcounts != NULL) | |
946 | { | |
947 | if (local_got_refcounts[r_symndx] > 0) | |
948 | { | |
949 | --local_got_refcounts[r_symndx]; | |
950 | if (local_got_refcounts[r_symndx] == 0) | |
951 | { | |
952 | /* We don't need the .got entry any more. */ | |
953 | sgot->_raw_size -= 4; | |
954 | if (info->shared) | |
955 | srelgot->_raw_size -= sizeof (Elf32_External_Rela); | |
956 | } | |
957 | } | |
958 | } | |
959 | break; | |
960 | ||
961 | case R_VAX_PLT32: | |
962 | case R_VAX_PC8: | |
963 | case R_VAX_PC16: | |
964 | case R_VAX_PC32: | |
965 | case R_VAX_8: | |
966 | case R_VAX_16: | |
967 | case R_VAX_32: | |
968 | r_symndx = ELF32_R_SYM (rel->r_info); | |
969 | if (r_symndx >= symtab_hdr->sh_info) | |
970 | { | |
971 | h = sym_hashes[r_symndx - symtab_hdr->sh_info]; | |
972 | if (h->plt.refcount > 0) | |
973 | --h->plt.refcount; | |
974 | } | |
975 | break; | |
976 | ||
977 | default: | |
978 | break; | |
979 | } | |
980 | } | |
981 | ||
982 | return true; | |
983 | } | |
984 | ||
985 | /* Adjust a symbol defined by a dynamic object and referenced by a | |
986 | regular object. The current definition is in some section of the | |
987 | dynamic object, but we're not including those sections. We have to | |
988 | change the definition to something the rest of the link can | |
989 | understand. */ | |
990 | ||
991 | static boolean | |
992 | elf_vax_adjust_dynamic_symbol (info, h) | |
993 | struct bfd_link_info *info; | |
994 | struct elf_link_hash_entry *h; | |
995 | { | |
996 | bfd *dynobj; | |
997 | asection *s; | |
998 | unsigned int power_of_two; | |
999 | ||
1000 | dynobj = elf_hash_table (info)->dynobj; | |
1001 | ||
1002 | /* Make sure we know what is going on here. */ | |
1003 | BFD_ASSERT (dynobj != NULL | |
1004 | && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) | |
1005 | || h->weakdef != NULL | |
1006 | || ((h->elf_link_hash_flags | |
1007 | & ELF_LINK_HASH_DEF_DYNAMIC) != 0 | |
1008 | && (h->elf_link_hash_flags | |
1009 | & ELF_LINK_HASH_REF_REGULAR) != 0 | |
1010 | && (h->elf_link_hash_flags | |
1011 | & ELF_LINK_HASH_DEF_REGULAR) == 0))); | |
1012 | ||
1013 | /* If this is a function, put it in the procedure linkage table. We | |
1014 | will fill in the contents of the procedure linkage table later, | |
1015 | when we know the address of the .got section. */ | |
1016 | if (h->type == STT_FUNC | |
1017 | || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0) | |
1018 | { | |
1019 | if (! info->shared | |
1020 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0 | |
1021 | && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0 | |
1022 | /* We must always create the plt entry if it was referenced | |
1023 | by a PLTxxO relocation. In this case we already recorded | |
1024 | it as a dynamic symbol. */ | |
1025 | && h->dynindx == -1) | |
1026 | { | |
1027 | /* This case can occur if we saw a PLTxx reloc in an input | |
1028 | file, but the symbol was never referred to by a dynamic | |
1029 | object. In such a case, we don't actually need to build | |
1030 | a procedure linkage table, and we can just do a PCxx | |
1031 | reloc instead. */ | |
1032 | BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0); | |
1033 | h->plt.offset = (bfd_vma) -1; | |
1034 | return true; | |
1035 | } | |
1036 | ||
1037 | /* GC may have rendered this entry unused. */ | |
1038 | if (h->plt.refcount <= 0) | |
1039 | { | |
1040 | h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; | |
1041 | h->plt.offset = (bfd_vma) -1; | |
1042 | return true; | |
1043 | } | |
1044 | ||
1045 | /* Make sure this symbol is output as a dynamic symbol. */ | |
1046 | if (h->dynindx == -1) | |
1047 | { | |
1048 | if (! bfd_elf32_link_record_dynamic_symbol (info, h)) | |
1049 | return false; | |
1050 | } | |
1051 | ||
1052 | s = bfd_get_section_by_name (dynobj, ".plt"); | |
1053 | BFD_ASSERT (s != NULL); | |
1054 | ||
1055 | /* If this is the first .plt entry, make room for the special | |
1056 | first entry. */ | |
1057 | if (s->_raw_size == 0) | |
1058 | { | |
1059 | s->_raw_size += PLT_ENTRY_SIZE; | |
1060 | } | |
1061 | ||
1062 | /* If this symbol is not defined in a regular file, and we are | |
1063 | not generating a shared library, then set the symbol to this | |
1064 | location in the .plt. This is required to make function | |
1065 | pointers compare as equal between the normal executable and | |
1066 | the shared library. */ | |
1067 | if (!info->shared | |
1068 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) | |
1069 | { | |
1070 | h->root.u.def.section = s; | |
1071 | h->root.u.def.value = s->_raw_size; | |
1072 | } | |
1073 | ||
1074 | h->plt.offset = s->_raw_size; | |
1075 | ||
1076 | /* Make room for this entry. */ | |
1077 | s->_raw_size += PLT_ENTRY_SIZE; | |
1078 | ||
1079 | /* We also need to make an entry in the .got.plt section, which | |
1080 | will be placed in the .got section by the linker script. */ | |
1081 | ||
1082 | s = bfd_get_section_by_name (dynobj, ".got.plt"); | |
1083 | BFD_ASSERT (s != NULL); | |
1084 | s->_raw_size += 4; | |
1085 | ||
1086 | /* We also need to make an entry in the .rela.plt section. */ | |
1087 | ||
1088 | s = bfd_get_section_by_name (dynobj, ".rela.plt"); | |
1089 | BFD_ASSERT (s != NULL); | |
1090 | s->_raw_size += sizeof (Elf32_External_Rela); | |
1091 | ||
1092 | return true; | |
1093 | } | |
1094 | ||
1095 | /* Reinitialize the plt offset now that it is not used as a reference | |
1096 | count any more. */ | |
1097 | h->plt.offset = (bfd_vma) -1; | |
1098 | ||
1099 | /* If this is a weak symbol, and there is a real definition, the | |
1100 | processor independent code will have arranged for us to see the | |
1101 | real definition first, and we can just use the same value. */ | |
1102 | if (h->weakdef != NULL) | |
1103 | { | |
1104 | BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined | |
1105 | || h->weakdef->root.type == bfd_link_hash_defweak); | |
1106 | h->root.u.def.section = h->weakdef->root.u.def.section; | |
1107 | h->root.u.def.value = h->weakdef->root.u.def.value; | |
1108 | return true; | |
1109 | } | |
1110 | ||
1111 | /* This is a reference to a symbol defined by a dynamic object which | |
1112 | is not a function. */ | |
1113 | ||
1114 | /* If we are creating a shared library, we must presume that the | |
1115 | only references to the symbol are via the global offset table. | |
1116 | For such cases we need not do anything here; the relocations will | |
1117 | be handled correctly by relocate_section. */ | |
1118 | if (info->shared) | |
1119 | return true; | |
1120 | ||
1121 | /* We must allocate the symbol in our .dynbss section, which will | |
1122 | become part of the .bss section of the executable. There will be | |
1123 | an entry for this symbol in the .dynsym section. The dynamic | |
1124 | object will contain position independent code, so all references | |
1125 | from the dynamic object to this symbol will go through the global | |
1126 | offset table. The dynamic linker will use the .dynsym entry to | |
1127 | determine the address it must put in the global offset table, so | |
1128 | both the dynamic object and the regular object will refer to the | |
1129 | same memory location for the variable. */ | |
1130 | ||
1131 | s = bfd_get_section_by_name (dynobj, ".dynbss"); | |
1132 | BFD_ASSERT (s != NULL); | |
1133 | ||
1134 | /* We must generate a R_VAX_COPY reloc to tell the dynamic linker to | |
1135 | copy the initial value out of the dynamic object and into the | |
1136 | runtime process image. We need to remember the offset into the | |
1137 | .rela.bss section we are going to use. */ | |
1138 | if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) | |
1139 | { | |
1140 | asection *srel; | |
1141 | ||
1142 | srel = bfd_get_section_by_name (dynobj, ".rela.bss"); | |
1143 | BFD_ASSERT (srel != NULL); | |
1144 | srel->_raw_size += sizeof (Elf32_External_Rela); | |
1145 | h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; | |
1146 | } | |
1147 | ||
1148 | /* We need to figure out the alignment required for this symbol. I | |
1149 | have no idea how ELF linkers handle this. */ | |
1150 | power_of_two = bfd_log2 (h->size); | |
1151 | if (power_of_two > 3) | |
1152 | power_of_two = 3; | |
1153 | ||
1154 | /* Apply the required alignment. */ | |
1155 | s->_raw_size = BFD_ALIGN (s->_raw_size, | |
1156 | (bfd_size_type) (1 << power_of_two)); | |
1157 | if (power_of_two > bfd_get_section_alignment (dynobj, s)) | |
1158 | { | |
1159 | if (!bfd_set_section_alignment (dynobj, s, power_of_two)) | |
1160 | return false; | |
1161 | } | |
1162 | ||
1163 | /* Define the symbol as being at this point in the section. */ | |
1164 | h->root.u.def.section = s; | |
1165 | h->root.u.def.value = s->_raw_size; | |
1166 | ||
1167 | /* Increment the section size to make room for the symbol. */ | |
1168 | s->_raw_size += h->size; | |
1169 | ||
1170 | return true; | |
1171 | } | |
1172 | ||
1173 | /* Set the sizes of the dynamic sections. */ | |
1174 | ||
1175 | static boolean | |
1176 | elf_vax_size_dynamic_sections (output_bfd, info) | |
1177 | bfd *output_bfd; | |
1178 | struct bfd_link_info *info; | |
1179 | { | |
1180 | bfd *dynobj; | |
1181 | asection *s; | |
1182 | boolean plt; | |
1183 | boolean relocs; | |
1184 | boolean reltext; | |
1185 | ||
1186 | dynobj = elf_hash_table (info)->dynobj; | |
1187 | BFD_ASSERT (dynobj != NULL); | |
1188 | ||
1189 | if (elf_hash_table (info)->dynamic_sections_created) | |
1190 | { | |
1191 | /* Set the contents of the .interp section to the interpreter. */ | |
1192 | if (!info->shared) | |
1193 | { | |
1194 | s = bfd_get_section_by_name (dynobj, ".interp"); | |
1195 | BFD_ASSERT (s != NULL); | |
1196 | s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER; | |
1197 | s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; | |
1198 | } | |
1199 | } | |
1200 | else | |
1201 | { | |
1202 | /* We may have created entries in the .rela.got and .got sections. | |
1203 | However, if we are not creating the dynamic sections, we will | |
1204 | not actually use these entries. Reset the size of .rela.got | |
1205 | and .got, which will cause it to get stripped from the output | |
1206 | file below. */ | |
1207 | s = bfd_get_section_by_name (dynobj, ".rela.got"); | |
1208 | if (s != NULL) | |
1209 | s->_raw_size = 0; | |
1210 | s = bfd_get_section_by_name (dynobj, ".got.plt"); | |
1211 | if (s != NULL) | |
1212 | s->_raw_size = 0; | |
1213 | s = bfd_get_section_by_name (dynobj, ".got"); | |
1214 | if (s != NULL) | |
1215 | s->_raw_size = 0; | |
1216 | } | |
1217 | ||
1218 | /* If this is a -Bsymbolic shared link, then we need to discard all PC | |
1219 | relative relocs against symbols defined in a regular object. We | |
1220 | allocated space for them in the check_relocs routine, but we will not | |
1221 | fill them in in the relocate_section routine. */ | |
1222 | if (info->shared && info->symbolic) | |
1223 | elf_vax_link_hash_traverse (elf_vax_hash_table (info), | |
1224 | elf_vax_discard_copies, | |
1225 | (PTR) NULL); | |
1226 | ||
1227 | /* The check_relocs and adjust_dynamic_symbol entry points have | |
1228 | determined the sizes of the various dynamic sections. Allocate | |
1229 | memory for them. */ | |
1230 | plt = false; | |
1231 | relocs = false; | |
1232 | reltext = false; | |
1233 | for (s = dynobj->sections; s != NULL; s = s->next) | |
1234 | { | |
1235 | const char *name; | |
1236 | boolean strip; | |
1237 | ||
1238 | if ((s->flags & SEC_LINKER_CREATED) == 0) | |
1239 | continue; | |
1240 | ||
1241 | /* It's OK to base decisions on the section name, because none | |
1242 | of the dynobj section names depend upon the input files. */ | |
1243 | name = bfd_get_section_name (dynobj, s); | |
1244 | ||
1245 | strip = false; | |
1246 | ||
1247 | if (strcmp (name, ".plt") == 0) | |
1248 | { | |
1249 | if (s->_raw_size == 0) | |
1250 | { | |
1251 | /* Strip this section if we don't need it; see the | |
1252 | comment below. */ | |
1253 | strip = true; | |
1254 | } | |
1255 | else | |
1256 | { | |
1257 | /* Remember whether there is a PLT. */ | |
1258 | plt = true; | |
1259 | } | |
1260 | } | |
1261 | else if (strncmp (name, ".rela", 5) == 0) | |
1262 | { | |
1263 | if (s->_raw_size == 0) | |
1264 | { | |
1265 | /* If we don't need this section, strip it from the | |
1266 | output file. This is mostly to handle .rela.bss and | |
1267 | .rela.plt. We must create both sections in | |
1268 | create_dynamic_sections, because they must be created | |
1269 | before the linker maps input sections to output | |
1270 | sections. The linker does that before | |
1271 | adjust_dynamic_symbol is called, and it is that | |
1272 | function which decides whether anything needs to go | |
1273 | into these sections. */ | |
1274 | strip = true; | |
1275 | } | |
1276 | else | |
1277 | { | |
1278 | asection *target; | |
1279 | ||
1280 | /* Remember whether there are any reloc sections other | |
1281 | than .rela.plt. */ | |
1282 | if (strcmp (name, ".rela.plt") != 0) | |
1283 | { | |
1284 | const char *outname; | |
1285 | ||
1286 | relocs = true; | |
1287 | ||
1288 | /* If this relocation section applies to a read only | |
1289 | section, then we probably need a DT_TEXTREL | |
1290 | entry. .rela.plt is actually associated with | |
1291 | .got.plt, which is never readonly. */ | |
1292 | outname = bfd_get_section_name (output_bfd, | |
1293 | s->output_section); | |
1294 | target = bfd_get_section_by_name (output_bfd, outname + 5); | |
1295 | if (target != NULL | |
1296 | && (target->flags & SEC_READONLY) != 0 | |
1297 | && (target->flags & SEC_ALLOC) != 0) | |
1298 | reltext = true; | |
1299 | } | |
1300 | ||
1301 | /* We use the reloc_count field as a counter if we need | |
1302 | to copy relocs into the output file. */ | |
1303 | s->reloc_count = 0; | |
1304 | } | |
1305 | } | |
1306 | else if (strncmp (name, ".got", 4) != 0) | |
1307 | { | |
1308 | /* It's not one of our sections, so don't allocate space. */ | |
1309 | continue; | |
1310 | } | |
1311 | ||
1312 | if (strip) | |
1313 | { | |
1314 | _bfd_strip_section_from_output (info, s); | |
1315 | continue; | |
1316 | } | |
1317 | ||
1318 | /* Allocate memory for the section contents. */ | |
1319 | s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size); | |
1320 | if (s->contents == NULL && s->_raw_size != 0) | |
1321 | return false; | |
1322 | } | |
1323 | ||
1324 | if (elf_hash_table (info)->dynamic_sections_created) | |
1325 | { | |
1326 | /* Add some entries to the .dynamic section. We fill in the | |
1327 | values later, in elf_vax_finish_dynamic_sections, but we | |
1328 | must add the entries now so that we get the correct size for | |
1329 | the .dynamic section. The DT_DEBUG entry is filled in by the | |
1330 | dynamic linker and used by the debugger. */ | |
1331 | #define add_dynamic_entry(TAG, VAL) \ | |
1332 | bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) | |
1333 | ||
1334 | if (!info->shared) | |
1335 | { | |
1336 | if (!add_dynamic_entry (DT_DEBUG, 0)) | |
1337 | return false; | |
1338 | } | |
1339 | ||
1340 | if (plt) | |
1341 | { | |
1342 | if (!add_dynamic_entry (DT_PLTGOT, 0) | |
1343 | || !add_dynamic_entry (DT_PLTRELSZ, 0) | |
1344 | || !add_dynamic_entry (DT_PLTREL, DT_RELA) | |
1345 | || !add_dynamic_entry (DT_JMPREL, 0)) | |
1346 | return false; | |
1347 | } | |
1348 | ||
1349 | if (relocs) | |
1350 | { | |
1351 | if (!add_dynamic_entry (DT_RELA, 0) | |
1352 | || !add_dynamic_entry (DT_RELASZ, 0) | |
1353 | || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela))) | |
1354 | return false; | |
1355 | } | |
1356 | ||
1357 | if (reltext || (info->flags & DF_TEXTREL) != 0) | |
1358 | { | |
1359 | if (!add_dynamic_entry (DT_TEXTREL, 0)) | |
1360 | return false; | |
1361 | } | |
1362 | } | |
1363 | #undef add_dynamic_entry | |
1364 | ||
1365 | return true; | |
1366 | } | |
1367 | ||
1368 | /* This function is called via elf_vax_link_hash_traverse if we are | |
1369 | creating a shared object with -Bsymbolic. It discards the space | |
1370 | allocated to copy PC relative relocs against symbols which are defined | |
1371 | in regular objects. We allocated space for them in the check_relocs | |
1372 | routine, but we won't fill them in in the relocate_section routine. */ | |
1373 | ||
1374 | /*ARGSUSED*/ | |
1375 | static boolean | |
1376 | elf_vax_discard_copies (h, ignore) | |
1377 | struct elf_vax_link_hash_entry *h; | |
1378 | PTR ignore ATTRIBUTE_UNUSED; | |
1379 | { | |
1380 | struct elf_vax_pcrel_relocs_copied *s; | |
1381 | ||
1382 | if (h->root.root.type == bfd_link_hash_warning) | |
1383 | h = (struct elf_vax_link_hash_entry *) h->root.root.u.i.link; | |
1384 | ||
1385 | /* We only discard relocs for symbols defined in a regular object. */ | |
1386 | if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) | |
1387 | return true; | |
1388 | ||
1389 | for (s = h->pcrel_relocs_copied; s != NULL; s = s->next) | |
1390 | s->section->_raw_size -= s->count * sizeof (Elf32_External_Rela); | |
1391 | ||
1392 | return true; | |
1393 | } | |
1394 | ||
1395 | /* Relocate an VAX ELF section. */ | |
1396 | ||
1397 | static boolean | |
1398 | elf_vax_relocate_section (output_bfd, info, input_bfd, input_section, | |
1399 | contents, relocs, local_syms, local_sections) | |
1400 | bfd *output_bfd; | |
1401 | struct bfd_link_info *info; | |
1402 | bfd *input_bfd; | |
1403 | asection *input_section; | |
1404 | bfd_byte *contents; | |
1405 | Elf_Internal_Rela *relocs; | |
1406 | Elf_Internal_Sym *local_syms; | |
1407 | asection **local_sections; | |
1408 | { | |
1409 | bfd *dynobj; | |
1410 | Elf_Internal_Shdr *symtab_hdr; | |
1411 | struct elf_link_hash_entry **sym_hashes; | |
1412 | bfd_vma *local_got_offsets; | |
1413 | bfd_vma plt_index; | |
1414 | bfd_vma got_offset; | |
1415 | asection *sgot; | |
1416 | asection *splt; | |
1417 | asection *sgotplt; | |
1418 | asection *sreloc; | |
1419 | Elf_Internal_Rela *rel; | |
1420 | Elf_Internal_Rela *relend; | |
1421 | ||
1422 | dynobj = elf_hash_table (info)->dynobj; | |
1423 | symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; | |
1424 | sym_hashes = elf_sym_hashes (input_bfd); | |
1425 | local_got_offsets = elf_local_got_offsets (input_bfd); | |
1426 | ||
1427 | sgot = NULL; | |
1428 | splt = NULL; | |
1429 | sgotplt = NULL; | |
1430 | sreloc = NULL; | |
1431 | ||
1432 | rel = relocs; | |
1433 | relend = relocs + input_section->reloc_count; | |
1434 | for (; rel < relend; rel++) | |
1435 | { | |
1436 | int r_type; | |
1437 | reloc_howto_type *howto; | |
1438 | unsigned long r_symndx; | |
1439 | struct elf_link_hash_entry *h; | |
1440 | Elf_Internal_Sym *sym; | |
1441 | asection *sec; | |
1442 | bfd_vma relocation; | |
1443 | bfd_reloc_status_type r; | |
1444 | ||
1445 | r_type = ELF32_R_TYPE (rel->r_info); | |
1446 | if (r_type < 0 || r_type >= (int) R_VAX_max) | |
1447 | { | |
1448 | bfd_set_error (bfd_error_bad_value); | |
1449 | return false; | |
1450 | } | |
1451 | howto = howto_table + r_type; | |
1452 | ||
1453 | r_symndx = ELF32_R_SYM (rel->r_info); | |
1454 | ||
1455 | if (info->relocateable) | |
1456 | { | |
1457 | /* This is a relocateable link. We don't have to change | |
1458 | anything, unless the reloc is against a section symbol, | |
1459 | in which case we have to adjust according to where the | |
1460 | section symbol winds up in the output section. */ | |
1461 | if (r_symndx < symtab_hdr->sh_info) | |
1462 | { | |
1463 | sym = local_syms + r_symndx; | |
1464 | if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) | |
1465 | { | |
1466 | sec = local_sections[r_symndx]; | |
1467 | rel->r_addend += sec->output_offset + sym->st_value; | |
1468 | } | |
1469 | } | |
1470 | ||
1471 | continue; | |
1472 | } | |
1473 | ||
1474 | /* This is a final link. */ | |
1475 | h = NULL; | |
1476 | sym = NULL; | |
1477 | sec = NULL; | |
1478 | if (r_symndx < symtab_hdr->sh_info) | |
1479 | { | |
1480 | sym = local_syms + r_symndx; | |
1481 | sec = local_sections[r_symndx]; | |
1482 | relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); | |
1483 | } | |
1484 | else | |
1485 | { | |
1486 | h = sym_hashes[r_symndx - symtab_hdr->sh_info]; | |
1487 | while (h->root.type == bfd_link_hash_indirect | |
1488 | || h->root.type == bfd_link_hash_warning) | |
1489 | h = (struct elf_link_hash_entry *) h->root.u.i.link; | |
1490 | if (h->root.type == bfd_link_hash_defined | |
1491 | || h->root.type == bfd_link_hash_defweak) | |
1492 | { | |
1493 | sec = h->root.u.def.section; | |
1494 | if ((r_type == R_VAX_PLT32 | |
1495 | && h->plt.offset != (bfd_vma) -1 | |
1496 | && elf_hash_table (info)->dynamic_sections_created) | |
1497 | || (r_type == R_VAX_GOT32 | |
1498 | && strcmp (h->root.root.string, | |
1499 | "_GLOBAL_OFFSET_TABLE_") != 0 | |
1500 | && elf_hash_table (info)->dynamic_sections_created | |
1501 | && (! info->shared | |
1502 | || (! info->symbolic && h->dynindx != -1) | |
1503 | || (h->elf_link_hash_flags | |
1504 | & ELF_LINK_HASH_DEF_REGULAR) == 0)) | |
1505 | || (info->shared | |
1506 | && ((! info->symbolic && h->dynindx != -1) | |
1507 | || (h->elf_link_hash_flags | |
1508 | & ELF_LINK_HASH_DEF_REGULAR) == 0) | |
1509 | && ((input_section->flags & SEC_ALLOC) != 0 | |
1510 | /* DWARF will emit R_VAX_32 relocations in its | |
1511 | sections against symbols defined externally | |
1512 | in shared libraries. We can't do anything | |
1513 | with them here. */ | |
1514 | ||
1515 | || ((input_section->flags & SEC_DEBUGGING) != 0 | |
1516 | && (h->elf_link_hash_flags | |
1517 | & ELF_LINK_HASH_DEF_DYNAMIC) != 0)) | |
1518 | && (r_type == R_VAX_8 | |
1519 | || r_type == R_VAX_16 | |
1520 | || r_type == R_VAX_32 | |
1521 | || r_type == R_VAX_PC8 | |
1522 | || r_type == R_VAX_PC16 | |
1523 | || r_type == R_VAX_PC32))) | |
1524 | { | |
1525 | /* In these cases, we don't need the relocation | |
1526 | value. We check specially because in some | |
1527 | obscure cases sec->output_section will be NULL. */ | |
1528 | relocation = 0; | |
1529 | } | |
1530 | else | |
1531 | relocation = (h->root.u.def.value | |
1532 | + sec->output_section->vma | |
1533 | + sec->output_offset); | |
1534 | } | |
1535 | else if (h->root.type == bfd_link_hash_undefweak) | |
1536 | relocation = 0; | |
1537 | else if (info->shared | |
1538 | && (!info->symbolic || info->allow_shlib_undefined) | |
1539 | && !info->no_undefined | |
1540 | && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) | |
1541 | relocation = 0; | |
1542 | else | |
1543 | { | |
1544 | if (!(info->callbacks->undefined_symbol | |
1545 | (info, h->root.root.string, input_bfd, | |
1546 | input_section, rel->r_offset, | |
1547 | (!info->shared || info->no_undefined | |
1548 | || ELF_ST_VISIBILITY (h->other))))) | |
1549 | return false; | |
1550 | relocation = 0; | |
1551 | } | |
1552 | } | |
1553 | ||
1554 | switch (r_type) | |
1555 | { | |
1556 | case R_VAX_GOT32: | |
1557 | /* Relocation is to the address of the entry for this symbol | |
1558 | in the global offset table. */ | |
1559 | if (h != NULL | |
1560 | && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) | |
1561 | break; | |
1562 | ||
1563 | /* Relocation is the offset of the entry for this symbol in | |
1564 | the global offset table. */ | |
1565 | ||
1566 | { | |
1567 | bfd_vma off; | |
1568 | ||
1569 | if (!elf_hash_table (info)->dynamic_sections_created | |
1570 | || (h == NULL) | |
1571 | || (info->shared | |
1572 | && info->symbolic | |
1573 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))) | |
1574 | { | |
1575 | /* This is actually a static link, or it is a -Bsymbolic link | |
1576 | and the symbol is defined locally or there is no symbol. | |
cedb70c5 | 1577 | Change the GOT32 entry to a PC32 entry. */ |
90ace9e9 JT |
1578 | break; |
1579 | } | |
1580 | ||
1581 | if (sgot == NULL) | |
1582 | { | |
1583 | sgot = bfd_get_section_by_name (dynobj, ".got"); | |
1584 | BFD_ASSERT (sgot != NULL); | |
1585 | } | |
1586 | ||
1587 | BFD_ASSERT (h != NULL); | |
1588 | off = h->got.offset; | |
1589 | BFD_ASSERT (off != (bfd_vma) -1); | |
1590 | ||
1591 | if (info->shared | |
1592 | && h->dynindx == -1 | |
1593 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)) | |
1594 | { | |
1595 | /* The symbol was forced to be local | |
1596 | because of a version file.. We must initialize | |
1597 | this entry in the global offset table. Since | |
1598 | the offset must always be a multiple of 4, we | |
1599 | use the least significant bit to record whether | |
1600 | we have initialized it already. | |
1601 | ||
1602 | When doing a dynamic link, we create a .rela.got | |
1603 | relocation entry to initialize the value. This | |
1604 | is done in the finish_dynamic_symbol routine. */ | |
1605 | if ((off & 1) != 0) | |
1606 | off &= ~1; | |
1607 | else | |
1608 | { | |
1609 | bfd_put_32 (output_bfd, relocation + rel->r_addend, | |
1610 | sgot->contents + off); | |
1611 | h->got.offset |= 1; | |
1612 | } | |
1613 | } else { | |
1614 | bfd_put_32 (output_bfd, rel->r_addend, sgot->contents + off); | |
1615 | } | |
1616 | ||
1617 | relocation = sgot->output_offset + off; | |
1618 | /* Neither GOT relocation uses the addend. */ | |
1619 | rel->r_addend = 0; | |
1620 | ||
1621 | if (r_type == R_VAX_GOT32) | |
1622 | { | |
1623 | /* Change the reference to be indirect */ | |
1624 | contents[rel->r_offset - 1] |= 0x10; | |
1625 | relocation += sgot->output_section->vma; | |
1626 | } | |
1627 | } | |
1628 | break; | |
1629 | ||
1630 | case R_VAX_PLT32: | |
1631 | /* Relocation is to the entry for this symbol in the | |
1632 | procedure linkage table. */ | |
1633 | ||
1634 | /* Resolve a PLTxx reloc against a local symbol directly, | |
1635 | without using the procedure linkage table. */ | |
1636 | if (h == NULL) | |
1637 | break; | |
1638 | ||
1639 | if (h->plt.offset == (bfd_vma) -1 | |
1640 | || !elf_hash_table (info)->dynamic_sections_created) | |
1641 | { | |
1642 | /* We didn't make a PLT entry for this symbol. This | |
1643 | happens when statically linking PIC code, or when | |
1644 | using -Bsymbolic. */ | |
1645 | break; | |
1646 | } | |
1647 | ||
1648 | if (splt == NULL) | |
1649 | { | |
1650 | splt = bfd_get_section_by_name (dynobj, ".plt"); | |
1651 | BFD_ASSERT (splt != NULL); | |
1652 | } | |
1653 | ||
1654 | if (sgotplt == NULL) | |
1655 | { | |
1656 | sgotplt = bfd_get_section_by_name (dynobj, ".got.plt"); | |
1657 | BFD_ASSERT (splt != NULL); | |
1658 | } | |
1659 | ||
1660 | plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1; | |
1661 | ||
1662 | /* Get the offset into the .got table of the entry that | |
1663 | corresponds to this function. Each .got entry is 4 bytes. | |
1664 | The first two are reserved. */ | |
1665 | got_offset = (plt_index + 3) * 4; | |
1666 | ||
1667 | /* We want the relocate to point into the .got.plt instead | |
cedb70c5 | 1668 | of the plt itself. */ |
90ace9e9 JT |
1669 | relocation = (sgotplt->output_section->vma |
1670 | + sgotplt->output_offset | |
1671 | + got_offset); | |
1672 | contents[rel->r_offset-1] |= 0x10; /* make indirect */ | |
1673 | if (rel->r_addend == 2) | |
1674 | { | |
1675 | h->plt.offset |= 1; | |
1676 | } | |
1677 | else if (rel->r_addend != 0) | |
1678 | (*_bfd_error_handler) | |
1679 | (_("%s: warning: PLT addend of %d to `%s' from %s section ignored"), | |
1680 | bfd_get_filename (input_bfd), rel->r_addend, | |
1681 | h->root.root.string, | |
1682 | bfd_get_section_name (input_bfd, input_section)); | |
1683 | rel->r_addend = 0; | |
1684 | ||
1685 | break; | |
1686 | ||
1687 | case R_VAX_PC8: | |
1688 | case R_VAX_PC16: | |
1689 | case R_VAX_PC32: | |
1690 | if (h == NULL) | |
1691 | break; | |
1692 | /* Fall through. */ | |
1693 | case R_VAX_8: | |
1694 | case R_VAX_16: | |
1695 | case R_VAX_32: | |
1696 | if (info->shared | |
1697 | && r_symndx != 0 | |
1698 | && (input_section->flags & SEC_ALLOC) != 0 | |
1699 | && ((r_type != R_VAX_PC8 | |
1700 | && r_type != R_VAX_PC16 | |
1701 | && r_type != R_VAX_PC32) | |
1702 | || (!info->symbolic | |
1703 | || (h->elf_link_hash_flags | |
1704 | & ELF_LINK_HASH_DEF_REGULAR) == 0))) | |
1705 | { | |
1706 | Elf_Internal_Rela outrel; | |
1707 | boolean skip, relocate; | |
1708 | ||
1709 | /* When generating a shared object, these relocations | |
1710 | are copied into the output file to be resolved at run | |
1711 | time. */ | |
1712 | ||
1713 | if (sreloc == NULL) | |
1714 | { | |
1715 | const char *name; | |
1716 | ||
1717 | name = (bfd_elf_string_from_elf_section | |
1718 | (input_bfd, | |
1719 | elf_elfheader (input_bfd)->e_shstrndx, | |
1720 | elf_section_data (input_section)->rel_hdr.sh_name)); | |
1721 | if (name == NULL) | |
1722 | return false; | |
1723 | ||
1724 | BFD_ASSERT (strncmp (name, ".rela", 5) == 0 | |
1725 | && strcmp (bfd_get_section_name (input_bfd, | |
1726 | input_section), | |
1727 | name + 5) == 0); | |
1728 | ||
1729 | sreloc = bfd_get_section_by_name (dynobj, name); | |
1730 | BFD_ASSERT (sreloc != NULL); | |
1731 | } | |
1732 | ||
1733 | skip = false; | |
1734 | relocate = false; | |
1735 | ||
1736 | outrel.r_offset = | |
1737 | _bfd_elf_section_offset (output_bfd, info, input_section, | |
1738 | rel->r_offset); | |
1739 | if (outrel.r_offset == (bfd_vma) -1) | |
1740 | skip = true; | |
1741 | if (outrel.r_offset == (bfd_vma) -2) | |
1742 | skip = true, relocate = true; | |
1743 | outrel.r_offset += (input_section->output_section->vma | |
1744 | + input_section->output_offset); | |
1745 | ||
1746 | if (skip) | |
1747 | memset (&outrel, 0, sizeof outrel); | |
1748 | /* h->dynindx may be -1 if the symbol was marked to | |
1749 | become local. */ | |
1750 | else if (h != NULL | |
1751 | && ((! info->symbolic && h->dynindx != -1) | |
1752 | || (h->elf_link_hash_flags | |
1753 | & ELF_LINK_HASH_DEF_REGULAR) == 0)) | |
1754 | { | |
1755 | BFD_ASSERT (h->dynindx != -1); | |
1756 | outrel.r_info = ELF32_R_INFO (h->dynindx, r_type); | |
1757 | outrel.r_addend = relocation + rel->r_addend; | |
1758 | } | |
1759 | else | |
1760 | { | |
1761 | if (r_type == R_VAX_32) | |
1762 | { | |
1763 | relocate = true; | |
1764 | outrel.r_info = ELF32_R_INFO (0, R_VAX_RELATIVE); | |
1765 | BFD_ASSERT (bfd_get_signed_32 (input_bfd, | |
1766 | &contents[rel->r_offset]) == 0); | |
1767 | outrel.r_addend = relocation + rel->r_addend; | |
1768 | } | |
1769 | else | |
1770 | { | |
1771 | long indx; | |
1772 | ||
1773 | if (h == NULL) | |
1774 | sec = local_sections[r_symndx]; | |
1775 | else | |
1776 | { | |
1777 | BFD_ASSERT (h->root.type == bfd_link_hash_defined | |
1778 | || (h->root.type | |
1779 | == bfd_link_hash_defweak)); | |
1780 | sec = h->root.u.def.section; | |
1781 | } | |
1782 | if (sec != NULL && bfd_is_abs_section (sec)) | |
1783 | indx = 0; | |
1784 | else if (sec == NULL || sec->owner == NULL) | |
1785 | { | |
1786 | bfd_set_error (bfd_error_bad_value); | |
1787 | return false; | |
1788 | } | |
1789 | else | |
1790 | { | |
1791 | asection *osec; | |
1792 | ||
1793 | osec = sec->output_section; | |
1794 | indx = elf_section_data (osec)->dynindx; | |
1795 | BFD_ASSERT (indx > 0); | |
1796 | } | |
1797 | ||
1798 | outrel.r_info = ELF32_R_INFO (indx, r_type); | |
1799 | outrel.r_addend = relocation + rel->r_addend; | |
1800 | } | |
1801 | } | |
1802 | ||
1803 | if (!strcmp (bfd_get_section_name (input_bfd, input_section), | |
cedb70c5 | 1804 | ".text") != 0 || |
90ace9e9 JT |
1805 | (info->shared |
1806 | && ELF32_R_TYPE(outrel.r_info) != R_VAX_32 | |
1807 | && ELF32_R_TYPE(outrel.r_info) != R_VAX_RELATIVE | |
1808 | && ELF32_R_TYPE(outrel.r_info) != R_VAX_COPY | |
1809 | && ELF32_R_TYPE(outrel.r_info) != R_VAX_JMP_SLOT | |
1810 | && ELF32_R_TYPE(outrel.r_info) != R_VAX_GLOB_DAT)) | |
1811 | { | |
1812 | if (h != NULL) | |
1813 | (*_bfd_error_handler) | |
1814 | (_("%s: warning: %s relocation against symbol `%s' from %s section"), | |
1815 | bfd_get_filename (input_bfd), howto->name, | |
1816 | h->root.root.string, | |
1817 | bfd_get_section_name (input_bfd, input_section)); | |
1818 | else | |
1819 | (*_bfd_error_handler) | |
1820 | (_("%s: warning: %s relocation to 0x%x from %s section"), | |
1821 | bfd_get_filename (input_bfd), howto->name, | |
1822 | outrel.r_addend, | |
1823 | bfd_get_section_name (input_bfd, input_section)); | |
1824 | } | |
1825 | bfd_elf32_swap_reloca_out (output_bfd, &outrel, | |
1826 | (((Elf32_External_Rela *) | |
1827 | sreloc->contents) | |
1828 | + sreloc->reloc_count)); | |
1829 | ++sreloc->reloc_count; | |
1830 | ||
1831 | /* This reloc will be computed at runtime, so there's no | |
1832 | need to do anything now, except for R_VAX_32 | |
1833 | relocations that have been turned into | |
1834 | R_VAX_RELATIVE. */ | |
1835 | if (!relocate) | |
1836 | continue; | |
1837 | } | |
1838 | ||
1839 | break; | |
1840 | ||
1841 | case R_VAX_GNU_VTINHERIT: | |
1842 | case R_VAX_GNU_VTENTRY: | |
1843 | /* These are no-ops in the end. */ | |
1844 | continue; | |
1845 | ||
1846 | default: | |
1847 | break; | |
1848 | } | |
1849 | ||
1850 | /* VAX PCREL relocations are from the end of relocation, not the start */ | |
1851 | if (howto->pc_relative && howto->pcrel_offset) | |
1852 | { | |
1853 | relocation -= bfd_get_reloc_size(howto); | |
1854 | } | |
1855 | ||
1856 | r = _bfd_final_link_relocate (howto, input_bfd, input_section, | |
1857 | contents, rel->r_offset, | |
1858 | relocation, rel->r_addend); | |
1859 | ||
1860 | if (r != bfd_reloc_ok) | |
1861 | { | |
1862 | switch (r) | |
1863 | { | |
1864 | default: | |
1865 | case bfd_reloc_outofrange: | |
1866 | abort (); | |
1867 | case bfd_reloc_overflow: | |
1868 | { | |
1869 | const char *name; | |
1870 | ||
1871 | if (h != NULL) | |
1872 | name = h->root.root.string; | |
1873 | else | |
1874 | { | |
1875 | name = bfd_elf_string_from_elf_section (input_bfd, | |
1876 | symtab_hdr->sh_link, | |
1877 | sym->st_name); | |
1878 | if (name == NULL) | |
1879 | return false; | |
1880 | if (*name == '\0') | |
1881 | name = bfd_section_name (input_bfd, sec); | |
1882 | } | |
1883 | if (!(info->callbacks->reloc_overflow | |
1884 | (info, name, howto->name, (bfd_vma) 0, | |
1885 | input_bfd, input_section, rel->r_offset))) | |
1886 | return false; | |
1887 | } | |
1888 | break; | |
1889 | } | |
1890 | } | |
1891 | } | |
1892 | ||
1893 | return true; | |
1894 | } | |
1895 | ||
1896 | /* Finish up dynamic symbol handling. We set the contents of various | |
1897 | dynamic sections here. */ | |
1898 | ||
1899 | static boolean | |
1900 | elf_vax_finish_dynamic_symbol (output_bfd, info, h, sym) | |
1901 | bfd *output_bfd; | |
1902 | struct bfd_link_info *info; | |
1903 | struct elf_link_hash_entry *h; | |
1904 | Elf_Internal_Sym *sym; | |
1905 | { | |
1906 | bfd *dynobj; | |
1907 | ||
1908 | dynobj = elf_hash_table (info)->dynobj; | |
1909 | ||
1910 | if (h->plt.offset != (bfd_vma) -1) | |
1911 | { | |
1912 | asection *splt; | |
1913 | asection *sgot; | |
1914 | asection *srela; | |
1915 | bfd_vma plt_index; | |
1916 | bfd_vma got_offset; | |
1917 | bfd_vma addend; | |
1918 | Elf_Internal_Rela rela; | |
1919 | ||
1920 | /* This symbol has an entry in the procedure linkage table. Set | |
1921 | it up. */ | |
1922 | ||
1923 | BFD_ASSERT (h->dynindx != -1); | |
1924 | ||
1925 | splt = bfd_get_section_by_name (dynobj, ".plt"); | |
1926 | sgot = bfd_get_section_by_name (dynobj, ".got.plt"); | |
1927 | srela = bfd_get_section_by_name (dynobj, ".rela.plt"); | |
1928 | BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL); | |
1929 | ||
1930 | addend = 2 * (h->plt.offset & 1); | |
1931 | h->plt.offset &= ~1; | |
1932 | ||
1933 | /* Get the index in the procedure linkage table which | |
1934 | corresponds to this symbol. This is the index of this symbol | |
1935 | in all the symbols for which we are making plt entries. The | |
1936 | first entry in the procedure linkage table is reserved. */ | |
1937 | plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1; | |
1938 | ||
1939 | /* Get the offset into the .got table of the entry that | |
1940 | corresponds to this function. Each .got entry is 4 bytes. | |
1941 | The first two are reserved. */ | |
1942 | got_offset = (plt_index + 3) * 4; | |
1943 | ||
1944 | /* Fill in the entry in the procedure linkage table. */ | |
1945 | memcpy (splt->contents + h->plt.offset, elf_vax_plt_entry, | |
1946 | PLT_ENTRY_SIZE); | |
1947 | ||
1948 | /* The offset is relative to the first extension word. */ | |
1949 | bfd_put_32 (output_bfd, | |
1950 | -(h->plt.offset + 8), | |
1951 | splt->contents + h->plt.offset + 4); | |
1952 | ||
1953 | bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rela), | |
1954 | splt->contents + h->plt.offset + 8); | |
1955 | ||
1956 | /* Fill in the entry in the global offset table. */ | |
1957 | bfd_put_32 (output_bfd, | |
1958 | (splt->output_section->vma | |
1959 | + splt->output_offset | |
1960 | + h->plt.offset) + addend, | |
1961 | sgot->contents + got_offset); | |
1962 | ||
1963 | /* Fill in the entry in the .rela.plt section. */ | |
1964 | rela.r_offset = (sgot->output_section->vma | |
1965 | + sgot->output_offset | |
1966 | + got_offset); | |
1967 | rela.r_info = ELF32_R_INFO (h->dynindx, R_VAX_JMP_SLOT); | |
1968 | rela.r_addend = addend; | |
1969 | bfd_elf32_swap_reloca_out (output_bfd, &rela, | |
1970 | ((Elf32_External_Rela *) srela->contents | |
1971 | + plt_index)); | |
1972 | ||
1973 | if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) | |
1974 | { | |
1975 | /* Mark the symbol as undefined, rather than as defined in | |
1976 | the .plt section. Leave the value alone. */ | |
1977 | sym->st_shndx = SHN_UNDEF; | |
1978 | } | |
1979 | } | |
1980 | ||
1981 | if (h->got.offset != (bfd_vma) -1) | |
1982 | { | |
1983 | asection *sgot; | |
1984 | asection *srela; | |
1985 | Elf_Internal_Rela rela; | |
1986 | ||
1987 | /* This symbol has an entry in the global offset table. Set it | |
1988 | up. */ | |
1989 | ||
1990 | sgot = bfd_get_section_by_name (dynobj, ".got"); | |
1991 | srela = bfd_get_section_by_name (dynobj, ".rela.got"); | |
1992 | BFD_ASSERT (sgot != NULL && srela != NULL); | |
1993 | ||
1994 | rela.r_offset = (sgot->output_section->vma | |
1995 | + sgot->output_offset | |
1996 | + (h->got.offset &~ 1)); | |
1997 | ||
1998 | /* If the symbol was forced to be local because of a version file | |
1999 | locally we just want to emit a RELATIVE reloc. The entry in | |
2000 | the global offset table will already have been initialized in | |
2001 | the relocate_section function. */ | |
2002 | if (info->shared | |
2003 | && h->dynindx == -1 | |
2004 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)) | |
2005 | { | |
2006 | rela.r_info = ELF32_R_INFO (0, R_VAX_RELATIVE); | |
2007 | } | |
2008 | else | |
2009 | { | |
2010 | rela.r_info = ELF32_R_INFO (h->dynindx, R_VAX_GLOB_DAT); | |
2011 | } | |
2012 | rela.r_addend = bfd_get_signed_32 (output_bfd, | |
2013 | (sgot->contents | |
2014 | + (h->got.offset & ~1))); | |
2015 | ||
2016 | bfd_elf32_swap_reloca_out (output_bfd, &rela, | |
2017 | ((Elf32_External_Rela *) srela->contents | |
2018 | + srela->reloc_count)); | |
2019 | ++srela->reloc_count; | |
2020 | } | |
2021 | ||
2022 | if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0) | |
2023 | { | |
2024 | asection *s; | |
2025 | Elf_Internal_Rela rela; | |
2026 | ||
2027 | /* This symbol needs a copy reloc. Set it up. */ | |
2028 | ||
2029 | BFD_ASSERT (h->dynindx != -1 | |
2030 | && (h->root.type == bfd_link_hash_defined | |
2031 | || h->root.type == bfd_link_hash_defweak)); | |
2032 | ||
2033 | s = bfd_get_section_by_name (h->root.u.def.section->owner, | |
2034 | ".rela.bss"); | |
2035 | BFD_ASSERT (s != NULL); | |
2036 | ||
2037 | rela.r_offset = (h->root.u.def.value | |
2038 | + h->root.u.def.section->output_section->vma | |
2039 | + h->root.u.def.section->output_offset); | |
2040 | rela.r_info = ELF32_R_INFO (h->dynindx, R_VAX_COPY); | |
2041 | rela.r_addend = 0; | |
2042 | bfd_elf32_swap_reloca_out (output_bfd, &rela, | |
2043 | ((Elf32_External_Rela *) s->contents | |
2044 | + s->reloc_count)); | |
2045 | ++s->reloc_count; | |
2046 | } | |
2047 | ||
2048 | /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ | |
2049 | if (strcmp (h->root.root.string, "_DYNAMIC") == 0 | |
2050 | || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) | |
2051 | sym->st_shndx = SHN_ABS; | |
2052 | ||
2053 | return true; | |
2054 | } | |
2055 | ||
2056 | /* Finish up the dynamic sections. */ | |
2057 | ||
2058 | static boolean | |
2059 | elf_vax_finish_dynamic_sections (output_bfd, info) | |
2060 | bfd *output_bfd; | |
2061 | struct bfd_link_info *info; | |
2062 | { | |
2063 | bfd *dynobj; | |
2064 | asection *sgot; | |
2065 | asection *sdyn; | |
2066 | ||
2067 | dynobj = elf_hash_table (info)->dynobj; | |
2068 | ||
2069 | sgot = bfd_get_section_by_name (dynobj, ".got.plt"); | |
2070 | BFD_ASSERT (sgot != NULL); | |
2071 | sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); | |
2072 | ||
2073 | if (elf_hash_table (info)->dynamic_sections_created) | |
2074 | { | |
2075 | asection *splt; | |
2076 | Elf32_External_Dyn *dyncon, *dynconend; | |
2077 | ||
2078 | splt = bfd_get_section_by_name (dynobj, ".plt"); | |
2079 | BFD_ASSERT (splt != NULL && sdyn != NULL); | |
2080 | ||
2081 | dyncon = (Elf32_External_Dyn *) sdyn->contents; | |
2082 | dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size); | |
2083 | for (; dyncon < dynconend; dyncon++) | |
2084 | { | |
2085 | Elf_Internal_Dyn dyn; | |
2086 | const char *name; | |
2087 | asection *s; | |
2088 | ||
2089 | bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn); | |
2090 | ||
2091 | switch (dyn.d_tag) | |
2092 | { | |
2093 | default: | |
2094 | break; | |
2095 | ||
2096 | case DT_PLTGOT: | |
2097 | name = ".got"; | |
2098 | goto get_vma; | |
2099 | case DT_JMPREL: | |
2100 | name = ".rela.plt"; | |
2101 | get_vma: | |
2102 | s = bfd_get_section_by_name (output_bfd, name); | |
2103 | BFD_ASSERT (s != NULL); | |
2104 | dyn.d_un.d_ptr = s->vma; | |
2105 | bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); | |
2106 | break; | |
2107 | ||
2108 | case DT_PLTRELSZ: | |
2109 | s = bfd_get_section_by_name (output_bfd, ".rela.plt"); | |
2110 | BFD_ASSERT (s != NULL); | |
2111 | if (s->_cooked_size != 0) | |
2112 | dyn.d_un.d_val = s->_cooked_size; | |
2113 | else | |
2114 | dyn.d_un.d_val = s->_raw_size; | |
2115 | bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); | |
2116 | break; | |
2117 | ||
2118 | case DT_RELASZ: | |
2119 | /* The procedure linkage table relocs (DT_JMPREL) should | |
2120 | not be included in the overall relocs (DT_RELA). | |
2121 | Therefore, we override the DT_RELASZ entry here to | |
2122 | make it not include the JMPREL relocs. Since the | |
2123 | linker script arranges for .rela.plt to follow all | |
2124 | other relocation sections, we don't have to worry | |
2125 | about changing the DT_RELA entry. */ | |
2126 | s = bfd_get_section_by_name (output_bfd, ".rela.plt"); | |
2127 | if (s != NULL) | |
2128 | { | |
2129 | if (s->_cooked_size != 0) | |
2130 | dyn.d_un.d_val -= s->_cooked_size; | |
2131 | else | |
2132 | dyn.d_un.d_val -= s->_raw_size; | |
2133 | } | |
2134 | bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); | |
2135 | break; | |
2136 | } | |
2137 | } | |
2138 | ||
2139 | /* Fill in the first entry in the procedure linkage table. */ | |
2140 | if (splt->_raw_size > 0) | |
2141 | { | |
2142 | memcpy (splt->contents, elf_vax_plt0_entry, PLT_ENTRY_SIZE); | |
2143 | bfd_put_32 (output_bfd, | |
2144 | (sgot->output_section->vma | |
2145 | + sgot->output_offset + 4 | |
2146 | - (splt->output_section->vma + 6)), | |
2147 | splt->contents + 2); | |
2148 | bfd_put_32 (output_bfd, | |
2149 | (sgot->output_section->vma | |
2150 | + sgot->output_offset + 8 | |
2151 | - (splt->output_section->vma + 12)), | |
2152 | splt->contents + 8); | |
cedb70c5 | 2153 | elf_section_data (splt->output_section)->this_hdr.sh_entsize |
90ace9e9 JT |
2154 | = PLT_ENTRY_SIZE; |
2155 | } | |
2156 | } | |
2157 | ||
2158 | /* Fill in the first three entries in the global offset table. */ | |
2159 | if (sgot->_raw_size > 0) | |
2160 | { | |
2161 | if (sdyn == NULL) | |
2162 | bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents); | |
2163 | else | |
2164 | bfd_put_32 (output_bfd, | |
2165 | sdyn->output_section->vma + sdyn->output_offset, | |
2166 | sgot->contents); | |
2167 | bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 4); | |
2168 | bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8); | |
2169 | } | |
2170 | ||
2171 | elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4; | |
2172 | ||
2173 | return true; | |
2174 | } | |
2175 | ||
2176 | #define TARGET_LITTLE_SYM bfd_elf32_vax_vec | |
2177 | #define TARGET_LITTLE_NAME "elf32-vax" | |
2178 | #define ELF_MACHINE_CODE EM_VAX | |
2179 | #define ELF_MAXPAGESIZE 0x1000 | |
2180 | ||
2181 | #define elf_backend_create_dynamic_sections \ | |
2182 | _bfd_elf_create_dynamic_sections | |
2183 | #define bfd_elf32_bfd_link_hash_table_create \ | |
2184 | elf_vax_link_hash_table_create | |
2185 | #define bfd_elf32_bfd_final_link _bfd_elf32_gc_common_final_link | |
2186 | ||
2187 | #define elf_backend_check_relocs elf_vax_check_relocs | |
2188 | #define elf_backend_adjust_dynamic_symbol \ | |
2189 | elf_vax_adjust_dynamic_symbol | |
2190 | #define elf_backend_size_dynamic_sections \ | |
2191 | elf_vax_size_dynamic_sections | |
2192 | #define elf_backend_relocate_section elf_vax_relocate_section | |
2193 | #define elf_backend_finish_dynamic_symbol \ | |
2194 | elf_vax_finish_dynamic_symbol | |
2195 | #define elf_backend_finish_dynamic_sections \ | |
2196 | elf_vax_finish_dynamic_sections | |
2197 | #define elf_backend_gc_mark_hook elf_vax_gc_mark_hook | |
2198 | #define elf_backend_gc_sweep_hook elf_vax_gc_sweep_hook | |
2199 | #define bfd_elf32_bfd_merge_private_bfd_data \ | |
2200 | elf32_vax_merge_private_bfd_data | |
2201 | #define bfd_elf32_bfd_set_private_flags \ | |
2202 | elf32_vax_set_private_flags | |
2203 | #define bfd_elf32_bfd_print_private_bfd_data \ | |
2204 | elf32_vax_print_private_bfd_data | |
2205 | ||
2206 | #define elf_backend_can_gc_sections 1 | |
2207 | #define elf_backend_want_got_plt 1 | |
2208 | #define elf_backend_plt_readonly 1 | |
2209 | #define elf_backend_want_plt_sym 0 | |
2210 | #define elf_backend_got_header_size 16 | |
2211 | ||
2212 | #include "elf32-target.h" |