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