| 1 | /* PowerPC-specific support for 32-bit ELF
|
|---|
| 2 | Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
|
|---|
| 3 | Free Software Foundation, Inc.
|
|---|
| 4 | Written by Ian Lance Taylor, Cygnus Support.
|
|---|
| 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
|
|---|
| 20 | Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|---|
| 21 | Boston, MA 02111-1307, USA. */
|
|---|
| 22 |
|
|---|
| 23 | /* This file is based on a preliminary PowerPC ELF ABI. The
|
|---|
| 24 | information may not match the final PowerPC ELF ABI. It includes
|
|---|
| 25 | suggestions from the in-progress Embedded PowerPC ABI, and that
|
|---|
| 26 | information may also not match. */
|
|---|
| 27 |
|
|---|
| 28 | #include "bfd.h"
|
|---|
| 29 | #include "sysdep.h"
|
|---|
| 30 | #include "bfdlink.h"
|
|---|
| 31 | #include "libbfd.h"
|
|---|
| 32 | #include "elf-bfd.h"
|
|---|
| 33 | #include "elf/ppc.h"
|
|---|
| 34 | #include "elf32-ppc.h"
|
|---|
| 35 |
|
|---|
| 36 | /* RELA relocations are used here. */
|
|---|
| 37 |
|
|---|
| 38 | static struct bfd_hash_entry *ppc_elf_link_hash_newfunc
|
|---|
| 39 | PARAMS ((struct bfd_hash_entry *entry, struct bfd_hash_table *table,
|
|---|
| 40 | const char *string));
|
|---|
| 41 | static struct bfd_link_hash_table *ppc_elf_link_hash_table_create
|
|---|
| 42 | PARAMS ((bfd *abfd));
|
|---|
| 43 | static void ppc_elf_copy_indirect_symbol
|
|---|
| 44 | PARAMS ((struct elf_backend_data *bed, struct elf_link_hash_entry *dir,
|
|---|
| 45 | struct elf_link_hash_entry *ind));
|
|---|
| 46 | static reloc_howto_type *ppc_elf_reloc_type_lookup
|
|---|
| 47 | PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
|
|---|
| 48 | static void ppc_elf_info_to_howto
|
|---|
| 49 | PARAMS ((bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst));
|
|---|
| 50 | static void ppc_elf_howto_init
|
|---|
| 51 | PARAMS ((void));
|
|---|
| 52 | static int ppc_elf_sort_rela
|
|---|
| 53 | PARAMS ((const PTR, const PTR));
|
|---|
| 54 | static bfd_boolean ppc_elf_relax_section
|
|---|
| 55 | PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *));
|
|---|
| 56 | static bfd_reloc_status_type ppc_elf_addr16_ha_reloc
|
|---|
| 57 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
|---|
| 58 | static bfd_reloc_status_type ppc_elf_unhandled_reloc
|
|---|
| 59 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
|---|
| 60 | static bfd_boolean ppc_elf_object_p
|
|---|
| 61 | PARAMS ((bfd *));
|
|---|
| 62 | static bfd_boolean ppc_elf_set_private_flags
|
|---|
| 63 | PARAMS ((bfd *, flagword));
|
|---|
| 64 | static bfd_boolean ppc_elf_merge_private_bfd_data
|
|---|
| 65 | PARAMS ((bfd *, bfd *));
|
|---|
| 66 | static int ppc_elf_additional_program_headers
|
|---|
| 67 | PARAMS ((bfd *));
|
|---|
| 68 | static bfd_boolean ppc_elf_modify_segment_map
|
|---|
| 69 | PARAMS ((bfd *));
|
|---|
| 70 | static bfd_boolean ppc_elf_create_got
|
|---|
| 71 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 72 | static bfd_boolean ppc_elf_create_dynamic_sections
|
|---|
| 73 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 74 | static bfd_boolean ppc_elf_section_from_shdr
|
|---|
| 75 | PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
|
|---|
| 76 | static bfd_boolean ppc_elf_fake_sections
|
|---|
| 77 | PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
|
|---|
| 78 | static elf_linker_section_t *ppc_elf_create_linker_section
|
|---|
| 79 | PARAMS ((bfd *abfd, struct bfd_link_info *info,
|
|---|
| 80 | enum elf_linker_section_enum));
|
|---|
| 81 | static bfd_boolean update_local_sym_info
|
|---|
| 82 | PARAMS ((bfd *, Elf_Internal_Shdr *, unsigned long, int));
|
|---|
| 83 | static void bad_shared_reloc
|
|---|
| 84 | PARAMS ((bfd *, enum elf_ppc_reloc_type));
|
|---|
| 85 | static bfd_boolean ppc_elf_check_relocs
|
|---|
| 86 | PARAMS ((bfd *, struct bfd_link_info *, asection *,
|
|---|
| 87 | const Elf_Internal_Rela *));
|
|---|
| 88 | static asection *ppc_elf_gc_mark_hook
|
|---|
| 89 | PARAMS ((asection *sec, struct bfd_link_info *info, Elf_Internal_Rela *rel,
|
|---|
| 90 | struct elf_link_hash_entry *h, Elf_Internal_Sym *sym));
|
|---|
| 91 | static bfd_boolean ppc_elf_gc_sweep_hook
|
|---|
| 92 | PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *sec,
|
|---|
| 93 | const Elf_Internal_Rela *relocs));
|
|---|
| 94 | static bfd_boolean ppc_elf_adjust_dynamic_symbol
|
|---|
| 95 | PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
|
|---|
| 96 | static bfd_boolean allocate_dynrelocs
|
|---|
| 97 | PARAMS ((struct elf_link_hash_entry *, PTR));
|
|---|
| 98 | static bfd_boolean readonly_dynrelocs
|
|---|
| 99 | PARAMS ((struct elf_link_hash_entry *, PTR));
|
|---|
| 100 | static bfd_boolean ppc_elf_size_dynamic_sections
|
|---|
| 101 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 102 | static bfd_boolean ppc_elf_relocate_section
|
|---|
| 103 | PARAMS ((bfd *, struct bfd_link_info *info, bfd *, asection *, bfd_byte *,
|
|---|
| 104 | Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms,
|
|---|
| 105 | asection **));
|
|---|
| 106 | static bfd_boolean ppc_elf_add_symbol_hook
|
|---|
| 107 | PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
|
|---|
| 108 | const char **, flagword *, asection **, bfd_vma *));
|
|---|
| 109 | static bfd_boolean ppc_elf_finish_dynamic_symbol
|
|---|
| 110 | PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
|
|---|
| 111 | Elf_Internal_Sym *));
|
|---|
| 112 | static bfd_boolean ppc_elf_finish_dynamic_sections
|
|---|
| 113 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 114 | static enum elf_reloc_type_class ppc_elf_reloc_type_class
|
|---|
| 115 | PARAMS ((const Elf_Internal_Rela *));
|
|---|
| 116 | static bfd_boolean ppc_elf_grok_prstatus
|
|---|
| 117 | PARAMS ((bfd *abfd, Elf_Internal_Note *note));
|
|---|
| 118 | static bfd_boolean ppc_elf_grok_psinfo
|
|---|
| 119 | PARAMS ((bfd *abfd, Elf_Internal_Note *note));
|
|---|
| 120 |
|
|---|
| 121 | /* Branch prediction bit for branch taken relocs. */
|
|---|
| 122 | #define BRANCH_PREDICT_BIT 0x200000
|
|---|
| 123 | /* Mask to set RA in memory instructions. */
|
|---|
| 124 | #define RA_REGISTER_MASK 0x001f0000
|
|---|
| 125 | /* Value to shift register by to insert RA. */
|
|---|
| 126 | #define RA_REGISTER_SHIFT 16
|
|---|
| 127 |
|
|---|
| 128 | /* The name of the dynamic interpreter. This is put in the .interp
|
|---|
| 129 | section. */
|
|---|
| 130 | #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
|
|---|
| 131 |
|
|---|
| 132 | /* The size in bytes of an entry in the procedure linkage table. */
|
|---|
| 133 | #define PLT_ENTRY_SIZE 12
|
|---|
| 134 | /* The initial size of the plt reserved for the dynamic linker. */
|
|---|
| 135 | #define PLT_INITIAL_ENTRY_SIZE 72
|
|---|
| 136 | /* The size of the gap between entries in the PLT. */
|
|---|
| 137 | #define PLT_SLOT_SIZE 8
|
|---|
| 138 | /* The number of single-slot PLT entries (the rest use two slots). */
|
|---|
| 139 | #define PLT_NUM_SINGLE_ENTRIES 8192
|
|---|
| 140 |
|
|---|
| 141 | /* Some nop instructions. */
|
|---|
| 142 | #define NOP 0x60000000
|
|---|
| 143 | #define CROR_151515 0x4def7b82
|
|---|
| 144 | #define CROR_313131 0x4ffffb82
|
|---|
| 145 |
|
|---|
| 146 | /* Offset of tp and dtp pointers from start of TLS block. */
|
|---|
| 147 | #define TP_OFFSET 0x7000
|
|---|
| 148 | #define DTP_OFFSET 0x8000
|
|---|
| 149 |
|
|---|
| 150 | /* Will references to this symbol always reference the symbol
|
|---|
| 151 | in this object? STV_PROTECTED is excluded from the visibility test
|
|---|
| 152 | here so that function pointer comparisons work properly. Since
|
|---|
| 153 | function symbols not defined in an app are set to their .plt entry,
|
|---|
| 154 | it's necessary for shared libs to also reference the .plt even
|
|---|
| 155 | though the symbol is really local to the shared lib. */
|
|---|
| 156 | #define SYMBOL_REFERENCES_LOCAL(INFO, H) \
|
|---|
| 157 | ((! INFO->shared \
|
|---|
| 158 | || INFO->symbolic \
|
|---|
| 159 | || H->dynindx == -1 \
|
|---|
| 160 | || ELF_ST_VISIBILITY (H->other) == STV_INTERNAL \
|
|---|
| 161 | || ELF_ST_VISIBILITY (H->other) == STV_HIDDEN) \
|
|---|
| 162 | && (H->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)
|
|---|
| 163 |
|
|---|
| 164 | /* Will _calls_ to this symbol always call the version in this object? */
|
|---|
| 165 | #define SYMBOL_CALLS_LOCAL(INFO, H) \
|
|---|
| 166 | ((! INFO->shared \
|
|---|
| 167 | || INFO->symbolic \
|
|---|
| 168 | || H->dynindx == -1 \
|
|---|
| 169 | || ELF_ST_VISIBILITY (H->other) != STV_DEFAULT) \
|
|---|
| 170 | && (H->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0)
|
|---|
| 171 | |
|---|
| 172 |
|
|---|
| 173 | /* The PPC linker needs to keep track of the number of relocs that it
|
|---|
| 174 | decides to copy as dynamic relocs in check_relocs for each symbol.
|
|---|
| 175 | This is so that it can later discard them if they are found to be
|
|---|
| 176 | unnecessary. We store the information in a field extending the
|
|---|
| 177 | regular ELF linker hash table. */
|
|---|
| 178 |
|
|---|
| 179 | struct ppc_elf_dyn_relocs
|
|---|
| 180 | {
|
|---|
| 181 | struct ppc_elf_dyn_relocs *next;
|
|---|
| 182 |
|
|---|
| 183 | /* The input section of the reloc. */
|
|---|
| 184 | asection *sec;
|
|---|
| 185 |
|
|---|
| 186 | /* Total number of relocs copied for the input section. */
|
|---|
| 187 | bfd_size_type count;
|
|---|
| 188 |
|
|---|
| 189 | /* Number of pc-relative relocs copied for the input section. */
|
|---|
| 190 | bfd_size_type pc_count;
|
|---|
| 191 | };
|
|---|
| 192 |
|
|---|
| 193 | /* PPC ELF linker hash entry. */
|
|---|
| 194 |
|
|---|
| 195 | struct ppc_elf_link_hash_entry
|
|---|
| 196 | {
|
|---|
| 197 | struct elf_link_hash_entry elf;
|
|---|
| 198 |
|
|---|
| 199 | /* Track dynamic relocs copied for this symbol. */
|
|---|
| 200 | struct ppc_elf_dyn_relocs *dyn_relocs;
|
|---|
| 201 |
|
|---|
| 202 | /* Contexts in which symbol is used in the GOT (or TOC).
|
|---|
| 203 | TLS_GD .. TLS_TLS bits are or'd into the mask as the
|
|---|
| 204 | corresponding relocs are encountered during check_relocs.
|
|---|
| 205 | tls_optimize clears TLS_GD .. TLS_TPREL when optimizing to
|
|---|
| 206 | indicate the corresponding GOT entry type is not needed. */
|
|---|
| 207 | #define TLS_GD 1 /* GD reloc. */
|
|---|
| 208 | #define TLS_LD 2 /* LD reloc. */
|
|---|
| 209 | #define TLS_TPREL 4 /* TPREL reloc, => IE. */
|
|---|
| 210 | #define TLS_DTPREL 8 /* DTPREL reloc, => LD. */
|
|---|
| 211 | #define TLS_TLS 16 /* Any TLS reloc. */
|
|---|
| 212 | #define TLS_TPRELGD 32 /* TPREL reloc resulting from GD->IE. */
|
|---|
| 213 | char tls_mask;
|
|---|
| 214 | };
|
|---|
| 215 |
|
|---|
| 216 | #define ppc_elf_hash_entry(ent) ((struct ppc_elf_link_hash_entry *) (ent))
|
|---|
| 217 |
|
|---|
| 218 | /* PPC ELF linker hash table. */
|
|---|
| 219 |
|
|---|
| 220 | struct ppc_elf_link_hash_table
|
|---|
| 221 | {
|
|---|
| 222 | struct elf_link_hash_table elf;
|
|---|
| 223 |
|
|---|
| 224 | /* Short-cuts to get to dynamic linker sections. */
|
|---|
| 225 | asection *got;
|
|---|
| 226 | asection *relgot;
|
|---|
| 227 | asection *plt;
|
|---|
| 228 | asection *relplt;
|
|---|
| 229 | asection *dynbss;
|
|---|
| 230 | asection *relbss;
|
|---|
| 231 | asection *dynsbss;
|
|---|
| 232 | asection *relsbss;
|
|---|
| 233 | elf_linker_section_t *sdata;
|
|---|
| 234 | elf_linker_section_t *sdata2;
|
|---|
| 235 |
|
|---|
| 236 | /* Short-cut to first output tls section. */
|
|---|
| 237 | asection *tls_sec;
|
|---|
| 238 |
|
|---|
| 239 | /* Shortcut to .__tls_get_addr. */
|
|---|
| 240 | struct elf_link_hash_entry *tls_get_addr;
|
|---|
| 241 |
|
|---|
| 242 | /* TLS local dynamic got entry handling. */
|
|---|
| 243 | union {
|
|---|
| 244 | bfd_signed_vma refcount;
|
|---|
| 245 | bfd_vma offset;
|
|---|
| 246 | } tlsld_got;
|
|---|
| 247 |
|
|---|
| 248 | /* Small local sym to section mapping cache. */
|
|---|
| 249 | struct sym_sec_cache sym_sec;
|
|---|
| 250 | };
|
|---|
| 251 |
|
|---|
| 252 | /* Get the PPC ELF linker hash table from a link_info structure. */
|
|---|
| 253 |
|
|---|
| 254 | #define ppc_elf_hash_table(p) \
|
|---|
| 255 | ((struct ppc_elf_link_hash_table *) (p)->hash)
|
|---|
| 256 |
|
|---|
| 257 | /* Create an entry in a PPC ELF linker hash table. */
|
|---|
| 258 |
|
|---|
| 259 | static struct bfd_hash_entry *
|
|---|
| 260 | ppc_elf_link_hash_newfunc (entry, table, string)
|
|---|
| 261 | struct bfd_hash_entry *entry;
|
|---|
| 262 | struct bfd_hash_table *table;
|
|---|
| 263 | const char *string;
|
|---|
| 264 | {
|
|---|
| 265 | /* Allocate the structure if it has not already been allocated by a
|
|---|
| 266 | subclass. */
|
|---|
| 267 | if (entry == NULL)
|
|---|
| 268 | {
|
|---|
| 269 | entry = bfd_hash_allocate (table,
|
|---|
| 270 | sizeof (struct ppc_elf_link_hash_entry));
|
|---|
| 271 | if (entry == NULL)
|
|---|
| 272 | return entry;
|
|---|
| 273 | }
|
|---|
| 274 |
|
|---|
| 275 | /* Call the allocation method of the superclass. */
|
|---|
| 276 | entry = _bfd_elf_link_hash_newfunc (entry, table, string);
|
|---|
| 277 | if (entry != NULL)
|
|---|
| 278 | {
|
|---|
| 279 | ppc_elf_hash_entry (entry)->dyn_relocs = NULL;
|
|---|
| 280 | ppc_elf_hash_entry (entry)->tls_mask = 0;
|
|---|
| 281 | }
|
|---|
| 282 |
|
|---|
| 283 | return entry;
|
|---|
| 284 | }
|
|---|
| 285 |
|
|---|
| 286 | /* Create a PPC ELF linker hash table. */
|
|---|
| 287 |
|
|---|
| 288 | static struct bfd_link_hash_table *
|
|---|
| 289 | ppc_elf_link_hash_table_create (abfd)
|
|---|
| 290 | bfd *abfd;
|
|---|
| 291 | {
|
|---|
| 292 | struct ppc_elf_link_hash_table *ret;
|
|---|
| 293 |
|
|---|
| 294 | ret = ((struct ppc_elf_link_hash_table *)
|
|---|
| 295 | bfd_malloc (sizeof (struct ppc_elf_link_hash_table)));
|
|---|
| 296 | if (ret == NULL)
|
|---|
| 297 | return NULL;
|
|---|
| 298 |
|
|---|
| 299 | if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd,
|
|---|
| 300 | ppc_elf_link_hash_newfunc))
|
|---|
| 301 | {
|
|---|
| 302 | free (ret);
|
|---|
| 303 | return NULL;
|
|---|
| 304 | }
|
|---|
| 305 |
|
|---|
| 306 | ret->got = NULL;
|
|---|
| 307 | ret->relgot = NULL;
|
|---|
| 308 | ret->plt = NULL;
|
|---|
| 309 | ret->relplt = NULL;
|
|---|
| 310 | ret->dynbss = NULL;
|
|---|
| 311 | ret->relbss = NULL;
|
|---|
| 312 | ret->dynsbss = NULL;
|
|---|
| 313 | ret->relsbss = NULL;
|
|---|
| 314 | ret->sdata = NULL;
|
|---|
| 315 | ret->sdata2 = NULL;
|
|---|
| 316 | ret->tls_sec = NULL;
|
|---|
| 317 | ret->tls_get_addr = NULL;
|
|---|
| 318 | ret->tlsld_got.refcount = 0;
|
|---|
| 319 | ret->sym_sec.abfd = NULL;
|
|---|
| 320 |
|
|---|
| 321 | return &ret->elf.root;
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 | /* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid
|
|---|
| 325 | copying dynamic variables from a shared lib into an app's dynbss
|
|---|
| 326 | section, and instead use a dynamic relocation to point into the
|
|---|
| 327 | shared lib. */
|
|---|
| 328 | #define ELIMINATE_COPY_RELOCS 1
|
|---|
| 329 |
|
|---|
| 330 | /* Copy the extra info we tack onto an elf_link_hash_entry. */
|
|---|
| 331 |
|
|---|
| 332 | static void
|
|---|
| 333 | ppc_elf_copy_indirect_symbol (bed, dir, ind)
|
|---|
| 334 | struct elf_backend_data *bed;
|
|---|
| 335 | struct elf_link_hash_entry *dir, *ind;
|
|---|
| 336 | {
|
|---|
| 337 | struct ppc_elf_link_hash_entry *edir, *eind;
|
|---|
| 338 |
|
|---|
| 339 | edir = (struct ppc_elf_link_hash_entry *) dir;
|
|---|
| 340 | eind = (struct ppc_elf_link_hash_entry *) ind;
|
|---|
| 341 |
|
|---|
| 342 | if (eind->dyn_relocs != NULL)
|
|---|
| 343 | {
|
|---|
| 344 | if (edir->dyn_relocs != NULL)
|
|---|
| 345 | {
|
|---|
| 346 | struct ppc_elf_dyn_relocs **pp;
|
|---|
| 347 | struct ppc_elf_dyn_relocs *p;
|
|---|
| 348 |
|
|---|
| 349 | if (ind->root.type == bfd_link_hash_indirect)
|
|---|
| 350 | abort ();
|
|---|
| 351 |
|
|---|
| 352 | /* Add reloc counts against the weak sym to the strong sym
|
|---|
| 353 | list. Merge any entries against the same section. */
|
|---|
| 354 | for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
|
|---|
| 355 | {
|
|---|
| 356 | struct ppc_elf_dyn_relocs *q;
|
|---|
| 357 |
|
|---|
| 358 | for (q = edir->dyn_relocs; q != NULL; q = q->next)
|
|---|
| 359 | if (q->sec == p->sec)
|
|---|
| 360 | {
|
|---|
| 361 | q->pc_count += p->pc_count;
|
|---|
| 362 | q->count += p->count;
|
|---|
| 363 | *pp = p->next;
|
|---|
| 364 | break;
|
|---|
| 365 | }
|
|---|
| 366 | if (q == NULL)
|
|---|
| 367 | pp = &p->next;
|
|---|
| 368 | }
|
|---|
| 369 | *pp = edir->dyn_relocs;
|
|---|
| 370 | }
|
|---|
| 371 |
|
|---|
| 372 | edir->dyn_relocs = eind->dyn_relocs;
|
|---|
| 373 | eind->dyn_relocs = NULL;
|
|---|
| 374 | }
|
|---|
| 375 |
|
|---|
| 376 | edir->tls_mask |= eind->tls_mask;
|
|---|
| 377 |
|
|---|
| 378 | if (ELIMINATE_COPY_RELOCS
|
|---|
| 379 | && ind->root.type != bfd_link_hash_indirect
|
|---|
| 380 | && (dir->elf_link_hash_flags & ELF_LINK_HASH_DYNAMIC_ADJUSTED) != 0)
|
|---|
| 381 | /* If called to transfer flags for a weakdef during processing
|
|---|
| 382 | of elf_adjust_dynamic_symbol, don't copy ELF_LINK_NON_GOT_REF.
|
|---|
| 383 | We clear it ourselves for ELIMINATE_COPY_RELOCS. */
|
|---|
| 384 | dir->elf_link_hash_flags |=
|
|---|
| 385 | (ind->elf_link_hash_flags & (ELF_LINK_HASH_REF_DYNAMIC
|
|---|
| 386 | | ELF_LINK_HASH_REF_REGULAR
|
|---|
| 387 | | ELF_LINK_HASH_REF_REGULAR_NONWEAK));
|
|---|
| 388 | else
|
|---|
| 389 | _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
|
|---|
| 390 | }
|
|---|
| 391 | |
|---|
| 392 |
|
|---|
| 393 | static reloc_howto_type *ppc_elf_howto_table[(int) R_PPC_max];
|
|---|
| 394 |
|
|---|
| 395 | static reloc_howto_type ppc_elf_howto_raw[] = {
|
|---|
| 396 | /* This reloc does nothing. */
|
|---|
| 397 | HOWTO (R_PPC_NONE, /* type */
|
|---|
| 398 | 0, /* rightshift */
|
|---|
| 399 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 400 | 32, /* bitsize */
|
|---|
| 401 | FALSE, /* pc_relative */
|
|---|
| 402 | 0, /* bitpos */
|
|---|
| 403 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 404 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 405 | "R_PPC_NONE", /* name */
|
|---|
| 406 | FALSE, /* partial_inplace */
|
|---|
| 407 | 0, /* src_mask */
|
|---|
| 408 | 0, /* dst_mask */
|
|---|
| 409 | FALSE), /* pcrel_offset */
|
|---|
| 410 |
|
|---|
| 411 | /* A standard 32 bit relocation. */
|
|---|
| 412 | HOWTO (R_PPC_ADDR32, /* type */
|
|---|
| 413 | 0, /* rightshift */
|
|---|
| 414 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 415 | 32, /* bitsize */
|
|---|
| 416 | FALSE, /* pc_relative */
|
|---|
| 417 | 0, /* bitpos */
|
|---|
| 418 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 419 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 420 | "R_PPC_ADDR32", /* name */
|
|---|
| 421 | FALSE, /* partial_inplace */
|
|---|
| 422 | 0, /* src_mask */
|
|---|
| 423 | 0xffffffff, /* dst_mask */
|
|---|
| 424 | FALSE), /* pcrel_offset */
|
|---|
| 425 |
|
|---|
| 426 | /* An absolute 26 bit branch; the lower two bits must be zero.
|
|---|
| 427 | FIXME: we don't check that, we just clear them. */
|
|---|
| 428 | HOWTO (R_PPC_ADDR24, /* type */
|
|---|
| 429 | 0, /* rightshift */
|
|---|
| 430 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 431 | 26, /* bitsize */
|
|---|
| 432 | FALSE, /* pc_relative */
|
|---|
| 433 | 0, /* bitpos */
|
|---|
| 434 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 435 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 436 | "R_PPC_ADDR24", /* name */
|
|---|
| 437 | FALSE, /* partial_inplace */
|
|---|
| 438 | 0, /* src_mask */
|
|---|
| 439 | 0x3fffffc, /* dst_mask */
|
|---|
| 440 | FALSE), /* pcrel_offset */
|
|---|
| 441 |
|
|---|
| 442 | /* A standard 16 bit relocation. */
|
|---|
| 443 | HOWTO (R_PPC_ADDR16, /* type */
|
|---|
| 444 | 0, /* rightshift */
|
|---|
| 445 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 446 | 16, /* bitsize */
|
|---|
| 447 | FALSE, /* pc_relative */
|
|---|
| 448 | 0, /* bitpos */
|
|---|
| 449 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 450 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 451 | "R_PPC_ADDR16", /* name */
|
|---|
| 452 | FALSE, /* partial_inplace */
|
|---|
| 453 | 0, /* src_mask */
|
|---|
| 454 | 0xffff, /* dst_mask */
|
|---|
| 455 | FALSE), /* pcrel_offset */
|
|---|
| 456 |
|
|---|
| 457 | /* A 16 bit relocation without overflow. */
|
|---|
| 458 | HOWTO (R_PPC_ADDR16_LO, /* type */
|
|---|
| 459 | 0, /* rightshift */
|
|---|
| 460 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 461 | 16, /* bitsize */
|
|---|
| 462 | FALSE, /* pc_relative */
|
|---|
| 463 | 0, /* bitpos */
|
|---|
| 464 | complain_overflow_dont,/* complain_on_overflow */
|
|---|
| 465 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 466 | "R_PPC_ADDR16_LO", /* name */
|
|---|
| 467 | FALSE, /* partial_inplace */
|
|---|
| 468 | 0, /* src_mask */
|
|---|
| 469 | 0xffff, /* dst_mask */
|
|---|
| 470 | FALSE), /* pcrel_offset */
|
|---|
| 471 |
|
|---|
| 472 | /* The high order 16 bits of an address. */
|
|---|
| 473 | HOWTO (R_PPC_ADDR16_HI, /* type */
|
|---|
| 474 | 16, /* rightshift */
|
|---|
| 475 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 476 | 16, /* bitsize */
|
|---|
| 477 | FALSE, /* pc_relative */
|
|---|
| 478 | 0, /* bitpos */
|
|---|
| 479 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 480 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 481 | "R_PPC_ADDR16_HI", /* name */
|
|---|
| 482 | FALSE, /* partial_inplace */
|
|---|
| 483 | 0, /* src_mask */
|
|---|
| 484 | 0xffff, /* dst_mask */
|
|---|
| 485 | FALSE), /* pcrel_offset */
|
|---|
| 486 |
|
|---|
| 487 | /* The high order 16 bits of an address, plus 1 if the contents of
|
|---|
| 488 | the low 16 bits, treated as a signed number, is negative. */
|
|---|
| 489 | HOWTO (R_PPC_ADDR16_HA, /* type */
|
|---|
| 490 | 16, /* rightshift */
|
|---|
| 491 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 492 | 16, /* bitsize */
|
|---|
| 493 | FALSE, /* pc_relative */
|
|---|
| 494 | 0, /* bitpos */
|
|---|
| 495 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 496 | ppc_elf_addr16_ha_reloc, /* special_function */
|
|---|
| 497 | "R_PPC_ADDR16_HA", /* name */
|
|---|
| 498 | FALSE, /* partial_inplace */
|
|---|
| 499 | 0, /* src_mask */
|
|---|
| 500 | 0xffff, /* dst_mask */
|
|---|
| 501 | FALSE), /* pcrel_offset */
|
|---|
| 502 |
|
|---|
| 503 | /* An absolute 16 bit branch; the lower two bits must be zero.
|
|---|
| 504 | FIXME: we don't check that, we just clear them. */
|
|---|
| 505 | HOWTO (R_PPC_ADDR14, /* type */
|
|---|
| 506 | 0, /* rightshift */
|
|---|
| 507 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 508 | 16, /* bitsize */
|
|---|
| 509 | FALSE, /* pc_relative */
|
|---|
| 510 | 0, /* bitpos */
|
|---|
| 511 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 512 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 513 | "R_PPC_ADDR14", /* name */
|
|---|
| 514 | FALSE, /* partial_inplace */
|
|---|
| 515 | 0, /* src_mask */
|
|---|
| 516 | 0xfffc, /* dst_mask */
|
|---|
| 517 | FALSE), /* pcrel_offset */
|
|---|
| 518 |
|
|---|
| 519 | /* An absolute 16 bit branch, for which bit 10 should be set to
|
|---|
| 520 | indicate that the branch is expected to be taken. The lower two
|
|---|
| 521 | bits must be zero. */
|
|---|
| 522 | HOWTO (R_PPC_ADDR14_BRTAKEN, /* type */
|
|---|
| 523 | 0, /* rightshift */
|
|---|
| 524 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 525 | 16, /* bitsize */
|
|---|
| 526 | FALSE, /* pc_relative */
|
|---|
| 527 | 0, /* bitpos */
|
|---|
| 528 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 529 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 530 | "R_PPC_ADDR14_BRTAKEN",/* name */
|
|---|
| 531 | FALSE, /* partial_inplace */
|
|---|
| 532 | 0, /* src_mask */
|
|---|
| 533 | 0xfffc, /* dst_mask */
|
|---|
| 534 | FALSE), /* pcrel_offset */
|
|---|
| 535 |
|
|---|
| 536 | /* An absolute 16 bit branch, for which bit 10 should be set to
|
|---|
| 537 | indicate that the branch is not expected to be taken. The lower
|
|---|
| 538 | two bits must be zero. */
|
|---|
| 539 | HOWTO (R_PPC_ADDR14_BRNTAKEN, /* type */
|
|---|
| 540 | 0, /* rightshift */
|
|---|
| 541 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 542 | 16, /* bitsize */
|
|---|
| 543 | FALSE, /* pc_relative */
|
|---|
| 544 | 0, /* bitpos */
|
|---|
| 545 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 546 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 547 | "R_PPC_ADDR14_BRNTAKEN",/* name */
|
|---|
| 548 | FALSE, /* partial_inplace */
|
|---|
| 549 | 0, /* src_mask */
|
|---|
| 550 | 0xfffc, /* dst_mask */
|
|---|
| 551 | FALSE), /* pcrel_offset */
|
|---|
| 552 |
|
|---|
| 553 | /* A relative 26 bit branch; the lower two bits must be zero. */
|
|---|
| 554 | HOWTO (R_PPC_REL24, /* type */
|
|---|
| 555 | 0, /* rightshift */
|
|---|
| 556 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 557 | 26, /* bitsize */
|
|---|
| 558 | TRUE, /* pc_relative */
|
|---|
| 559 | 0, /* bitpos */
|
|---|
| 560 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 561 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 562 | "R_PPC_REL24", /* name */
|
|---|
| 563 | FALSE, /* partial_inplace */
|
|---|
| 564 | 0, /* src_mask */
|
|---|
| 565 | 0x3fffffc, /* dst_mask */
|
|---|
| 566 | TRUE), /* pcrel_offset */
|
|---|
| 567 |
|
|---|
| 568 | /* A relative 16 bit branch; the lower two bits must be zero. */
|
|---|
| 569 | HOWTO (R_PPC_REL14, /* type */
|
|---|
| 570 | 0, /* rightshift */
|
|---|
| 571 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 572 | 16, /* bitsize */
|
|---|
| 573 | TRUE, /* pc_relative */
|
|---|
| 574 | 0, /* bitpos */
|
|---|
| 575 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 576 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 577 | "R_PPC_REL14", /* name */
|
|---|
| 578 | FALSE, /* partial_inplace */
|
|---|
| 579 | 0, /* src_mask */
|
|---|
| 580 | 0xfffc, /* dst_mask */
|
|---|
| 581 | TRUE), /* pcrel_offset */
|
|---|
| 582 |
|
|---|
| 583 | /* A relative 16 bit branch. Bit 10 should be set to indicate that
|
|---|
| 584 | the branch is expected to be taken. The lower two bits must be
|
|---|
| 585 | zero. */
|
|---|
| 586 | HOWTO (R_PPC_REL14_BRTAKEN, /* type */
|
|---|
| 587 | 0, /* rightshift */
|
|---|
| 588 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 589 | 16, /* bitsize */
|
|---|
| 590 | TRUE, /* pc_relative */
|
|---|
| 591 | 0, /* bitpos */
|
|---|
| 592 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 593 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 594 | "R_PPC_REL14_BRTAKEN", /* name */
|
|---|
| 595 | FALSE, /* partial_inplace */
|
|---|
| 596 | 0, /* src_mask */
|
|---|
| 597 | 0xfffc, /* dst_mask */
|
|---|
| 598 | TRUE), /* pcrel_offset */
|
|---|
| 599 |
|
|---|
| 600 | /* A relative 16 bit branch. Bit 10 should be set to indicate that
|
|---|
| 601 | the branch is not expected to be taken. The lower two bits must
|
|---|
| 602 | be zero. */
|
|---|
| 603 | HOWTO (R_PPC_REL14_BRNTAKEN, /* type */
|
|---|
| 604 | 0, /* rightshift */
|
|---|
| 605 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 606 | 16, /* bitsize */
|
|---|
| 607 | TRUE, /* pc_relative */
|
|---|
| 608 | 0, /* bitpos */
|
|---|
| 609 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 610 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 611 | "R_PPC_REL14_BRNTAKEN",/* name */
|
|---|
| 612 | FALSE, /* partial_inplace */
|
|---|
| 613 | 0, /* src_mask */
|
|---|
| 614 | 0xfffc, /* dst_mask */
|
|---|
| 615 | TRUE), /* pcrel_offset */
|
|---|
| 616 |
|
|---|
| 617 | /* Like R_PPC_ADDR16, but referring to the GOT table entry for the
|
|---|
| 618 | symbol. */
|
|---|
| 619 | HOWTO (R_PPC_GOT16, /* type */
|
|---|
| 620 | 0, /* rightshift */
|
|---|
| 621 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 622 | 16, /* bitsize */
|
|---|
| 623 | FALSE, /* pc_relative */
|
|---|
| 624 | 0, /* bitpos */
|
|---|
| 625 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 626 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 627 | "R_PPC_GOT16", /* name */
|
|---|
| 628 | FALSE, /* partial_inplace */
|
|---|
| 629 | 0, /* src_mask */
|
|---|
| 630 | 0xffff, /* dst_mask */
|
|---|
| 631 | FALSE), /* pcrel_offset */
|
|---|
| 632 |
|
|---|
| 633 | /* Like R_PPC_ADDR16_LO, but referring to the GOT table entry for
|
|---|
| 634 | the symbol. */
|
|---|
| 635 | HOWTO (R_PPC_GOT16_LO, /* type */
|
|---|
| 636 | 0, /* rightshift */
|
|---|
| 637 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 638 | 16, /* bitsize */
|
|---|
| 639 | FALSE, /* pc_relative */
|
|---|
| 640 | 0, /* bitpos */
|
|---|
| 641 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 642 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 643 | "R_PPC_GOT16_LO", /* name */
|
|---|
| 644 | FALSE, /* partial_inplace */
|
|---|
| 645 | 0, /* src_mask */
|
|---|
| 646 | 0xffff, /* dst_mask */
|
|---|
| 647 | FALSE), /* pcrel_offset */
|
|---|
| 648 |
|
|---|
| 649 | /* Like R_PPC_ADDR16_HI, but referring to the GOT table entry for
|
|---|
| 650 | the symbol. */
|
|---|
| 651 | HOWTO (R_PPC_GOT16_HI, /* type */
|
|---|
| 652 | 16, /* rightshift */
|
|---|
| 653 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 654 | 16, /* bitsize */
|
|---|
| 655 | FALSE, /* pc_relative */
|
|---|
| 656 | 0, /* bitpos */
|
|---|
| 657 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 658 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 659 | "R_PPC_GOT16_HI", /* name */
|
|---|
| 660 | FALSE, /* partial_inplace */
|
|---|
| 661 | 0, /* src_mask */
|
|---|
| 662 | 0xffff, /* dst_mask */
|
|---|
| 663 | FALSE), /* pcrel_offset */
|
|---|
| 664 |
|
|---|
| 665 | /* Like R_PPC_ADDR16_HA, but referring to the GOT table entry for
|
|---|
| 666 | the symbol. */
|
|---|
| 667 | HOWTO (R_PPC_GOT16_HA, /* type */
|
|---|
| 668 | 16, /* rightshift */
|
|---|
| 669 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 670 | 16, /* bitsize */
|
|---|
| 671 | FALSE, /* pc_relative */
|
|---|
| 672 | 0, /* bitpos */
|
|---|
| 673 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 674 | ppc_elf_addr16_ha_reloc, /* special_function */
|
|---|
| 675 | "R_PPC_GOT16_HA", /* name */
|
|---|
| 676 | FALSE, /* partial_inplace */
|
|---|
| 677 | 0, /* src_mask */
|
|---|
| 678 | 0xffff, /* dst_mask */
|
|---|
| 679 | FALSE), /* pcrel_offset */
|
|---|
| 680 |
|
|---|
| 681 | /* Like R_PPC_REL24, but referring to the procedure linkage table
|
|---|
| 682 | entry for the symbol. */
|
|---|
| 683 | HOWTO (R_PPC_PLTREL24, /* type */
|
|---|
| 684 | 0, /* rightshift */
|
|---|
| 685 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 686 | 26, /* bitsize */
|
|---|
| 687 | TRUE, /* pc_relative */
|
|---|
| 688 | 0, /* bitpos */
|
|---|
| 689 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 690 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 691 | "R_PPC_PLTREL24", /* name */
|
|---|
| 692 | FALSE, /* partial_inplace */
|
|---|
| 693 | 0, /* src_mask */
|
|---|
| 694 | 0x3fffffc, /* dst_mask */
|
|---|
| 695 | TRUE), /* pcrel_offset */
|
|---|
| 696 |
|
|---|
| 697 | /* This is used only by the dynamic linker. The symbol should exist
|
|---|
| 698 | both in the object being run and in some shared library. The
|
|---|
| 699 | dynamic linker copies the data addressed by the symbol from the
|
|---|
| 700 | shared library into the object, because the object being
|
|---|
| 701 | run has to have the data at some particular address. */
|
|---|
| 702 | HOWTO (R_PPC_COPY, /* type */
|
|---|
| 703 | 0, /* rightshift */
|
|---|
| 704 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 705 | 32, /* bitsize */
|
|---|
| 706 | FALSE, /* pc_relative */
|
|---|
| 707 | 0, /* bitpos */
|
|---|
| 708 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 709 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 710 | "R_PPC_COPY", /* name */
|
|---|
| 711 | FALSE, /* partial_inplace */
|
|---|
| 712 | 0, /* src_mask */
|
|---|
| 713 | 0, /* dst_mask */
|
|---|
| 714 | FALSE), /* pcrel_offset */
|
|---|
| 715 |
|
|---|
| 716 | /* Like R_PPC_ADDR32, but used when setting global offset table
|
|---|
| 717 | entries. */
|
|---|
| 718 | HOWTO (R_PPC_GLOB_DAT, /* type */
|
|---|
| 719 | 0, /* rightshift */
|
|---|
| 720 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 721 | 32, /* bitsize */
|
|---|
| 722 | FALSE, /* pc_relative */
|
|---|
| 723 | 0, /* bitpos */
|
|---|
| 724 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 725 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 726 | "R_PPC_GLOB_DAT", /* name */
|
|---|
| 727 | FALSE, /* partial_inplace */
|
|---|
| 728 | 0, /* src_mask */
|
|---|
| 729 | 0xffffffff, /* dst_mask */
|
|---|
| 730 | FALSE), /* pcrel_offset */
|
|---|
| 731 |
|
|---|
| 732 | /* Marks a procedure linkage table entry for a symbol. */
|
|---|
| 733 | HOWTO (R_PPC_JMP_SLOT, /* type */
|
|---|
| 734 | 0, /* rightshift */
|
|---|
| 735 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 736 | 32, /* bitsize */
|
|---|
| 737 | FALSE, /* pc_relative */
|
|---|
| 738 | 0, /* bitpos */
|
|---|
| 739 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 740 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 741 | "R_PPC_JMP_SLOT", /* name */
|
|---|
| 742 | FALSE, /* partial_inplace */
|
|---|
| 743 | 0, /* src_mask */
|
|---|
| 744 | 0, /* dst_mask */
|
|---|
| 745 | FALSE), /* pcrel_offset */
|
|---|
| 746 |
|
|---|
| 747 | /* Used only by the dynamic linker. When the object is run, this
|
|---|
| 748 | longword is set to the load address of the object, plus the
|
|---|
| 749 | addend. */
|
|---|
| 750 | HOWTO (R_PPC_RELATIVE, /* type */
|
|---|
| 751 | 0, /* rightshift */
|
|---|
| 752 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 753 | 32, /* bitsize */
|
|---|
| 754 | FALSE, /* pc_relative */
|
|---|
| 755 | 0, /* bitpos */
|
|---|
| 756 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 757 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 758 | "R_PPC_RELATIVE", /* name */
|
|---|
| 759 | FALSE, /* partial_inplace */
|
|---|
| 760 | 0, /* src_mask */
|
|---|
| 761 | 0xffffffff, /* dst_mask */
|
|---|
| 762 | FALSE), /* pcrel_offset */
|
|---|
| 763 |
|
|---|
| 764 | /* Like R_PPC_REL24, but uses the value of the symbol within the
|
|---|
| 765 | object rather than the final value. Normally used for
|
|---|
| 766 | _GLOBAL_OFFSET_TABLE_. */
|
|---|
| 767 | HOWTO (R_PPC_LOCAL24PC, /* type */
|
|---|
| 768 | 0, /* rightshift */
|
|---|
| 769 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 770 | 26, /* bitsize */
|
|---|
| 771 | TRUE, /* pc_relative */
|
|---|
| 772 | 0, /* bitpos */
|
|---|
| 773 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 774 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 775 | "R_PPC_LOCAL24PC", /* name */
|
|---|
| 776 | FALSE, /* partial_inplace */
|
|---|
| 777 | 0, /* src_mask */
|
|---|
| 778 | 0x3fffffc, /* dst_mask */
|
|---|
| 779 | TRUE), /* pcrel_offset */
|
|---|
| 780 |
|
|---|
| 781 | /* Like R_PPC_ADDR32, but may be unaligned. */
|
|---|
| 782 | HOWTO (R_PPC_UADDR32, /* type */
|
|---|
| 783 | 0, /* rightshift */
|
|---|
| 784 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 785 | 32, /* bitsize */
|
|---|
| 786 | FALSE, /* pc_relative */
|
|---|
| 787 | 0, /* bitpos */
|
|---|
| 788 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 789 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 790 | "R_PPC_UADDR32", /* name */
|
|---|
| 791 | FALSE, /* partial_inplace */
|
|---|
| 792 | 0, /* src_mask */
|
|---|
| 793 | 0xffffffff, /* dst_mask */
|
|---|
| 794 | FALSE), /* pcrel_offset */
|
|---|
| 795 |
|
|---|
| 796 | /* Like R_PPC_ADDR16, but may be unaligned. */
|
|---|
| 797 | HOWTO (R_PPC_UADDR16, /* type */
|
|---|
| 798 | 0, /* rightshift */
|
|---|
| 799 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 800 | 16, /* bitsize */
|
|---|
| 801 | FALSE, /* pc_relative */
|
|---|
| 802 | 0, /* bitpos */
|
|---|
| 803 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 804 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 805 | "R_PPC_UADDR16", /* name */
|
|---|
| 806 | FALSE, /* partial_inplace */
|
|---|
| 807 | 0, /* src_mask */
|
|---|
| 808 | 0xffff, /* dst_mask */
|
|---|
| 809 | FALSE), /* pcrel_offset */
|
|---|
| 810 |
|
|---|
| 811 | /* 32-bit PC relative */
|
|---|
| 812 | HOWTO (R_PPC_REL32, /* type */
|
|---|
| 813 | 0, /* rightshift */
|
|---|
| 814 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 815 | 32, /* bitsize */
|
|---|
| 816 | TRUE, /* pc_relative */
|
|---|
| 817 | 0, /* bitpos */
|
|---|
| 818 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 819 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 820 | "R_PPC_REL32", /* name */
|
|---|
| 821 | FALSE, /* partial_inplace */
|
|---|
| 822 | 0, /* src_mask */
|
|---|
| 823 | 0xffffffff, /* dst_mask */
|
|---|
| 824 | TRUE), /* pcrel_offset */
|
|---|
| 825 |
|
|---|
| 826 | /* 32-bit relocation to the symbol's procedure linkage table.
|
|---|
| 827 | FIXME: not supported. */
|
|---|
| 828 | HOWTO (R_PPC_PLT32, /* type */
|
|---|
| 829 | 0, /* rightshift */
|
|---|
| 830 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 831 | 32, /* bitsize */
|
|---|
| 832 | FALSE, /* pc_relative */
|
|---|
| 833 | 0, /* bitpos */
|
|---|
| 834 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 835 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 836 | "R_PPC_PLT32", /* name */
|
|---|
| 837 | FALSE, /* partial_inplace */
|
|---|
| 838 | 0, /* src_mask */
|
|---|
| 839 | 0, /* dst_mask */
|
|---|
| 840 | FALSE), /* pcrel_offset */
|
|---|
| 841 |
|
|---|
| 842 | /* 32-bit PC relative relocation to the symbol's procedure linkage table.
|
|---|
| 843 | FIXME: not supported. */
|
|---|
| 844 | HOWTO (R_PPC_PLTREL32, /* type */
|
|---|
| 845 | 0, /* rightshift */
|
|---|
| 846 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 847 | 32, /* bitsize */
|
|---|
| 848 | TRUE, /* pc_relative */
|
|---|
| 849 | 0, /* bitpos */
|
|---|
| 850 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 851 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 852 | "R_PPC_PLTREL32", /* name */
|
|---|
| 853 | FALSE, /* partial_inplace */
|
|---|
| 854 | 0, /* src_mask */
|
|---|
| 855 | 0, /* dst_mask */
|
|---|
| 856 | TRUE), /* pcrel_offset */
|
|---|
| 857 |
|
|---|
| 858 | /* Like R_PPC_ADDR16_LO, but referring to the PLT table entry for
|
|---|
| 859 | the symbol. */
|
|---|
| 860 | HOWTO (R_PPC_PLT16_LO, /* type */
|
|---|
| 861 | 0, /* rightshift */
|
|---|
| 862 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 863 | 16, /* bitsize */
|
|---|
| 864 | FALSE, /* pc_relative */
|
|---|
| 865 | 0, /* bitpos */
|
|---|
| 866 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 867 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 868 | "R_PPC_PLT16_LO", /* name */
|
|---|
| 869 | FALSE, /* partial_inplace */
|
|---|
| 870 | 0, /* src_mask */
|
|---|
| 871 | 0xffff, /* dst_mask */
|
|---|
| 872 | FALSE), /* pcrel_offset */
|
|---|
| 873 |
|
|---|
| 874 | /* Like R_PPC_ADDR16_HI, but referring to the PLT table entry for
|
|---|
| 875 | the symbol. */
|
|---|
| 876 | HOWTO (R_PPC_PLT16_HI, /* type */
|
|---|
| 877 | 16, /* rightshift */
|
|---|
| 878 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 879 | 16, /* bitsize */
|
|---|
| 880 | FALSE, /* pc_relative */
|
|---|
| 881 | 0, /* bitpos */
|
|---|
| 882 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 883 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 884 | "R_PPC_PLT16_HI", /* name */
|
|---|
| 885 | FALSE, /* partial_inplace */
|
|---|
| 886 | 0, /* src_mask */
|
|---|
| 887 | 0xffff, /* dst_mask */
|
|---|
| 888 | FALSE), /* pcrel_offset */
|
|---|
| 889 |
|
|---|
| 890 | /* Like R_PPC_ADDR16_HA, but referring to the PLT table entry for
|
|---|
| 891 | the symbol. */
|
|---|
| 892 | HOWTO (R_PPC_PLT16_HA, /* type */
|
|---|
| 893 | 16, /* rightshift */
|
|---|
| 894 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 895 | 16, /* bitsize */
|
|---|
| 896 | FALSE, /* pc_relative */
|
|---|
| 897 | 0, /* bitpos */
|
|---|
| 898 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 899 | ppc_elf_addr16_ha_reloc, /* special_function */
|
|---|
| 900 | "R_PPC_PLT16_HA", /* name */
|
|---|
| 901 | FALSE, /* partial_inplace */
|
|---|
| 902 | 0, /* src_mask */
|
|---|
| 903 | 0xffff, /* dst_mask */
|
|---|
| 904 | FALSE), /* pcrel_offset */
|
|---|
| 905 |
|
|---|
| 906 | /* A sign-extended 16 bit value relative to _SDA_BASE_, for use with
|
|---|
| 907 | small data items. */
|
|---|
| 908 | HOWTO (R_PPC_SDAREL16, /* type */
|
|---|
| 909 | 0, /* rightshift */
|
|---|
| 910 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 911 | 16, /* bitsize */
|
|---|
| 912 | FALSE, /* pc_relative */
|
|---|
| 913 | 0, /* bitpos */
|
|---|
| 914 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 915 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 916 | "R_PPC_SDAREL16", /* name */
|
|---|
| 917 | FALSE, /* partial_inplace */
|
|---|
| 918 | 0, /* src_mask */
|
|---|
| 919 | 0xffff, /* dst_mask */
|
|---|
| 920 | FALSE), /* pcrel_offset */
|
|---|
| 921 |
|
|---|
| 922 | /* 16-bit section relative relocation. */
|
|---|
| 923 | HOWTO (R_PPC_SECTOFF, /* type */
|
|---|
| 924 | 0, /* rightshift */
|
|---|
| 925 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 926 | 16, /* bitsize */
|
|---|
| 927 | FALSE, /* pc_relative */
|
|---|
| 928 | 0, /* bitpos */
|
|---|
| 929 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 930 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 931 | "R_PPC_SECTOFF", /* name */
|
|---|
| 932 | FALSE, /* partial_inplace */
|
|---|
| 933 | 0, /* src_mask */
|
|---|
| 934 | 0xffff, /* dst_mask */
|
|---|
| 935 | FALSE), /* pcrel_offset */
|
|---|
| 936 |
|
|---|
| 937 | /* 16-bit lower half section relative relocation. */
|
|---|
| 938 | HOWTO (R_PPC_SECTOFF_LO, /* type */
|
|---|
| 939 | 0, /* rightshift */
|
|---|
| 940 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 941 | 16, /* bitsize */
|
|---|
| 942 | FALSE, /* pc_relative */
|
|---|
| 943 | 0, /* bitpos */
|
|---|
| 944 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 945 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 946 | "R_PPC_SECTOFF_LO", /* name */
|
|---|
| 947 | FALSE, /* partial_inplace */
|
|---|
| 948 | 0, /* src_mask */
|
|---|
| 949 | 0xffff, /* dst_mask */
|
|---|
| 950 | FALSE), /* pcrel_offset */
|
|---|
| 951 |
|
|---|
| 952 | /* 16-bit upper half section relative relocation. */
|
|---|
| 953 | HOWTO (R_PPC_SECTOFF_HI, /* type */
|
|---|
| 954 | 16, /* rightshift */
|
|---|
| 955 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 956 | 16, /* bitsize */
|
|---|
| 957 | FALSE, /* pc_relative */
|
|---|
| 958 | 0, /* bitpos */
|
|---|
| 959 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 960 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 961 | "R_PPC_SECTOFF_HI", /* name */
|
|---|
| 962 | FALSE, /* partial_inplace */
|
|---|
| 963 | 0, /* src_mask */
|
|---|
| 964 | 0xffff, /* dst_mask */
|
|---|
| 965 | FALSE), /* pcrel_offset */
|
|---|
| 966 |
|
|---|
| 967 | /* 16-bit upper half adjusted section relative relocation. */
|
|---|
| 968 | HOWTO (R_PPC_SECTOFF_HA, /* type */
|
|---|
| 969 | 16, /* rightshift */
|
|---|
| 970 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 971 | 16, /* bitsize */
|
|---|
| 972 | FALSE, /* pc_relative */
|
|---|
| 973 | 0, /* bitpos */
|
|---|
| 974 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 975 | ppc_elf_addr16_ha_reloc, /* special_function */
|
|---|
| 976 | "R_PPC_SECTOFF_HA", /* name */
|
|---|
| 977 | FALSE, /* partial_inplace */
|
|---|
| 978 | 0, /* src_mask */
|
|---|
| 979 | 0xffff, /* dst_mask */
|
|---|
| 980 | FALSE), /* pcrel_offset */
|
|---|
| 981 |
|
|---|
| 982 | /* Marker reloc for TLS. */
|
|---|
| 983 | HOWTO (R_PPC_TLS,
|
|---|
| 984 | 0, /* rightshift */
|
|---|
| 985 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 986 | 32, /* bitsize */
|
|---|
| 987 | FALSE, /* pc_relative */
|
|---|
| 988 | 0, /* bitpos */
|
|---|
| 989 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 990 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 991 | "R_PPC_TLS", /* name */
|
|---|
| 992 | FALSE, /* partial_inplace */
|
|---|
| 993 | 0, /* src_mask */
|
|---|
| 994 | 0, /* dst_mask */
|
|---|
| 995 | FALSE), /* pcrel_offset */
|
|---|
| 996 |
|
|---|
| 997 | /* Computes the load module index of the load module that contains the
|
|---|
| 998 | definition of its TLS sym. */
|
|---|
| 999 | HOWTO (R_PPC_DTPMOD32,
|
|---|
| 1000 | 0, /* rightshift */
|
|---|
| 1001 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1002 | 32, /* bitsize */
|
|---|
| 1003 | FALSE, /* pc_relative */
|
|---|
| 1004 | 0, /* bitpos */
|
|---|
| 1005 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1006 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1007 | "R_PPC_DTPMOD32", /* name */
|
|---|
| 1008 | FALSE, /* partial_inplace */
|
|---|
| 1009 | 0, /* src_mask */
|
|---|
| 1010 | 0xffffffff, /* dst_mask */
|
|---|
| 1011 | FALSE), /* pcrel_offset */
|
|---|
| 1012 |
|
|---|
| 1013 | /* Computes a dtv-relative displacement, the difference between the value
|
|---|
| 1014 | of sym+add and the base address of the thread-local storage block that
|
|---|
| 1015 | contains the definition of sym, minus 0x8000. */
|
|---|
| 1016 | HOWTO (R_PPC_DTPREL32,
|
|---|
| 1017 | 0, /* rightshift */
|
|---|
| 1018 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1019 | 32, /* bitsize */
|
|---|
| 1020 | FALSE, /* pc_relative */
|
|---|
| 1021 | 0, /* bitpos */
|
|---|
| 1022 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1023 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1024 | "R_PPC_DTPREL32", /* name */
|
|---|
| 1025 | FALSE, /* partial_inplace */
|
|---|
| 1026 | 0, /* src_mask */
|
|---|
| 1027 | 0xffffffff, /* dst_mask */
|
|---|
| 1028 | FALSE), /* pcrel_offset */
|
|---|
| 1029 |
|
|---|
| 1030 | /* A 16 bit dtprel reloc. */
|
|---|
| 1031 | HOWTO (R_PPC_DTPREL16,
|
|---|
| 1032 | 0, /* rightshift */
|
|---|
| 1033 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1034 | 16, /* bitsize */
|
|---|
| 1035 | FALSE, /* pc_relative */
|
|---|
| 1036 | 0, /* bitpos */
|
|---|
| 1037 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 1038 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1039 | "R_PPC_DTPREL16", /* name */
|
|---|
| 1040 | FALSE, /* partial_inplace */
|
|---|
| 1041 | 0, /* src_mask */
|
|---|
| 1042 | 0xffff, /* dst_mask */
|
|---|
| 1043 | FALSE), /* pcrel_offset */
|
|---|
| 1044 |
|
|---|
| 1045 | /* Like DTPREL16, but no overflow. */
|
|---|
| 1046 | HOWTO (R_PPC_DTPREL16_LO,
|
|---|
| 1047 | 0, /* rightshift */
|
|---|
| 1048 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1049 | 16, /* bitsize */
|
|---|
| 1050 | FALSE, /* pc_relative */
|
|---|
| 1051 | 0, /* bitpos */
|
|---|
| 1052 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1053 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1054 | "R_PPC_DTPREL16_LO", /* name */
|
|---|
| 1055 | FALSE, /* partial_inplace */
|
|---|
| 1056 | 0, /* src_mask */
|
|---|
| 1057 | 0xffff, /* dst_mask */
|
|---|
| 1058 | FALSE), /* pcrel_offset */
|
|---|
| 1059 |
|
|---|
| 1060 | /* Like DTPREL16_LO, but next higher group of 16 bits. */
|
|---|
| 1061 | HOWTO (R_PPC_DTPREL16_HI,
|
|---|
| 1062 | 16, /* rightshift */
|
|---|
| 1063 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1064 | 16, /* bitsize */
|
|---|
| 1065 | FALSE, /* pc_relative */
|
|---|
| 1066 | 0, /* bitpos */
|
|---|
| 1067 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1068 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1069 | "R_PPC_DTPREL16_HI", /* name */
|
|---|
| 1070 | FALSE, /* partial_inplace */
|
|---|
| 1071 | 0, /* src_mask */
|
|---|
| 1072 | 0xffff, /* dst_mask */
|
|---|
| 1073 | FALSE), /* pcrel_offset */
|
|---|
| 1074 |
|
|---|
| 1075 | /* Like DTPREL16_HI, but adjust for low 16 bits. */
|
|---|
| 1076 | HOWTO (R_PPC_DTPREL16_HA,
|
|---|
| 1077 | 16, /* rightshift */
|
|---|
| 1078 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1079 | 16, /* bitsize */
|
|---|
| 1080 | FALSE, /* pc_relative */
|
|---|
| 1081 | 0, /* bitpos */
|
|---|
| 1082 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1083 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1084 | "R_PPC_DTPREL16_HA", /* name */
|
|---|
| 1085 | FALSE, /* partial_inplace */
|
|---|
| 1086 | 0, /* src_mask */
|
|---|
| 1087 | 0xffff, /* dst_mask */
|
|---|
| 1088 | FALSE), /* pcrel_offset */
|
|---|
| 1089 |
|
|---|
| 1090 | /* Computes a tp-relative displacement, the difference between the value of
|
|---|
| 1091 | sym+add and the value of the thread pointer (r13). */
|
|---|
| 1092 | HOWTO (R_PPC_TPREL32,
|
|---|
| 1093 | 0, /* rightshift */
|
|---|
| 1094 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1095 | 32, /* bitsize */
|
|---|
| 1096 | FALSE, /* pc_relative */
|
|---|
| 1097 | 0, /* bitpos */
|
|---|
| 1098 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1099 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1100 | "R_PPC_TPREL32", /* name */
|
|---|
| 1101 | FALSE, /* partial_inplace */
|
|---|
| 1102 | 0, /* src_mask */
|
|---|
| 1103 | 0xffffffff, /* dst_mask */
|
|---|
| 1104 | FALSE), /* pcrel_offset */
|
|---|
| 1105 |
|
|---|
| 1106 | /* A 16 bit tprel reloc. */
|
|---|
| 1107 | HOWTO (R_PPC_TPREL16,
|
|---|
| 1108 | 0, /* rightshift */
|
|---|
| 1109 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1110 | 16, /* bitsize */
|
|---|
| 1111 | FALSE, /* pc_relative */
|
|---|
| 1112 | 0, /* bitpos */
|
|---|
| 1113 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 1114 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1115 | "R_PPC_TPREL16", /* name */
|
|---|
| 1116 | FALSE, /* partial_inplace */
|
|---|
| 1117 | 0, /* src_mask */
|
|---|
| 1118 | 0xffff, /* dst_mask */
|
|---|
| 1119 | FALSE), /* pcrel_offset */
|
|---|
| 1120 |
|
|---|
| 1121 | /* Like TPREL16, but no overflow. */
|
|---|
| 1122 | HOWTO (R_PPC_TPREL16_LO,
|
|---|
| 1123 | 0, /* rightshift */
|
|---|
| 1124 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1125 | 16, /* bitsize */
|
|---|
| 1126 | FALSE, /* pc_relative */
|
|---|
| 1127 | 0, /* bitpos */
|
|---|
| 1128 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1129 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1130 | "R_PPC_TPREL16_LO", /* name */
|
|---|
| 1131 | FALSE, /* partial_inplace */
|
|---|
| 1132 | 0, /* src_mask */
|
|---|
| 1133 | 0xffff, /* dst_mask */
|
|---|
| 1134 | FALSE), /* pcrel_offset */
|
|---|
| 1135 |
|
|---|
| 1136 | /* Like TPREL16_LO, but next higher group of 16 bits. */
|
|---|
| 1137 | HOWTO (R_PPC_TPREL16_HI,
|
|---|
| 1138 | 16, /* rightshift */
|
|---|
| 1139 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1140 | 16, /* bitsize */
|
|---|
| 1141 | FALSE, /* pc_relative */
|
|---|
| 1142 | 0, /* bitpos */
|
|---|
| 1143 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1144 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1145 | "R_PPC_TPREL16_HI", /* name */
|
|---|
| 1146 | FALSE, /* partial_inplace */
|
|---|
| 1147 | 0, /* src_mask */
|
|---|
| 1148 | 0xffff, /* dst_mask */
|
|---|
| 1149 | FALSE), /* pcrel_offset */
|
|---|
| 1150 |
|
|---|
| 1151 | /* Like TPREL16_HI, but adjust for low 16 bits. */
|
|---|
| 1152 | HOWTO (R_PPC_TPREL16_HA,
|
|---|
| 1153 | 16, /* rightshift */
|
|---|
| 1154 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1155 | 16, /* bitsize */
|
|---|
| 1156 | FALSE, /* pc_relative */
|
|---|
| 1157 | 0, /* bitpos */
|
|---|
| 1158 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1159 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1160 | "R_PPC_TPREL16_HA", /* name */
|
|---|
| 1161 | FALSE, /* partial_inplace */
|
|---|
| 1162 | 0, /* src_mask */
|
|---|
| 1163 | 0xffff, /* dst_mask */
|
|---|
| 1164 | FALSE), /* pcrel_offset */
|
|---|
| 1165 |
|
|---|
| 1166 | /* Allocates two contiguous entries in the GOT to hold a tls_index structure,
|
|---|
| 1167 | with values (sym+add)@dtpmod and (sym+add)@dtprel, and computes the offset
|
|---|
| 1168 | to the first entry. */
|
|---|
| 1169 | HOWTO (R_PPC_GOT_TLSGD16,
|
|---|
| 1170 | 0, /* rightshift */
|
|---|
| 1171 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1172 | 16, /* bitsize */
|
|---|
| 1173 | FALSE, /* pc_relative */
|
|---|
| 1174 | 0, /* bitpos */
|
|---|
| 1175 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 1176 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1177 | "R_PPC_GOT_TLSGD16", /* name */
|
|---|
| 1178 | FALSE, /* partial_inplace */
|
|---|
| 1179 | 0, /* src_mask */
|
|---|
| 1180 | 0xffff, /* dst_mask */
|
|---|
| 1181 | FALSE), /* pcrel_offset */
|
|---|
| 1182 |
|
|---|
| 1183 | /* Like GOT_TLSGD16, but no overflow. */
|
|---|
| 1184 | HOWTO (R_PPC_GOT_TLSGD16_LO,
|
|---|
| 1185 | 0, /* rightshift */
|
|---|
| 1186 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1187 | 16, /* bitsize */
|
|---|
| 1188 | FALSE, /* pc_relative */
|
|---|
| 1189 | 0, /* bitpos */
|
|---|
| 1190 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1191 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1192 | "R_PPC_GOT_TLSGD16_LO", /* name */
|
|---|
| 1193 | FALSE, /* partial_inplace */
|
|---|
| 1194 | 0, /* src_mask */
|
|---|
| 1195 | 0xffff, /* dst_mask */
|
|---|
| 1196 | FALSE), /* pcrel_offset */
|
|---|
| 1197 |
|
|---|
| 1198 | /* Like GOT_TLSGD16_LO, but next higher group of 16 bits. */
|
|---|
| 1199 | HOWTO (R_PPC_GOT_TLSGD16_HI,
|
|---|
| 1200 | 16, /* rightshift */
|
|---|
| 1201 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1202 | 16, /* bitsize */
|
|---|
| 1203 | FALSE, /* pc_relative */
|
|---|
| 1204 | 0, /* bitpos */
|
|---|
| 1205 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1206 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1207 | "R_PPC_GOT_TLSGD16_HI", /* name */
|
|---|
| 1208 | FALSE, /* partial_inplace */
|
|---|
| 1209 | 0, /* src_mask */
|
|---|
| 1210 | 0xffff, /* dst_mask */
|
|---|
| 1211 | FALSE), /* pcrel_offset */
|
|---|
| 1212 |
|
|---|
| 1213 | /* Like GOT_TLSGD16_HI, but adjust for low 16 bits. */
|
|---|
| 1214 | HOWTO (R_PPC_GOT_TLSGD16_HA,
|
|---|
| 1215 | 16, /* rightshift */
|
|---|
| 1216 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1217 | 16, /* bitsize */
|
|---|
| 1218 | FALSE, /* pc_relative */
|
|---|
| 1219 | 0, /* bitpos */
|
|---|
| 1220 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1221 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1222 | "R_PPC_GOT_TLSGD16_HA", /* name */
|
|---|
| 1223 | FALSE, /* partial_inplace */
|
|---|
| 1224 | 0, /* src_mask */
|
|---|
| 1225 | 0xffff, /* dst_mask */
|
|---|
| 1226 | FALSE), /* pcrel_offset */
|
|---|
| 1227 |
|
|---|
| 1228 | /* Allocates two contiguous entries in the GOT to hold a tls_index structure,
|
|---|
| 1229 | with values (sym+add)@dtpmod and zero, and computes the offset to the
|
|---|
| 1230 | first entry. */
|
|---|
| 1231 | HOWTO (R_PPC_GOT_TLSLD16,
|
|---|
| 1232 | 0, /* rightshift */
|
|---|
| 1233 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1234 | 16, /* bitsize */
|
|---|
| 1235 | FALSE, /* pc_relative */
|
|---|
| 1236 | 0, /* bitpos */
|
|---|
| 1237 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 1238 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1239 | "R_PPC_GOT_TLSLD16", /* name */
|
|---|
| 1240 | FALSE, /* partial_inplace */
|
|---|
| 1241 | 0, /* src_mask */
|
|---|
| 1242 | 0xffff, /* dst_mask */
|
|---|
| 1243 | FALSE), /* pcrel_offset */
|
|---|
| 1244 |
|
|---|
| 1245 | /* Like GOT_TLSLD16, but no overflow. */
|
|---|
| 1246 | HOWTO (R_PPC_GOT_TLSLD16_LO,
|
|---|
| 1247 | 0, /* rightshift */
|
|---|
| 1248 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1249 | 16, /* bitsize */
|
|---|
| 1250 | FALSE, /* pc_relative */
|
|---|
| 1251 | 0, /* bitpos */
|
|---|
| 1252 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1253 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1254 | "R_PPC_GOT_TLSLD16_LO", /* name */
|
|---|
| 1255 | FALSE, /* partial_inplace */
|
|---|
| 1256 | 0, /* src_mask */
|
|---|
| 1257 | 0xffff, /* dst_mask */
|
|---|
| 1258 | FALSE), /* pcrel_offset */
|
|---|
| 1259 |
|
|---|
| 1260 | /* Like GOT_TLSLD16_LO, but next higher group of 16 bits. */
|
|---|
| 1261 | HOWTO (R_PPC_GOT_TLSLD16_HI,
|
|---|
| 1262 | 16, /* rightshift */
|
|---|
| 1263 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1264 | 16, /* bitsize */
|
|---|
| 1265 | FALSE, /* pc_relative */
|
|---|
| 1266 | 0, /* bitpos */
|
|---|
| 1267 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1268 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1269 | "R_PPC_GOT_TLSLD16_HI", /* name */
|
|---|
| 1270 | FALSE, /* partial_inplace */
|
|---|
| 1271 | 0, /* src_mask */
|
|---|
| 1272 | 0xffff, /* dst_mask */
|
|---|
| 1273 | FALSE), /* pcrel_offset */
|
|---|
| 1274 |
|
|---|
| 1275 | /* Like GOT_TLSLD16_HI, but adjust for low 16 bits. */
|
|---|
| 1276 | HOWTO (R_PPC_GOT_TLSLD16_HA,
|
|---|
| 1277 | 16, /* rightshift */
|
|---|
| 1278 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1279 | 16, /* bitsize */
|
|---|
| 1280 | FALSE, /* pc_relative */
|
|---|
| 1281 | 0, /* bitpos */
|
|---|
| 1282 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1283 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1284 | "R_PPC_GOT_TLSLD16_HA", /* name */
|
|---|
| 1285 | FALSE, /* partial_inplace */
|
|---|
| 1286 | 0, /* src_mask */
|
|---|
| 1287 | 0xffff, /* dst_mask */
|
|---|
| 1288 | FALSE), /* pcrel_offset */
|
|---|
| 1289 |
|
|---|
| 1290 | /* Allocates an entry in the GOT with value (sym+add)@dtprel, and computes
|
|---|
| 1291 | the offset to the entry. */
|
|---|
| 1292 | HOWTO (R_PPC_GOT_DTPREL16,
|
|---|
| 1293 | 0, /* rightshift */
|
|---|
| 1294 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1295 | 16, /* bitsize */
|
|---|
| 1296 | FALSE, /* pc_relative */
|
|---|
| 1297 | 0, /* bitpos */
|
|---|
| 1298 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 1299 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1300 | "R_PPC_GOT_DTPREL16", /* name */
|
|---|
| 1301 | FALSE, /* partial_inplace */
|
|---|
| 1302 | 0, /* src_mask */
|
|---|
| 1303 | 0xffff, /* dst_mask */
|
|---|
| 1304 | FALSE), /* pcrel_offset */
|
|---|
| 1305 |
|
|---|
| 1306 | /* Like GOT_DTPREL16, but no overflow. */
|
|---|
| 1307 | HOWTO (R_PPC_GOT_DTPREL16_LO,
|
|---|
| 1308 | 0, /* rightshift */
|
|---|
| 1309 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1310 | 16, /* bitsize */
|
|---|
| 1311 | FALSE, /* pc_relative */
|
|---|
| 1312 | 0, /* bitpos */
|
|---|
| 1313 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1314 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1315 | "R_PPC_GOT_DTPREL16_LO", /* name */
|
|---|
| 1316 | FALSE, /* partial_inplace */
|
|---|
| 1317 | 0, /* src_mask */
|
|---|
| 1318 | 0xffff, /* dst_mask */
|
|---|
| 1319 | FALSE), /* pcrel_offset */
|
|---|
| 1320 |
|
|---|
| 1321 | /* Like GOT_DTPREL16_LO, but next higher group of 16 bits. */
|
|---|
| 1322 | HOWTO (R_PPC_GOT_DTPREL16_HI,
|
|---|
| 1323 | 16, /* rightshift */
|
|---|
| 1324 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1325 | 16, /* bitsize */
|
|---|
| 1326 | FALSE, /* pc_relative */
|
|---|
| 1327 | 0, /* bitpos */
|
|---|
| 1328 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1329 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1330 | "R_PPC_GOT_DTPREL16_HI", /* name */
|
|---|
| 1331 | FALSE, /* partial_inplace */
|
|---|
| 1332 | 0, /* src_mask */
|
|---|
| 1333 | 0xffff, /* dst_mask */
|
|---|
| 1334 | FALSE), /* pcrel_offset */
|
|---|
| 1335 |
|
|---|
| 1336 | /* Like GOT_DTPREL16_HI, but adjust for low 16 bits. */
|
|---|
| 1337 | HOWTO (R_PPC_GOT_DTPREL16_HA,
|
|---|
| 1338 | 16, /* rightshift */
|
|---|
| 1339 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1340 | 16, /* bitsize */
|
|---|
| 1341 | FALSE, /* pc_relative */
|
|---|
| 1342 | 0, /* bitpos */
|
|---|
| 1343 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1344 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1345 | "R_PPC_GOT_DTPREL16_HA", /* name */
|
|---|
| 1346 | FALSE, /* partial_inplace */
|
|---|
| 1347 | 0, /* src_mask */
|
|---|
| 1348 | 0xffff, /* dst_mask */
|
|---|
| 1349 | FALSE), /* pcrel_offset */
|
|---|
| 1350 |
|
|---|
| 1351 | /* Allocates an entry in the GOT with value (sym+add)@tprel, and computes the
|
|---|
| 1352 | offset to the entry. */
|
|---|
| 1353 | HOWTO (R_PPC_GOT_TPREL16,
|
|---|
| 1354 | 0, /* rightshift */
|
|---|
| 1355 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1356 | 16, /* bitsize */
|
|---|
| 1357 | FALSE, /* pc_relative */
|
|---|
| 1358 | 0, /* bitpos */
|
|---|
| 1359 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 1360 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1361 | "R_PPC_GOT_TPREL16", /* name */
|
|---|
| 1362 | FALSE, /* partial_inplace */
|
|---|
| 1363 | 0, /* src_mask */
|
|---|
| 1364 | 0xffff, /* dst_mask */
|
|---|
| 1365 | FALSE), /* pcrel_offset */
|
|---|
| 1366 |
|
|---|
| 1367 | /* Like GOT_TPREL16, but no overflow. */
|
|---|
| 1368 | HOWTO (R_PPC_GOT_TPREL16_LO,
|
|---|
| 1369 | 0, /* rightshift */
|
|---|
| 1370 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1371 | 16, /* bitsize */
|
|---|
| 1372 | FALSE, /* pc_relative */
|
|---|
| 1373 | 0, /* bitpos */
|
|---|
| 1374 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1375 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1376 | "R_PPC_GOT_TPREL16_LO", /* name */
|
|---|
| 1377 | FALSE, /* partial_inplace */
|
|---|
| 1378 | 0, /* src_mask */
|
|---|
| 1379 | 0xffff, /* dst_mask */
|
|---|
| 1380 | FALSE), /* pcrel_offset */
|
|---|
| 1381 |
|
|---|
| 1382 | /* Like GOT_TPREL16_LO, but next higher group of 16 bits. */
|
|---|
| 1383 | HOWTO (R_PPC_GOT_TPREL16_HI,
|
|---|
| 1384 | 16, /* rightshift */
|
|---|
| 1385 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1386 | 16, /* bitsize */
|
|---|
| 1387 | FALSE, /* pc_relative */
|
|---|
| 1388 | 0, /* bitpos */
|
|---|
| 1389 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1390 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1391 | "R_PPC_GOT_TPREL16_HI", /* name */
|
|---|
| 1392 | FALSE, /* partial_inplace */
|
|---|
| 1393 | 0, /* src_mask */
|
|---|
| 1394 | 0xffff, /* dst_mask */
|
|---|
| 1395 | FALSE), /* pcrel_offset */
|
|---|
| 1396 |
|
|---|
| 1397 | /* Like GOT_TPREL16_HI, but adjust for low 16 bits. */
|
|---|
| 1398 | HOWTO (R_PPC_GOT_TPREL16_HA,
|
|---|
| 1399 | 16, /* rightshift */
|
|---|
| 1400 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1401 | 16, /* bitsize */
|
|---|
| 1402 | FALSE, /* pc_relative */
|
|---|
| 1403 | 0, /* bitpos */
|
|---|
| 1404 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1405 | ppc_elf_unhandled_reloc, /* special_function */
|
|---|
| 1406 | "R_PPC_GOT_TPREL16_HA", /* name */
|
|---|
| 1407 | FALSE, /* partial_inplace */
|
|---|
| 1408 | 0, /* src_mask */
|
|---|
| 1409 | 0xffff, /* dst_mask */
|
|---|
| 1410 | FALSE), /* pcrel_offset */
|
|---|
| 1411 |
|
|---|
| 1412 | /* The remaining relocs are from the Embedded ELF ABI, and are not
|
|---|
| 1413 | in the SVR4 ELF ABI. */
|
|---|
| 1414 |
|
|---|
| 1415 | /* 32 bit value resulting from the addend minus the symbol. */
|
|---|
| 1416 | HOWTO (R_PPC_EMB_NADDR32, /* type */
|
|---|
| 1417 | 0, /* rightshift */
|
|---|
| 1418 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1419 | 32, /* bitsize */
|
|---|
| 1420 | FALSE, /* pc_relative */
|
|---|
| 1421 | 0, /* bitpos */
|
|---|
| 1422 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 1423 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 1424 | "R_PPC_EMB_NADDR32", /* name */
|
|---|
| 1425 | FALSE, /* partial_inplace */
|
|---|
| 1426 | 0, /* src_mask */
|
|---|
| 1427 | 0xffffffff, /* dst_mask */
|
|---|
| 1428 | FALSE), /* pcrel_offset */
|
|---|
| 1429 |
|
|---|
| 1430 | /* 16 bit value resulting from the addend minus the symbol. */
|
|---|
| 1431 | HOWTO (R_PPC_EMB_NADDR16, /* type */
|
|---|
| 1432 | 0, /* rightshift */
|
|---|
| 1433 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1434 | 16, /* bitsize */
|
|---|
| 1435 | FALSE, /* pc_relative */
|
|---|
| 1436 | 0, /* bitpos */
|
|---|
| 1437 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 1438 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 1439 | "R_PPC_EMB_NADDR16", /* name */
|
|---|
| 1440 | FALSE, /* partial_inplace */
|
|---|
| 1441 | 0, /* src_mask */
|
|---|
| 1442 | 0xffff, /* dst_mask */
|
|---|
| 1443 | FALSE), /* pcrel_offset */
|
|---|
| 1444 |
|
|---|
| 1445 | /* 16 bit value resulting from the addend minus the symbol. */
|
|---|
| 1446 | HOWTO (R_PPC_EMB_NADDR16_LO, /* type */
|
|---|
| 1447 | 0, /* rightshift */
|
|---|
| 1448 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1449 | 16, /* bitsize */
|
|---|
| 1450 | FALSE, /* pc_relative */
|
|---|
| 1451 | 0, /* bitpos */
|
|---|
| 1452 | complain_overflow_dont,/* complain_on_overflow */
|
|---|
| 1453 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 1454 | "R_PPC_EMB_ADDR16_LO", /* name */
|
|---|
| 1455 | FALSE, /* partial_inplace */
|
|---|
| 1456 | 0, /* src_mask */
|
|---|
| 1457 | 0xffff, /* dst_mask */
|
|---|
| 1458 | FALSE), /* pcrel_offset */
|
|---|
| 1459 |
|
|---|
| 1460 | /* The high order 16 bits of the addend minus the symbol. */
|
|---|
| 1461 | HOWTO (R_PPC_EMB_NADDR16_HI, /* type */
|
|---|
| 1462 | 16, /* rightshift */
|
|---|
| 1463 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1464 | 16, /* bitsize */
|
|---|
| 1465 | FALSE, /* pc_relative */
|
|---|
| 1466 | 0, /* bitpos */
|
|---|
| 1467 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1468 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 1469 | "R_PPC_EMB_NADDR16_HI", /* name */
|
|---|
| 1470 | FALSE, /* partial_inplace */
|
|---|
| 1471 | 0, /* src_mask */
|
|---|
| 1472 | 0xffff, /* dst_mask */
|
|---|
| 1473 | FALSE), /* pcrel_offset */
|
|---|
| 1474 |
|
|---|
| 1475 | /* The high order 16 bits of the result of the addend minus the address,
|
|---|
| 1476 | plus 1 if the contents of the low 16 bits, treated as a signed number,
|
|---|
| 1477 | is negative. */
|
|---|
| 1478 | HOWTO (R_PPC_EMB_NADDR16_HA, /* type */
|
|---|
| 1479 | 16, /* rightshift */
|
|---|
| 1480 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1481 | 16, /* bitsize */
|
|---|
| 1482 | FALSE, /* pc_relative */
|
|---|
| 1483 | 0, /* bitpos */
|
|---|
| 1484 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1485 | ppc_elf_addr16_ha_reloc, /* special_function */
|
|---|
| 1486 | "R_PPC_EMB_NADDR16_HA", /* name */
|
|---|
| 1487 | FALSE, /* partial_inplace */
|
|---|
| 1488 | 0, /* src_mask */
|
|---|
| 1489 | 0xffff, /* dst_mask */
|
|---|
| 1490 | FALSE), /* pcrel_offset */
|
|---|
| 1491 |
|
|---|
| 1492 | /* 16 bit value resulting from allocating a 4 byte word to hold an
|
|---|
| 1493 | address in the .sdata section, and returning the offset from
|
|---|
| 1494 | _SDA_BASE_ for that relocation. */
|
|---|
| 1495 | HOWTO (R_PPC_EMB_SDAI16, /* type */
|
|---|
| 1496 | 0, /* rightshift */
|
|---|
| 1497 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1498 | 16, /* bitsize */
|
|---|
| 1499 | FALSE, /* pc_relative */
|
|---|
| 1500 | 0, /* bitpos */
|
|---|
| 1501 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 1502 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 1503 | "R_PPC_EMB_SDAI16", /* name */
|
|---|
| 1504 | FALSE, /* partial_inplace */
|
|---|
| 1505 | 0, /* src_mask */
|
|---|
| 1506 | 0xffff, /* dst_mask */
|
|---|
| 1507 | FALSE), /* pcrel_offset */
|
|---|
| 1508 |
|
|---|
| 1509 | /* 16 bit value resulting from allocating a 4 byte word to hold an
|
|---|
| 1510 | address in the .sdata2 section, and returning the offset from
|
|---|
| 1511 | _SDA2_BASE_ for that relocation. */
|
|---|
| 1512 | HOWTO (R_PPC_EMB_SDA2I16, /* type */
|
|---|
| 1513 | 0, /* rightshift */
|
|---|
| 1514 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1515 | 16, /* bitsize */
|
|---|
| 1516 | FALSE, /* pc_relative */
|
|---|
| 1517 | 0, /* bitpos */
|
|---|
| 1518 | complain_overflow_bitfield, /* complain_on_overflow */
|
|---|
| 1519 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 1520 | "R_PPC_EMB_SDA2I16", /* name */
|
|---|
| 1521 | FALSE, /* partial_inplace */
|
|---|
| 1522 | 0, /* src_mask */
|
|---|
| 1523 | 0xffff, /* dst_mask */
|
|---|
| 1524 | FALSE), /* pcrel_offset */
|
|---|
| 1525 |
|
|---|
| 1526 | /* A sign-extended 16 bit value relative to _SDA2_BASE_, for use with
|
|---|
| 1527 | small data items. */
|
|---|
| 1528 | HOWTO (R_PPC_EMB_SDA2REL, /* type */
|
|---|
| 1529 | 0, /* rightshift */
|
|---|
| 1530 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1531 | 16, /* bitsize */
|
|---|
| 1532 | FALSE, /* pc_relative */
|
|---|
| 1533 | 0, /* bitpos */
|
|---|
| 1534 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 1535 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 1536 | "R_PPC_EMB_SDA2REL", /* name */
|
|---|
| 1537 | FALSE, /* partial_inplace */
|
|---|
| 1538 | 0, /* src_mask */
|
|---|
| 1539 | 0xffff, /* dst_mask */
|
|---|
| 1540 | FALSE), /* pcrel_offset */
|
|---|
| 1541 |
|
|---|
| 1542 | /* Relocate against either _SDA_BASE_ or _SDA2_BASE_, filling in the 16 bit
|
|---|
| 1543 | signed offset from the appropriate base, and filling in the register
|
|---|
| 1544 | field with the appropriate register (0, 2, or 13). */
|
|---|
| 1545 | HOWTO (R_PPC_EMB_SDA21, /* type */
|
|---|
| 1546 | 0, /* rightshift */
|
|---|
| 1547 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1548 | 16, /* bitsize */
|
|---|
| 1549 | FALSE, /* pc_relative */
|
|---|
| 1550 | 0, /* bitpos */
|
|---|
| 1551 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 1552 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 1553 | "R_PPC_EMB_SDA21", /* name */
|
|---|
| 1554 | FALSE, /* partial_inplace */
|
|---|
| 1555 | 0, /* src_mask */
|
|---|
| 1556 | 0xffff, /* dst_mask */
|
|---|
| 1557 | FALSE), /* pcrel_offset */
|
|---|
| 1558 |
|
|---|
| 1559 | /* Relocation not handled: R_PPC_EMB_MRKREF */
|
|---|
| 1560 | /* Relocation not handled: R_PPC_EMB_RELSEC16 */
|
|---|
| 1561 | /* Relocation not handled: R_PPC_EMB_RELST_LO */
|
|---|
| 1562 | /* Relocation not handled: R_PPC_EMB_RELST_HI */
|
|---|
| 1563 | /* Relocation not handled: R_PPC_EMB_RELST_HA */
|
|---|
| 1564 | /* Relocation not handled: R_PPC_EMB_BIT_FLD */
|
|---|
| 1565 |
|
|---|
| 1566 | /* PC relative relocation against either _SDA_BASE_ or _SDA2_BASE_, filling
|
|---|
| 1567 | in the 16 bit signed offset from the appropriate base, and filling in the
|
|---|
| 1568 | register field with the appropriate register (0, 2, or 13). */
|
|---|
| 1569 | HOWTO (R_PPC_EMB_RELSDA, /* type */
|
|---|
| 1570 | 0, /* rightshift */
|
|---|
| 1571 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1572 | 16, /* bitsize */
|
|---|
| 1573 | TRUE, /* pc_relative */
|
|---|
| 1574 | 0, /* bitpos */
|
|---|
| 1575 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 1576 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 1577 | "R_PPC_EMB_RELSDA", /* name */
|
|---|
| 1578 | FALSE, /* partial_inplace */
|
|---|
| 1579 | 0, /* src_mask */
|
|---|
| 1580 | 0xffff, /* dst_mask */
|
|---|
| 1581 | FALSE), /* pcrel_offset */
|
|---|
| 1582 |
|
|---|
| 1583 | /* GNU extension to record C++ vtable hierarchy. */
|
|---|
| 1584 | HOWTO (R_PPC_GNU_VTINHERIT, /* type */
|
|---|
| 1585 | 0, /* rightshift */
|
|---|
| 1586 | 0, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1587 | 0, /* bitsize */
|
|---|
| 1588 | FALSE, /* pc_relative */
|
|---|
| 1589 | 0, /* bitpos */
|
|---|
| 1590 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1591 | NULL, /* special_function */
|
|---|
| 1592 | "R_PPC_GNU_VTINHERIT", /* name */
|
|---|
| 1593 | FALSE, /* partial_inplace */
|
|---|
| 1594 | 0, /* src_mask */
|
|---|
| 1595 | 0, /* dst_mask */
|
|---|
| 1596 | FALSE), /* pcrel_offset */
|
|---|
| 1597 |
|
|---|
| 1598 | /* GNU extension to record C++ vtable member usage. */
|
|---|
| 1599 | HOWTO (R_PPC_GNU_VTENTRY, /* type */
|
|---|
| 1600 | 0, /* rightshift */
|
|---|
| 1601 | 0, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1602 | 0, /* bitsize */
|
|---|
| 1603 | FALSE, /* pc_relative */
|
|---|
| 1604 | 0, /* bitpos */
|
|---|
| 1605 | complain_overflow_dont, /* complain_on_overflow */
|
|---|
| 1606 | NULL, /* special_function */
|
|---|
| 1607 | "R_PPC_GNU_VTENTRY", /* name */
|
|---|
| 1608 | FALSE, /* partial_inplace */
|
|---|
| 1609 | 0, /* src_mask */
|
|---|
| 1610 | 0, /* dst_mask */
|
|---|
| 1611 | FALSE), /* pcrel_offset */
|
|---|
| 1612 |
|
|---|
| 1613 | /* Phony reloc to handle AIX style TOC entries. */
|
|---|
| 1614 | HOWTO (R_PPC_TOC16, /* type */
|
|---|
| 1615 | 0, /* rightshift */
|
|---|
| 1616 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
|---|
| 1617 | 16, /* bitsize */
|
|---|
| 1618 | FALSE, /* pc_relative */
|
|---|
| 1619 | 0, /* bitpos */
|
|---|
| 1620 | complain_overflow_signed, /* complain_on_overflow */
|
|---|
| 1621 | bfd_elf_generic_reloc, /* special_function */
|
|---|
| 1622 | "R_PPC_TOC16", /* name */
|
|---|
| 1623 | FALSE, /* partial_inplace */
|
|---|
| 1624 | 0, /* src_mask */
|
|---|
| 1625 | 0xffff, /* dst_mask */
|
|---|
| 1626 | FALSE), /* pcrel_offset */
|
|---|
| 1627 | };
|
|---|
| 1628 | |
|---|
| 1629 |
|
|---|
| 1630 | /* Initialize the ppc_elf_howto_table, so that linear accesses can be done. */
|
|---|
| 1631 |
|
|---|
| 1632 | static void
|
|---|
| 1633 | ppc_elf_howto_init ()
|
|---|
| 1634 | {
|
|---|
| 1635 | unsigned int i, type;
|
|---|
| 1636 |
|
|---|
| 1637 | for (i = 0;
|
|---|
| 1638 | i < sizeof (ppc_elf_howto_raw) / sizeof (ppc_elf_howto_raw[0]);
|
|---|
| 1639 | i++)
|
|---|
| 1640 | {
|
|---|
| 1641 | type = ppc_elf_howto_raw[i].type;
|
|---|
| 1642 | if (type >= (sizeof (ppc_elf_howto_table)
|
|---|
| 1643 | / sizeof (ppc_elf_howto_table[0])))
|
|---|
| 1644 | abort ();
|
|---|
| 1645 | ppc_elf_howto_table[type] = &ppc_elf_howto_raw[i];
|
|---|
| 1646 | }
|
|---|
| 1647 | }
|
|---|
| 1648 | |
|---|
| 1649 |
|
|---|
| 1650 | /* This function handles relaxing for the PPC with option --mpc860c0[=<n>].
|
|---|
| 1651 |
|
|---|
| 1652 | The MPC860, revision C0 or earlier contains a bug in the die.
|
|---|
| 1653 | If all of the following conditions are true, the next instruction
|
|---|
| 1654 | to be executed *may* be treated as a no-op.
|
|---|
| 1655 | 1/ A forward branch is executed.
|
|---|
| 1656 | 2/ The branch is predicted as not taken.
|
|---|
| 1657 | 3/ The branch is taken.
|
|---|
| 1658 | 4/ The branch is located in the last 5 words of a page.
|
|---|
| 1659 | (The EOP limit is 5 by default but may be specified as any value
|
|---|
| 1660 | from 1-10.)
|
|---|
| 1661 |
|
|---|
| 1662 | Our software solution is to detect these problematic branches in a
|
|---|
| 1663 | linker pass and modify them as follows:
|
|---|
| 1664 | 1/ Unconditional branches - Since these are always predicted taken,
|
|---|
| 1665 | there is no problem and no action is required.
|
|---|
| 1666 | 2/ Conditional backward branches - No problem, no action required.
|
|---|
| 1667 | 3/ Conditional forward branches - Ensure that the "inverse prediction
|
|---|
| 1668 | bit" is set (ensure it is predicted taken).
|
|---|
| 1669 | 4/ Conditional register branches - Ensure that the "y bit" is set
|
|---|
| 1670 | (ensure it is predicted taken). */
|
|---|
| 1671 |
|
|---|
| 1672 | /* Sort sections by address. */
|
|---|
| 1673 |
|
|---|
| 1674 | static int
|
|---|
| 1675 | ppc_elf_sort_rela (arg1, arg2)
|
|---|
| 1676 | const PTR arg1;
|
|---|
| 1677 | const PTR arg2;
|
|---|
| 1678 | {
|
|---|
| 1679 | const Elf_Internal_Rela **rela1 = (const Elf_Internal_Rela**) arg1;
|
|---|
| 1680 | const Elf_Internal_Rela **rela2 = (const Elf_Internal_Rela**) arg2;
|
|---|
| 1681 |
|
|---|
| 1682 | /* Sort by offset. */
|
|---|
| 1683 | return ((*rela1)->r_offset - (*rela2)->r_offset);
|
|---|
| 1684 | }
|
|---|
| 1685 |
|
|---|
| 1686 | static bfd_boolean
|
|---|
| 1687 | ppc_elf_relax_section (abfd, isec, link_info, again)
|
|---|
| 1688 | bfd *abfd;
|
|---|
| 1689 | asection *isec;
|
|---|
| 1690 | struct bfd_link_info *link_info;
|
|---|
| 1691 | bfd_boolean *again;
|
|---|
| 1692 | {
|
|---|
| 1693 | #define PAGESIZE 0x1000
|
|---|
| 1694 |
|
|---|
| 1695 | bfd_byte *contents = NULL;
|
|---|
| 1696 | bfd_byte *free_contents = NULL;
|
|---|
| 1697 | Elf_Internal_Rela *internal_relocs = NULL;
|
|---|
| 1698 | Elf_Internal_Rela *free_relocs = NULL;
|
|---|
| 1699 | Elf_Internal_Rela **rela_comb = NULL;
|
|---|
| 1700 | int comb_curr, comb_count;
|
|---|
| 1701 |
|
|---|
| 1702 | /* We never have to do this more than once per input section. */
|
|---|
| 1703 | *again = FALSE;
|
|---|
| 1704 |
|
|---|
| 1705 | /* If needed, initialize this section's cooked size. */
|
|---|
| 1706 | if (isec->_cooked_size == 0)
|
|---|
| 1707 | isec->_cooked_size = isec->_raw_size;
|
|---|
| 1708 |
|
|---|
| 1709 | /* We're only interested in text sections which overlap the
|
|---|
| 1710 | troublesome area at the end of a page. */
|
|---|
| 1711 | if (link_info->mpc860c0 && (isec->flags & SEC_CODE) && isec->_cooked_size)
|
|---|
| 1712 | {
|
|---|
| 1713 | bfd_vma dot, end_page, end_section;
|
|---|
| 1714 | bfd_boolean section_modified;
|
|---|
| 1715 |
|
|---|
| 1716 | /* Get the section contents. */
|
|---|
| 1717 | /* Get cached copy if it exists. */
|
|---|
| 1718 | if (elf_section_data (isec)->this_hdr.contents != NULL)
|
|---|
| 1719 | contents = elf_section_data (isec)->this_hdr.contents;
|
|---|
| 1720 | else
|
|---|
| 1721 | {
|
|---|
| 1722 | /* Go get them off disk. */
|
|---|
| 1723 | contents = (bfd_byte *) bfd_malloc (isec->_raw_size);
|
|---|
| 1724 | if (contents == NULL)
|
|---|
| 1725 | goto error_return;
|
|---|
| 1726 | free_contents = contents;
|
|---|
| 1727 |
|
|---|
| 1728 | if (! bfd_get_section_contents (abfd, isec, contents,
|
|---|
| 1729 | (file_ptr) 0, isec->_raw_size))
|
|---|
| 1730 | goto error_return;
|
|---|
| 1731 | }
|
|---|
| 1732 |
|
|---|
| 1733 | comb_curr = 0;
|
|---|
| 1734 | comb_count = 0;
|
|---|
| 1735 | if (isec->reloc_count)
|
|---|
| 1736 | {
|
|---|
| 1737 | unsigned n;
|
|---|
| 1738 | bfd_size_type amt;
|
|---|
| 1739 |
|
|---|
| 1740 | /* Get a copy of the native relocations. */
|
|---|
| 1741 | internal_relocs
|
|---|
| 1742 | = _bfd_elf32_link_read_relocs (abfd, isec, (PTR) NULL,
|
|---|
| 1743 | (Elf_Internal_Rela *) NULL,
|
|---|
| 1744 | link_info->keep_memory);
|
|---|
| 1745 | if (internal_relocs == NULL)
|
|---|
| 1746 | goto error_return;
|
|---|
| 1747 | if (! link_info->keep_memory)
|
|---|
| 1748 | free_relocs = internal_relocs;
|
|---|
| 1749 |
|
|---|
| 1750 | /* Setup a faster access method for the reloc info we need. */
|
|---|
| 1751 | amt = isec->reloc_count;
|
|---|
| 1752 | amt *= sizeof (Elf_Internal_Rela*);
|
|---|
| 1753 | rela_comb = (Elf_Internal_Rela**) bfd_malloc (amt);
|
|---|
| 1754 | if (rela_comb == NULL)
|
|---|
| 1755 | goto error_return;
|
|---|
| 1756 | for (n = 0; n < isec->reloc_count; ++n)
|
|---|
| 1757 | {
|
|---|
| 1758 | long r_type;
|
|---|
| 1759 |
|
|---|
| 1760 | r_type = ELF32_R_TYPE (internal_relocs[n].r_info);
|
|---|
| 1761 | if (r_type < 0 || r_type >= (int) R_PPC_max)
|
|---|
| 1762 | goto error_return;
|
|---|
| 1763 |
|
|---|
| 1764 | /* Prologue constants are sometimes present in the ".text"
|
|---|
| 1765 | sections and they can be identified by their associated
|
|---|
| 1766 | relocation. We don't want to process those words and
|
|---|
| 1767 | some others which can also be identified by their
|
|---|
| 1768 | relocations. However, not all conditional branches will
|
|---|
| 1769 | have a relocation so we will only ignore words that
|
|---|
| 1770 | 1) have a reloc, and 2) the reloc is not applicable to a
|
|---|
| 1771 | conditional branch. The array rela_comb is built here
|
|---|
| 1772 | for use in the EOP scan loop. */
|
|---|
| 1773 | switch (r_type)
|
|---|
| 1774 | {
|
|---|
| 1775 | case R_PPC_ADDR14_BRNTAKEN:
|
|---|
| 1776 | case R_PPC_REL14:
|
|---|
| 1777 | case R_PPC_REL14_BRNTAKEN:
|
|---|
| 1778 | /* We should check the instruction. */
|
|---|
| 1779 | break;
|
|---|
| 1780 | default:
|
|---|
| 1781 | /* The word is not a conditional branch - ignore it. */
|
|---|
| 1782 | rela_comb[comb_count++] = &internal_relocs[n];
|
|---|
| 1783 | break;
|
|---|
| 1784 | }
|
|---|
| 1785 | }
|
|---|
| 1786 | if (comb_count > 1)
|
|---|
| 1787 | qsort (rela_comb, (size_t) comb_count, sizeof (int),
|
|---|
| 1788 | ppc_elf_sort_rela);
|
|---|
| 1789 | }
|
|---|
| 1790 |
|
|---|
| 1791 | /* Enumerate each EOP region that overlaps this section. */
|
|---|
| 1792 | end_section = isec->vma + isec->_cooked_size;
|
|---|
| 1793 | dot = end_page = (isec->vma | (PAGESIZE - 1)) + 1;
|
|---|
| 1794 | dot -= link_info->mpc860c0;
|
|---|
| 1795 | section_modified = FALSE;
|
|---|
| 1796 | /* Increment the start position if this section begins in the
|
|---|
| 1797 | middle of its first EOP region. */
|
|---|
| 1798 | if (dot < isec->vma)
|
|---|
| 1799 | dot = isec->vma;
|
|---|
| 1800 | for (;
|
|---|
| 1801 | dot < end_section;
|
|---|
| 1802 | dot += PAGESIZE, end_page += PAGESIZE)
|
|---|
| 1803 | {
|
|---|
| 1804 | /* Check each word in this EOP region. */
|
|---|
| 1805 | for (; dot < end_page; dot += 4)
|
|---|
| 1806 | {
|
|---|
| 1807 | bfd_vma isec_offset;
|
|---|
| 1808 | unsigned long insn;
|
|---|
| 1809 | bfd_boolean skip, modified;
|
|---|
| 1810 |
|
|---|
| 1811 | /* Don't process this word if there is a relocation for it
|
|---|
| 1812 | and the relocation indicates the word is not a
|
|---|
| 1813 | conditional branch. */
|
|---|
| 1814 | skip = FALSE;
|
|---|
| 1815 | isec_offset = dot - isec->vma;
|
|---|
| 1816 | for (; comb_curr<comb_count; ++comb_curr)
|
|---|
| 1817 | {
|
|---|
| 1818 | bfd_vma r_offset;
|
|---|
| 1819 |
|
|---|
| 1820 | r_offset = rela_comb[comb_curr]->r_offset;
|
|---|
| 1821 | if (r_offset >= isec_offset)
|
|---|
| 1822 | {
|
|---|
| 1823 | if (r_offset == isec_offset) skip = TRUE;
|
|---|
| 1824 | break;
|
|---|
| 1825 | }
|
|---|
| 1826 | }
|
|---|
| 1827 | if (skip) continue;
|
|---|
| 1828 |
|
|---|
| 1829 | /* Check the current word for a problematic conditional
|
|---|
| 1830 | branch. */
|
|---|
| 1831 | #define BO0(insn) ((insn) & 0x02000000)
|
|---|
| 1832 | #define BO2(insn) ((insn) & 0x00800000)
|
|---|
| 1833 | #define BO4(insn) ((insn) & 0x00200000)
|
|---|
| 1834 | insn = (unsigned long) bfd_get_32 (abfd, contents + isec_offset);
|
|---|
| 1835 | modified = FALSE;
|
|---|
| 1836 | if ((insn & 0xFc000000) == 0x40000000)
|
|---|
| 1837 | {
|
|---|
| 1838 | /* Instruction is BCx */
|
|---|
| 1839 | if ((!BO0(insn) || !BO2(insn)) && !BO4(insn))
|
|---|
| 1840 | {
|
|---|
| 1841 | bfd_vma target;
|
|---|
| 1842 |
|
|---|
| 1843 | /* This branch is predicted as "normal".
|
|---|
| 1844 | If this is a forward branch, it is problematic. */
|
|---|
| 1845 | target = insn & 0x0000Fffc;
|
|---|
| 1846 | target = (target ^ 0x8000) - 0x8000;
|
|---|
| 1847 | if ((insn & 0x00000002) == 0)
|
|---|
| 1848 | /* Convert to abs. */
|
|---|
| 1849 | target += dot;
|
|---|
| 1850 | if (target > dot)
|
|---|
| 1851 | {
|
|---|
| 1852 | /* Set the prediction bit. */
|
|---|
| 1853 | insn |= 0x00200000;
|
|---|
| 1854 | modified = TRUE;
|
|---|
| 1855 | }
|
|---|
| 1856 | }
|
|---|
| 1857 | }
|
|---|
| 1858 | else if ((insn & 0xFc00Fffe) == 0x4c000420)
|
|---|
| 1859 | {
|
|---|
| 1860 | /* Instruction is BCCTRx. */
|
|---|
| 1861 | if ((!BO0(insn) || !BO2(insn)) && !BO4(insn))
|
|---|
| 1862 | {
|
|---|
| 1863 | /* This branch is predicted as not-taken.
|
|---|
| 1864 | If this is a forward branch, it is problematic.
|
|---|
| 1865 | Since we can't tell statically if it will branch
|
|---|
| 1866 | forward, always set the prediction bit. */
|
|---|
| 1867 | insn |= 0x00200000;
|
|---|
| 1868 | modified = TRUE;
|
|---|
| 1869 | }
|
|---|
| 1870 | }
|
|---|
| 1871 | else if ((insn & 0xFc00Fffe) == 0x4c000020)
|
|---|
| 1872 | {
|
|---|
| 1873 | /* Instruction is BCLRx */
|
|---|
| 1874 | if ((!BO0(insn) || !BO2(insn)) && !BO4(insn))
|
|---|
| 1875 | {
|
|---|
| 1876 | /* This branch is predicted as not-taken.
|
|---|
| 1877 | If this is a forward branch, it is problematic.
|
|---|
| 1878 | Since we can't tell statically if it will branch
|
|---|
| 1879 | forward, always set the prediction bit. */
|
|---|
| 1880 | insn |= 0x00200000;
|
|---|
| 1881 | modified = TRUE;
|
|---|
| 1882 | }
|
|---|
| 1883 | }
|
|---|
| 1884 | #undef BO0
|
|---|
| 1885 | #undef BO2
|
|---|
| 1886 | #undef BO4
|
|---|
| 1887 | if (modified)
|
|---|
| 1888 | {
|
|---|
| 1889 | bfd_put_32 (abfd, (bfd_vma) insn, contents + isec_offset);
|
|---|
| 1890 | section_modified = TRUE;
|
|---|
| 1891 | }
|
|---|
| 1892 | }
|
|---|
| 1893 | }
|
|---|
| 1894 | if (section_modified)
|
|---|
| 1895 | {
|
|---|
| 1896 | elf_section_data (isec)->this_hdr.contents = contents;
|
|---|
| 1897 | free_contents = NULL;
|
|---|
| 1898 | }
|
|---|
| 1899 | }
|
|---|
| 1900 |
|
|---|
| 1901 | if (rela_comb != NULL)
|
|---|
| 1902 | {
|
|---|
| 1903 | free (rela_comb);
|
|---|
| 1904 | rela_comb = NULL;
|
|---|
| 1905 | }
|
|---|
| 1906 |
|
|---|
| 1907 | if (free_relocs != NULL)
|
|---|
| 1908 | {
|
|---|
| 1909 | free (free_relocs);
|
|---|
| 1910 | free_relocs = NULL;
|
|---|
| 1911 | }
|
|---|
| 1912 |
|
|---|
| 1913 | if (free_contents != NULL)
|
|---|
| 1914 | {
|
|---|
| 1915 | if (! link_info->keep_memory)
|
|---|
| 1916 | free (free_contents);
|
|---|
| 1917 | else
|
|---|
| 1918 | {
|
|---|
| 1919 | /* Cache the section contents for elf_link_input_bfd. */
|
|---|
| 1920 | elf_section_data (isec)->this_hdr.contents = contents;
|
|---|
| 1921 | }
|
|---|
| 1922 | free_contents = NULL;
|
|---|
| 1923 | }
|
|---|
| 1924 |
|
|---|
| 1925 | return TRUE;
|
|---|
| 1926 |
|
|---|
| 1927 | error_return:
|
|---|
| 1928 | if (rela_comb != NULL)
|
|---|
| 1929 | free (rela_comb);
|
|---|
| 1930 | if (free_relocs != NULL)
|
|---|
| 1931 | free (free_relocs);
|
|---|
| 1932 | if (free_contents != NULL)
|
|---|
| 1933 | free (free_contents);
|
|---|
| 1934 | return FALSE;
|
|---|
| 1935 | }
|
|---|
| 1936 | |
|---|
| 1937 |
|
|---|
| 1938 | static reloc_howto_type *
|
|---|
| 1939 | ppc_elf_reloc_type_lookup (abfd, code)
|
|---|
| 1940 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 1941 | bfd_reloc_code_real_type code;
|
|---|
| 1942 | {
|
|---|
| 1943 | enum elf_ppc_reloc_type r;
|
|---|
| 1944 |
|
|---|
| 1945 | if (!ppc_elf_howto_table[R_PPC_ADDR32])
|
|---|
| 1946 | /* Initialize howto table if needed. */
|
|---|
| 1947 | ppc_elf_howto_init ();
|
|---|
| 1948 |
|
|---|
| 1949 | switch ((int) code)
|
|---|
| 1950 | {
|
|---|
| 1951 | default:
|
|---|
| 1952 | return (reloc_howto_type *) NULL;
|
|---|
| 1953 |
|
|---|
| 1954 | case BFD_RELOC_NONE: r = R_PPC_NONE; break;
|
|---|
| 1955 | case BFD_RELOC_32: r = R_PPC_ADDR32; break;
|
|---|
| 1956 | case BFD_RELOC_PPC_BA26: r = R_PPC_ADDR24; break;
|
|---|
| 1957 | case BFD_RELOC_16: r = R_PPC_ADDR16; break;
|
|---|
| 1958 | case BFD_RELOC_LO16: r = R_PPC_ADDR16_LO; break;
|
|---|
| 1959 | case BFD_RELOC_HI16: r = R_PPC_ADDR16_HI; break;
|
|---|
| 1960 | case BFD_RELOC_HI16_S: r = R_PPC_ADDR16_HA; break;
|
|---|
| 1961 | case BFD_RELOC_PPC_BA16: r = R_PPC_ADDR14; break;
|
|---|
| 1962 | case BFD_RELOC_PPC_BA16_BRTAKEN: r = R_PPC_ADDR14_BRTAKEN; break;
|
|---|
| 1963 | case BFD_RELOC_PPC_BA16_BRNTAKEN: r = R_PPC_ADDR14_BRNTAKEN; break;
|
|---|
| 1964 | case BFD_RELOC_PPC_B26: r = R_PPC_REL24; break;
|
|---|
| 1965 | case BFD_RELOC_PPC_B16: r = R_PPC_REL14; break;
|
|---|
| 1966 | case BFD_RELOC_PPC_B16_BRTAKEN: r = R_PPC_REL14_BRTAKEN; break;
|
|---|
| 1967 | case BFD_RELOC_PPC_B16_BRNTAKEN: r = R_PPC_REL14_BRNTAKEN; break;
|
|---|
| 1968 | case BFD_RELOC_16_GOTOFF: r = R_PPC_GOT16; break;
|
|---|
| 1969 | case BFD_RELOC_LO16_GOTOFF: r = R_PPC_GOT16_LO; break;
|
|---|
| 1970 | case BFD_RELOC_HI16_GOTOFF: r = R_PPC_GOT16_HI; break;
|
|---|
| 1971 | case BFD_RELOC_HI16_S_GOTOFF: r = R_PPC_GOT16_HA; break;
|
|---|
| 1972 | case BFD_RELOC_24_PLT_PCREL: r = R_PPC_PLTREL24; break;
|
|---|
| 1973 | case BFD_RELOC_PPC_COPY: r = R_PPC_COPY; break;
|
|---|
| 1974 | case BFD_RELOC_PPC_GLOB_DAT: r = R_PPC_GLOB_DAT; break;
|
|---|
| 1975 | case BFD_RELOC_PPC_LOCAL24PC: r = R_PPC_LOCAL24PC; break;
|
|---|
| 1976 | case BFD_RELOC_32_PCREL: r = R_PPC_REL32; break;
|
|---|
| 1977 | case BFD_RELOC_32_PLTOFF: r = R_PPC_PLT32; break;
|
|---|
| 1978 | case BFD_RELOC_32_PLT_PCREL: r = R_PPC_PLTREL32; break;
|
|---|
| 1979 | case BFD_RELOC_LO16_PLTOFF: r = R_PPC_PLT16_LO; break;
|
|---|
| 1980 | case BFD_RELOC_HI16_PLTOFF: r = R_PPC_PLT16_HI; break;
|
|---|
| 1981 | case BFD_RELOC_HI16_S_PLTOFF: r = R_PPC_PLT16_HA; break;
|
|---|
| 1982 | case BFD_RELOC_GPREL16: r = R_PPC_SDAREL16; break;
|
|---|
| 1983 | case BFD_RELOC_16_BASEREL: r = R_PPC_SECTOFF; break;
|
|---|
| 1984 | case BFD_RELOC_LO16_BASEREL: r = R_PPC_SECTOFF_LO; break;
|
|---|
| 1985 | case BFD_RELOC_HI16_BASEREL: r = R_PPC_SECTOFF_HI; break;
|
|---|
| 1986 | case BFD_RELOC_HI16_S_BASEREL: r = R_PPC_SECTOFF_HA; break;
|
|---|
| 1987 | case BFD_RELOC_CTOR: r = R_PPC_ADDR32; break;
|
|---|
| 1988 | case BFD_RELOC_PPC_TOC16: r = R_PPC_TOC16; break;
|
|---|
| 1989 | case BFD_RELOC_PPC_TLS: r = R_PPC_TLS; break;
|
|---|
| 1990 | case BFD_RELOC_PPC_DTPMOD: r = R_PPC_DTPMOD32; break;
|
|---|
| 1991 | case BFD_RELOC_PPC_TPREL16: r = R_PPC_TPREL16; break;
|
|---|
| 1992 | case BFD_RELOC_PPC_TPREL16_LO: r = R_PPC_TPREL16_LO; break;
|
|---|
| 1993 | case BFD_RELOC_PPC_TPREL16_HI: r = R_PPC_TPREL16_HI; break;
|
|---|
| 1994 | case BFD_RELOC_PPC_TPREL16_HA: r = R_PPC_TPREL16_HA; break;
|
|---|
| 1995 | case BFD_RELOC_PPC_TPREL: r = R_PPC_TPREL32; break;
|
|---|
| 1996 | case BFD_RELOC_PPC_DTPREL16: r = R_PPC_DTPREL16; break;
|
|---|
| 1997 | case BFD_RELOC_PPC_DTPREL16_LO: r = R_PPC_DTPREL16_LO; break;
|
|---|
| 1998 | case BFD_RELOC_PPC_DTPREL16_HI: r = R_PPC_DTPREL16_HI; break;
|
|---|
| 1999 | case BFD_RELOC_PPC_DTPREL16_HA: r = R_PPC_DTPREL16_HA; break;
|
|---|
| 2000 | case BFD_RELOC_PPC_DTPREL: r = R_PPC_DTPREL32; break;
|
|---|
| 2001 | case BFD_RELOC_PPC_GOT_TLSGD16: r = R_PPC_GOT_TLSGD16; break;
|
|---|
| 2002 | case BFD_RELOC_PPC_GOT_TLSGD16_LO: r = R_PPC_GOT_TLSGD16_LO; break;
|
|---|
| 2003 | case BFD_RELOC_PPC_GOT_TLSGD16_HI: r = R_PPC_GOT_TLSGD16_HI; break;
|
|---|
| 2004 | case BFD_RELOC_PPC_GOT_TLSGD16_HA: r = R_PPC_GOT_TLSGD16_HA; break;
|
|---|
| 2005 | case BFD_RELOC_PPC_GOT_TLSLD16: r = R_PPC_GOT_TLSLD16; break;
|
|---|
| 2006 | case BFD_RELOC_PPC_GOT_TLSLD16_LO: r = R_PPC_GOT_TLSLD16_LO; break;
|
|---|
| 2007 | case BFD_RELOC_PPC_GOT_TLSLD16_HI: r = R_PPC_GOT_TLSLD16_HI; break;
|
|---|
| 2008 | case BFD_RELOC_PPC_GOT_TLSLD16_HA: r = R_PPC_GOT_TLSLD16_HA; break;
|
|---|
| 2009 | case BFD_RELOC_PPC_GOT_TPREL16: r = R_PPC_GOT_TPREL16; break;
|
|---|
| 2010 | case BFD_RELOC_PPC_GOT_TPREL16_LO: r = R_PPC_GOT_TPREL16_LO; break;
|
|---|
| 2011 | case BFD_RELOC_PPC_GOT_TPREL16_HI: r = R_PPC_GOT_TPREL16_HI; break;
|
|---|
| 2012 | case BFD_RELOC_PPC_GOT_TPREL16_HA: r = R_PPC_GOT_TPREL16_HA; break;
|
|---|
| 2013 | case BFD_RELOC_PPC_GOT_DTPREL16: r = R_PPC_GOT_DTPREL16; break;
|
|---|
| 2014 | case BFD_RELOC_PPC_GOT_DTPREL16_LO: r = R_PPC_GOT_DTPREL16_LO; break;
|
|---|
| 2015 | case BFD_RELOC_PPC_GOT_DTPREL16_HI: r = R_PPC_GOT_DTPREL16_HI; break;
|
|---|
| 2016 | case BFD_RELOC_PPC_GOT_DTPREL16_HA: r = R_PPC_GOT_DTPREL16_HA; break;
|
|---|
| 2017 | case BFD_RELOC_PPC_EMB_NADDR32: r = R_PPC_EMB_NADDR32; break;
|
|---|
| 2018 | case BFD_RELOC_PPC_EMB_NADDR16: r = R_PPC_EMB_NADDR16; break;
|
|---|
| 2019 | case BFD_RELOC_PPC_EMB_NADDR16_LO: r = R_PPC_EMB_NADDR16_LO; break;
|
|---|
| 2020 | case BFD_RELOC_PPC_EMB_NADDR16_HI: r = R_PPC_EMB_NADDR16_HI; break;
|
|---|
| 2021 | case BFD_RELOC_PPC_EMB_NADDR16_HA: r = R_PPC_EMB_NADDR16_HA; break;
|
|---|
| 2022 | case BFD_RELOC_PPC_EMB_SDAI16: r = R_PPC_EMB_SDAI16; break;
|
|---|
| 2023 | case BFD_RELOC_PPC_EMB_SDA2I16: r = R_PPC_EMB_SDA2I16; break;
|
|---|
| 2024 | case BFD_RELOC_PPC_EMB_SDA2REL: r = R_PPC_EMB_SDA2REL; break;
|
|---|
| 2025 | case BFD_RELOC_PPC_EMB_SDA21: r = R_PPC_EMB_SDA21; break;
|
|---|
| 2026 | case BFD_RELOC_PPC_EMB_MRKREF: r = R_PPC_EMB_MRKREF; break;
|
|---|
| 2027 | case BFD_RELOC_PPC_EMB_RELSEC16: r = R_PPC_EMB_RELSEC16; break;
|
|---|
| 2028 | case BFD_RELOC_PPC_EMB_RELST_LO: r = R_PPC_EMB_RELST_LO; break;
|
|---|
| 2029 | case BFD_RELOC_PPC_EMB_RELST_HI: r = R_PPC_EMB_RELST_HI; break;
|
|---|
| 2030 | case BFD_RELOC_PPC_EMB_RELST_HA: r = R_PPC_EMB_RELST_HA; break;
|
|---|
| 2031 | case BFD_RELOC_PPC_EMB_BIT_FLD: r = R_PPC_EMB_BIT_FLD; break;
|
|---|
| 2032 | case BFD_RELOC_PPC_EMB_RELSDA: r = R_PPC_EMB_RELSDA; break;
|
|---|
| 2033 | case BFD_RELOC_VTABLE_INHERIT: r = R_PPC_GNU_VTINHERIT; break;
|
|---|
| 2034 | case BFD_RELOC_VTABLE_ENTRY: r = R_PPC_GNU_VTENTRY; break;
|
|---|
| 2035 | }
|
|---|
| 2036 |
|
|---|
| 2037 | return ppc_elf_howto_table[(int) r];
|
|---|
| 2038 | };
|
|---|
| 2039 |
|
|---|
| 2040 | /* Set the howto pointer for a PowerPC ELF reloc. */
|
|---|
| 2041 |
|
|---|
| 2042 | static void
|
|---|
| 2043 | ppc_elf_info_to_howto (abfd, cache_ptr, dst)
|
|---|
| 2044 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 2045 | arelent *cache_ptr;
|
|---|
| 2046 | Elf_Internal_Rela *dst;
|
|---|
| 2047 | {
|
|---|
| 2048 | if (!ppc_elf_howto_table[R_PPC_ADDR32])
|
|---|
| 2049 | /* Initialize howto table if needed. */
|
|---|
| 2050 | ppc_elf_howto_init ();
|
|---|
| 2051 |
|
|---|
| 2052 | BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_PPC_max);
|
|---|
| 2053 | cache_ptr->howto = ppc_elf_howto_table[ELF32_R_TYPE (dst->r_info)];
|
|---|
| 2054 | }
|
|---|
| 2055 |
|
|---|
| 2056 | /* Handle the R_PPC_ADDR16_HA reloc. */
|
|---|
| 2057 |
|
|---|
| 2058 | static bfd_reloc_status_type
|
|---|
| 2059 | ppc_elf_addr16_ha_reloc (abfd, reloc_entry, symbol, data, input_section,
|
|---|
| 2060 | output_bfd, error_message)
|
|---|
| 2061 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 2062 | arelent *reloc_entry;
|
|---|
| 2063 | asymbol *symbol;
|
|---|
| 2064 | PTR data ATTRIBUTE_UNUSED;
|
|---|
| 2065 | asection *input_section;
|
|---|
| 2066 | bfd *output_bfd;
|
|---|
| 2067 | char **error_message ATTRIBUTE_UNUSED;
|
|---|
| 2068 | {
|
|---|
| 2069 | bfd_vma relocation;
|
|---|
| 2070 |
|
|---|
| 2071 | if (output_bfd != NULL)
|
|---|
| 2072 | {
|
|---|
| 2073 | reloc_entry->address += input_section->output_offset;
|
|---|
| 2074 | return bfd_reloc_ok;
|
|---|
| 2075 | }
|
|---|
| 2076 |
|
|---|
| 2077 | if (reloc_entry->address > input_section->_cooked_size)
|
|---|
| 2078 | return bfd_reloc_outofrange;
|
|---|
| 2079 |
|
|---|
| 2080 | if (bfd_is_com_section (symbol->section))
|
|---|
| 2081 | relocation = 0;
|
|---|
| 2082 | else
|
|---|
| 2083 | relocation = symbol->value;
|
|---|
| 2084 |
|
|---|
| 2085 | relocation += symbol->section->output_section->vma;
|
|---|
| 2086 | relocation += symbol->section->output_offset;
|
|---|
| 2087 | relocation += reloc_entry->addend;
|
|---|
| 2088 |
|
|---|
| 2089 | reloc_entry->addend += (relocation & 0x8000) << 1;
|
|---|
| 2090 |
|
|---|
| 2091 | return bfd_reloc_continue;
|
|---|
| 2092 | }
|
|---|
| 2093 |
|
|---|
| 2094 | static bfd_reloc_status_type
|
|---|
| 2095 | ppc_elf_unhandled_reloc (abfd, reloc_entry, symbol, data,
|
|---|
| 2096 | input_section, output_bfd, error_message)
|
|---|
| 2097 | bfd *abfd;
|
|---|
| 2098 | arelent *reloc_entry;
|
|---|
| 2099 | asymbol *symbol;
|
|---|
| 2100 | PTR data;
|
|---|
| 2101 | asection *input_section;
|
|---|
| 2102 | bfd *output_bfd;
|
|---|
| 2103 | char **error_message;
|
|---|
| 2104 | {
|
|---|
| 2105 | /* If this is a relocatable link (output_bfd test tells us), just
|
|---|
| 2106 | call the generic function. Any adjustment will be done at final
|
|---|
| 2107 | link time. */
|
|---|
| 2108 | if (output_bfd != NULL)
|
|---|
| 2109 | return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
|
|---|
| 2110 | input_section, output_bfd, error_message);
|
|---|
| 2111 |
|
|---|
| 2112 | if (error_message != NULL)
|
|---|
| 2113 | {
|
|---|
| 2114 | static char buf[60];
|
|---|
| 2115 | sprintf (buf, "generic linker can't handle %s",
|
|---|
| 2116 | reloc_entry->howto->name);
|
|---|
| 2117 | *error_message = buf;
|
|---|
| 2118 | }
|
|---|
| 2119 | return bfd_reloc_dangerous;
|
|---|
| 2120 | }
|
|---|
| 2121 |
|
|---|
| 2122 | /* Fix bad default arch selected for a 32 bit input bfd when the
|
|---|
| 2123 | default is 64 bit. */
|
|---|
| 2124 |
|
|---|
| 2125 | static bfd_boolean
|
|---|
| 2126 | ppc_elf_object_p (abfd)
|
|---|
| 2127 | bfd *abfd;
|
|---|
| 2128 | {
|
|---|
| 2129 | if (abfd->arch_info->the_default && abfd->arch_info->bits_per_word == 64)
|
|---|
| 2130 | {
|
|---|
| 2131 | Elf_Internal_Ehdr *i_ehdr = elf_elfheader (abfd);
|
|---|
| 2132 |
|
|---|
| 2133 | if (i_ehdr->e_ident[EI_CLASS] == ELFCLASS32)
|
|---|
| 2134 | {
|
|---|
| 2135 | /* Relies on arch after 64 bit default being 32 bit default. */
|
|---|
| 2136 | abfd->arch_info = abfd->arch_info->next;
|
|---|
| 2137 | BFD_ASSERT (abfd->arch_info->bits_per_word == 32);
|
|---|
| 2138 | }
|
|---|
| 2139 | }
|
|---|
| 2140 | return TRUE;
|
|---|
| 2141 | }
|
|---|
| 2142 |
|
|---|
| 2143 | /* Function to set whether a module needs the -mrelocatable bit set. */
|
|---|
| 2144 |
|
|---|
| 2145 | static bfd_boolean
|
|---|
| 2146 | ppc_elf_set_private_flags (abfd, flags)
|
|---|
| 2147 | bfd *abfd;
|
|---|
| 2148 | flagword flags;
|
|---|
| 2149 | {
|
|---|
| 2150 | BFD_ASSERT (!elf_flags_init (abfd)
|
|---|
| 2151 | || elf_elfheader (abfd)->e_flags == flags);
|
|---|
| 2152 |
|
|---|
| 2153 | elf_elfheader (abfd)->e_flags = flags;
|
|---|
| 2154 | elf_flags_init (abfd) = TRUE;
|
|---|
| 2155 | return TRUE;
|
|---|
| 2156 | }
|
|---|
| 2157 |
|
|---|
| 2158 | /* Merge backend specific data from an object file to the output
|
|---|
| 2159 | object file when linking. */
|
|---|
| 2160 |
|
|---|
| 2161 | static bfd_boolean
|
|---|
| 2162 | ppc_elf_merge_private_bfd_data (ibfd, obfd)
|
|---|
| 2163 | bfd *ibfd;
|
|---|
| 2164 | bfd *obfd;
|
|---|
| 2165 | {
|
|---|
| 2166 | flagword old_flags;
|
|---|
| 2167 | flagword new_flags;
|
|---|
| 2168 | bfd_boolean error;
|
|---|
| 2169 |
|
|---|
| 2170 | /* Check if we have the same endianess. */
|
|---|
| 2171 | if (! _bfd_generic_verify_endian_match (ibfd, obfd))
|
|---|
| 2172 | return FALSE;
|
|---|
| 2173 |
|
|---|
| 2174 | if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
|
|---|
| 2175 | || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
|
|---|
| 2176 | return TRUE;
|
|---|
| 2177 |
|
|---|
| 2178 | new_flags = elf_elfheader (ibfd)->e_flags;
|
|---|
| 2179 | old_flags = elf_elfheader (obfd)->e_flags;
|
|---|
| 2180 | if (!elf_flags_init (obfd))
|
|---|
| 2181 | {
|
|---|
| 2182 | /* First call, no flags set. */
|
|---|
| 2183 | elf_flags_init (obfd) = TRUE;
|
|---|
| 2184 | elf_elfheader (obfd)->e_flags = new_flags;
|
|---|
| 2185 | }
|
|---|
| 2186 |
|
|---|
| 2187 | /* Compatible flags are ok. */
|
|---|
| 2188 | else if (new_flags == old_flags)
|
|---|
| 2189 | ;
|
|---|
| 2190 |
|
|---|
| 2191 | /* Incompatible flags. */
|
|---|
| 2192 | else
|
|---|
| 2193 | {
|
|---|
| 2194 | /* Warn about -mrelocatable mismatch. Allow -mrelocatable-lib
|
|---|
| 2195 | to be linked with either. */
|
|---|
| 2196 | error = FALSE;
|
|---|
| 2197 | if ((new_flags & EF_PPC_RELOCATABLE) != 0
|
|---|
| 2198 | && (old_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0)
|
|---|
| 2199 | {
|
|---|
| 2200 | error = TRUE;
|
|---|
| 2201 | (*_bfd_error_handler)
|
|---|
| 2202 | (_("%s: compiled with -mrelocatable and linked with modules compiled normally"),
|
|---|
| 2203 | bfd_archive_filename (ibfd));
|
|---|
| 2204 | }
|
|---|
| 2205 | else if ((new_flags & (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB)) == 0
|
|---|
| 2206 | && (old_flags & EF_PPC_RELOCATABLE) != 0)
|
|---|
| 2207 | {
|
|---|
| 2208 | error = TRUE;
|
|---|
| 2209 | (*_bfd_error_handler)
|
|---|
| 2210 | (_("%s: compiled normally and linked with modules compiled with -mrelocatable"),
|
|---|
| 2211 | bfd_archive_filename (ibfd));
|
|---|
| 2212 | }
|
|---|
| 2213 |
|
|---|
| 2214 | /* The output is -mrelocatable-lib iff both the input files are. */
|
|---|
| 2215 | if (! (new_flags & EF_PPC_RELOCATABLE_LIB))
|
|---|
| 2216 | elf_elfheader (obfd)->e_flags &= ~EF_PPC_RELOCATABLE_LIB;
|
|---|
| 2217 |
|
|---|
| 2218 | /* The output is -mrelocatable iff it can't be -mrelocatable-lib,
|
|---|
| 2219 | but each input file is either -mrelocatable or -mrelocatable-lib. */
|
|---|
| 2220 | if (! (elf_elfheader (obfd)->e_flags & EF_PPC_RELOCATABLE_LIB)
|
|---|
| 2221 | && (new_flags & (EF_PPC_RELOCATABLE_LIB | EF_PPC_RELOCATABLE))
|
|---|
| 2222 | && (old_flags & (EF_PPC_RELOCATABLE_LIB | EF_PPC_RELOCATABLE)))
|
|---|
| 2223 | elf_elfheader (obfd)->e_flags |= EF_PPC_RELOCATABLE;
|
|---|
| 2224 |
|
|---|
| 2225 | /* Do not warn about eabi vs. V.4 mismatch, just or in the bit if
|
|---|
| 2226 | any module uses it. */
|
|---|
| 2227 | elf_elfheader (obfd)->e_flags |= (new_flags & EF_PPC_EMB);
|
|---|
| 2228 |
|
|---|
| 2229 | new_flags &= ~(EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB | EF_PPC_EMB);
|
|---|
| 2230 | old_flags &= ~(EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB | EF_PPC_EMB);
|
|---|
| 2231 |
|
|---|
| 2232 | /* Warn about any other mismatches. */
|
|---|
| 2233 | if (new_flags != old_flags)
|
|---|
| 2234 | {
|
|---|
| 2235 | error = TRUE;
|
|---|
| 2236 | (*_bfd_error_handler)
|
|---|
| 2237 | (_("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"),
|
|---|
| 2238 | bfd_archive_filename (ibfd), (long) new_flags, (long) old_flags);
|
|---|
| 2239 | }
|
|---|
| 2240 |
|
|---|
| 2241 | if (error)
|
|---|
| 2242 | {
|
|---|
| 2243 | bfd_set_error (bfd_error_bad_value);
|
|---|
| 2244 | return FALSE;
|
|---|
| 2245 | }
|
|---|
| 2246 | }
|
|---|
| 2247 |
|
|---|
| 2248 | return TRUE;
|
|---|
| 2249 | }
|
|---|
| 2250 | |
|---|
| 2251 |
|
|---|
| 2252 | /* Handle a PowerPC specific section when reading an object file. This
|
|---|
| 2253 | is called when elfcode.h finds a section with an unknown type. */
|
|---|
| 2254 |
|
|---|
| 2255 | static bfd_boolean
|
|---|
| 2256 | ppc_elf_section_from_shdr (abfd, hdr, name)
|
|---|
| 2257 | bfd *abfd;
|
|---|
| 2258 | Elf_Internal_Shdr *hdr;
|
|---|
| 2259 | const char *name;
|
|---|
| 2260 | {
|
|---|
| 2261 | asection *newsect;
|
|---|
| 2262 | flagword flags;
|
|---|
| 2263 |
|
|---|
| 2264 | if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name))
|
|---|
| 2265 | return FALSE;
|
|---|
| 2266 |
|
|---|
| 2267 | newsect = hdr->bfd_section;
|
|---|
| 2268 | flags = bfd_get_section_flags (abfd, newsect);
|
|---|
| 2269 | if (hdr->sh_flags & SHF_EXCLUDE)
|
|---|
| 2270 | flags |= SEC_EXCLUDE;
|
|---|
| 2271 |
|
|---|
| 2272 | if (hdr->sh_type == SHT_ORDERED)
|
|---|
| 2273 | flags |= SEC_SORT_ENTRIES;
|
|---|
| 2274 |
|
|---|
| 2275 | bfd_set_section_flags (abfd, newsect, flags);
|
|---|
| 2276 | return TRUE;
|
|---|
| 2277 | }
|
|---|
| 2278 | |
|---|
| 2279 |
|
|---|
| 2280 | /* Set up any other section flags and such that may be necessary. */
|
|---|
| 2281 |
|
|---|
| 2282 | static bfd_boolean
|
|---|
| 2283 | ppc_elf_fake_sections (abfd, shdr, asect)
|
|---|
| 2284 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 2285 | Elf_Internal_Shdr *shdr;
|
|---|
| 2286 | asection *asect;
|
|---|
| 2287 | {
|
|---|
| 2288 | if ((asect->flags & SEC_EXCLUDE) != 0)
|
|---|
| 2289 | shdr->sh_flags |= SHF_EXCLUDE;
|
|---|
| 2290 |
|
|---|
| 2291 | if ((asect->flags & SEC_SORT_ENTRIES) != 0)
|
|---|
| 2292 | shdr->sh_type = SHT_ORDERED;
|
|---|
| 2293 |
|
|---|
| 2294 | return TRUE;
|
|---|
| 2295 | }
|
|---|
| 2296 | |
|---|
| 2297 |
|
|---|
| 2298 | /* Create a special linker section */
|
|---|
| 2299 | static elf_linker_section_t *
|
|---|
| 2300 | ppc_elf_create_linker_section (abfd, info, which)
|
|---|
| 2301 | bfd *abfd;
|
|---|
| 2302 | struct bfd_link_info *info;
|
|---|
| 2303 | enum elf_linker_section_enum which;
|
|---|
| 2304 | {
|
|---|
| 2305 | bfd *dynobj = elf_hash_table (info)->dynobj;
|
|---|
| 2306 | elf_linker_section_t *lsect;
|
|---|
| 2307 |
|
|---|
| 2308 | /* Record the first bfd section that needs the special section. */
|
|---|
| 2309 | if (!dynobj)
|
|---|
| 2310 | dynobj = elf_hash_table (info)->dynobj = abfd;
|
|---|
| 2311 |
|
|---|
| 2312 | /* If this is the first time, create the section. */
|
|---|
| 2313 | lsect = elf_linker_section (dynobj, which);
|
|---|
| 2314 | if (!lsect)
|
|---|
| 2315 | {
|
|---|
| 2316 | elf_linker_section_t defaults;
|
|---|
| 2317 | static elf_linker_section_t zero_section;
|
|---|
| 2318 |
|
|---|
| 2319 | defaults = zero_section;
|
|---|
| 2320 | defaults.which = which;
|
|---|
| 2321 | defaults.hole_written_p = FALSE;
|
|---|
| 2322 | defaults.alignment = 2;
|
|---|
| 2323 |
|
|---|
| 2324 | /* Both of these sections are (technically) created by the user
|
|---|
| 2325 | putting data in them, so they shouldn't be marked
|
|---|
| 2326 | SEC_LINKER_CREATED.
|
|---|
| 2327 |
|
|---|
| 2328 | The linker creates them so it has somewhere to attach their
|
|---|
| 2329 | respective symbols. In fact, if they were empty it would
|
|---|
| 2330 | be OK to leave the symbol set to 0 (or any random number), because
|
|---|
| 2331 | the appropriate register should never be used. */
|
|---|
| 2332 | defaults.flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
|
|---|
| 2333 | | SEC_IN_MEMORY);
|
|---|
| 2334 |
|
|---|
| 2335 | switch (which)
|
|---|
| 2336 | {
|
|---|
| 2337 | default:
|
|---|
| 2338 | (*_bfd_error_handler) (_("%s: unknown special linker type %d"),
|
|---|
| 2339 | bfd_get_filename (abfd),
|
|---|
| 2340 | (int) which);
|
|---|
| 2341 |
|
|---|
| 2342 | bfd_set_error (bfd_error_bad_value);
|
|---|
| 2343 | return (elf_linker_section_t *) 0;
|
|---|
| 2344 |
|
|---|
| 2345 | case LINKER_SECTION_SDATA: /* .sdata/.sbss section */
|
|---|
| 2346 | defaults.name = ".sdata";
|
|---|
| 2347 | defaults.rel_name = ".rela.sdata";
|
|---|
| 2348 | defaults.bss_name = ".sbss";
|
|---|
| 2349 | defaults.sym_name = "_SDA_BASE_";
|
|---|
| 2350 | defaults.sym_offset = 32768;
|
|---|
| 2351 | break;
|
|---|
| 2352 |
|
|---|
| 2353 | case LINKER_SECTION_SDATA2: /* .sdata2/.sbss2 section */
|
|---|
| 2354 | defaults.name = ".sdata2";
|
|---|
| 2355 | defaults.rel_name = ".rela.sdata2";
|
|---|
| 2356 | defaults.bss_name = ".sbss2";
|
|---|
| 2357 | defaults.sym_name = "_SDA2_BASE_";
|
|---|
| 2358 | defaults.sym_offset = 32768;
|
|---|
| 2359 | defaults.flags |= SEC_READONLY;
|
|---|
| 2360 | break;
|
|---|
| 2361 | }
|
|---|
| 2362 |
|
|---|
| 2363 | lsect = _bfd_elf_create_linker_section (abfd, info, which, &defaults);
|
|---|
| 2364 | }
|
|---|
| 2365 |
|
|---|
| 2366 | return lsect;
|
|---|
| 2367 | }
|
|---|
| 2368 | |
|---|
| 2369 |
|
|---|
| 2370 | /* If we have a non-zero sized .sbss2 or .PPC.EMB.sbss0 sections, we
|
|---|
| 2371 | need to bump up the number of section headers. */
|
|---|
| 2372 |
|
|---|
| 2373 | static int
|
|---|
| 2374 | ppc_elf_additional_program_headers (abfd)
|
|---|
| 2375 | bfd *abfd;
|
|---|
| 2376 | {
|
|---|
| 2377 | asection *s;
|
|---|
| 2378 | int ret;
|
|---|
| 2379 |
|
|---|
| 2380 | ret = 0;
|
|---|
| 2381 |
|
|---|
| 2382 | s = bfd_get_section_by_name (abfd, ".interp");
|
|---|
| 2383 | if (s != NULL)
|
|---|
| 2384 | ++ret;
|
|---|
| 2385 |
|
|---|
| 2386 | s = bfd_get_section_by_name (abfd, ".sbss2");
|
|---|
| 2387 | if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->_raw_size > 0)
|
|---|
| 2388 | ++ret;
|
|---|
| 2389 |
|
|---|
| 2390 | s = bfd_get_section_by_name (abfd, ".PPC.EMB.sbss0");
|
|---|
| 2391 | if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->_raw_size > 0)
|
|---|
| 2392 | ++ret;
|
|---|
| 2393 |
|
|---|
| 2394 | return ret;
|
|---|
| 2395 | }
|
|---|
| 2396 |
|
|---|
| 2397 | /* Modify the segment map if needed. */
|
|---|
| 2398 |
|
|---|
| 2399 | static bfd_boolean
|
|---|
| 2400 | ppc_elf_modify_segment_map (abfd)
|
|---|
| 2401 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 2402 | {
|
|---|
| 2403 | return TRUE;
|
|---|
| 2404 | }
|
|---|
| 2405 | |
|---|
| 2406 |
|
|---|
| 2407 | /* The powerpc .got has a blrl instruction in it. Mark it executable. */
|
|---|
| 2408 |
|
|---|
| 2409 | static bfd_boolean
|
|---|
| 2410 | ppc_elf_create_got (abfd, info)
|
|---|
| 2411 | bfd *abfd;
|
|---|
| 2412 | struct bfd_link_info *info;
|
|---|
| 2413 | {
|
|---|
| 2414 | struct ppc_elf_link_hash_table *htab;
|
|---|
| 2415 | asection *s;
|
|---|
| 2416 | flagword flags;
|
|---|
| 2417 |
|
|---|
| 2418 | if (!_bfd_elf_create_got_section (abfd, info))
|
|---|
| 2419 | return FALSE;
|
|---|
| 2420 |
|
|---|
| 2421 | htab = ppc_elf_hash_table (info);
|
|---|
| 2422 | htab->got = s = bfd_get_section_by_name (abfd, ".got");
|
|---|
| 2423 | if (s == NULL)
|
|---|
| 2424 | abort ();
|
|---|
| 2425 |
|
|---|
| 2426 | flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_IN_MEMORY
|
|---|
| 2427 | | SEC_LINKER_CREATED);
|
|---|
| 2428 | if (!bfd_set_section_flags (abfd, s, flags))
|
|---|
| 2429 | return FALSE;
|
|---|
| 2430 |
|
|---|
| 2431 | htab->relgot = bfd_make_section (abfd, ".rela.got");
|
|---|
| 2432 | if (!htab->relgot
|
|---|
| 2433 | || ! bfd_set_section_flags (abfd, htab->relgot,
|
|---|
| 2434 | (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
|
|---|
| 2435 | | SEC_IN_MEMORY | SEC_LINKER_CREATED
|
|---|
| 2436 | | SEC_READONLY))
|
|---|
| 2437 | || ! bfd_set_section_alignment (abfd, htab->relgot, 2))
|
|---|
| 2438 | return FALSE;
|
|---|
| 2439 |
|
|---|
| 2440 | return TRUE;
|
|---|
| 2441 | }
|
|---|
| 2442 |
|
|---|
| 2443 | /* We have to create .dynsbss and .rela.sbss here so that they get mapped
|
|---|
| 2444 | to output sections (just like _bfd_elf_create_dynamic_sections has
|
|---|
| 2445 | to create .dynbss and .rela.bss). */
|
|---|
| 2446 |
|
|---|
| 2447 | static bfd_boolean
|
|---|
| 2448 | ppc_elf_create_dynamic_sections (abfd, info)
|
|---|
| 2449 | bfd *abfd;
|
|---|
| 2450 | struct bfd_link_info *info;
|
|---|
| 2451 | {
|
|---|
| 2452 | struct ppc_elf_link_hash_table *htab;
|
|---|
| 2453 | asection *s;
|
|---|
| 2454 | flagword flags;
|
|---|
| 2455 |
|
|---|
| 2456 | if (!ppc_elf_create_got (abfd, info))
|
|---|
| 2457 | return FALSE;
|
|---|
| 2458 |
|
|---|
| 2459 | if (!_bfd_elf_create_dynamic_sections (abfd, info))
|
|---|
| 2460 | return FALSE;
|
|---|
| 2461 |
|
|---|
| 2462 | flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
|
|---|
| 2463 | | SEC_LINKER_CREATED);
|
|---|
| 2464 |
|
|---|
| 2465 | htab = ppc_elf_hash_table (info);
|
|---|
| 2466 | htab->dynbss = bfd_get_section_by_name (abfd, ".dynbss");
|
|---|
| 2467 | htab->dynsbss = s = bfd_make_section (abfd, ".dynsbss");
|
|---|
| 2468 | if (s == NULL
|
|---|
| 2469 | || ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
|
|---|
| 2470 | return FALSE;
|
|---|
| 2471 |
|
|---|
| 2472 | if (! info->shared)
|
|---|
| 2473 | {
|
|---|
| 2474 | htab->relbss = bfd_get_section_by_name (abfd, ".rela.bss");
|
|---|
| 2475 | htab->relsbss = s = bfd_make_section (abfd, ".rela.sbss");
|
|---|
| 2476 | if (s == NULL
|
|---|
| 2477 | || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
|---|
| 2478 | || ! bfd_set_section_alignment (abfd, s, 2))
|
|---|
| 2479 | return FALSE;
|
|---|
| 2480 | }
|
|---|
| 2481 |
|
|---|
| 2482 | htab->relplt = bfd_get_section_by_name (abfd, ".rela.plt");
|
|---|
| 2483 | htab->plt = s = bfd_get_section_by_name (abfd, ".plt");
|
|---|
| 2484 | if (s == NULL)
|
|---|
| 2485 | abort ();
|
|---|
| 2486 |
|
|---|
| 2487 | flags = SEC_ALLOC | SEC_CODE | SEC_IN_MEMORY | SEC_LINKER_CREATED;
|
|---|
| 2488 | return bfd_set_section_flags (abfd, s, flags);
|
|---|
| 2489 | }
|
|---|
| 2490 |
|
|---|
| 2491 | /* Adjust a symbol defined by a dynamic object and referenced by a
|
|---|
| 2492 | regular object. The current definition is in some section of the
|
|---|
| 2493 | dynamic object, but we're not including those sections. We have to
|
|---|
| 2494 | change the definition to something the rest of the link can
|
|---|
| 2495 | understand. */
|
|---|
| 2496 |
|
|---|
| 2497 | static bfd_boolean
|
|---|
| 2498 | ppc_elf_adjust_dynamic_symbol (info, h)
|
|---|
| 2499 | struct bfd_link_info *info;
|
|---|
| 2500 | struct elf_link_hash_entry *h;
|
|---|
| 2501 | {
|
|---|
| 2502 | struct ppc_elf_link_hash_table *htab;
|
|---|
| 2503 | asection *s;
|
|---|
| 2504 | unsigned int power_of_two;
|
|---|
| 2505 |
|
|---|
| 2506 | #ifdef DEBUG
|
|---|
| 2507 | fprintf (stderr, "ppc_elf_adjust_dynamic_symbol called for %s\n",
|
|---|
| 2508 | h->root.root.string);
|
|---|
| 2509 | #endif
|
|---|
| 2510 |
|
|---|
| 2511 | /* Make sure we know what is going on here. */
|
|---|
| 2512 | htab = ppc_elf_hash_table (info);
|
|---|
| 2513 | BFD_ASSERT (htab->elf.dynobj != NULL
|
|---|
| 2514 | && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
|
|---|
| 2515 | || h->weakdef != NULL
|
|---|
| 2516 | || ((h->elf_link_hash_flags
|
|---|
| 2517 | & ELF_LINK_HASH_DEF_DYNAMIC) != 0
|
|---|
| 2518 | && (h->elf_link_hash_flags
|
|---|
| 2519 | & ELF_LINK_HASH_REF_REGULAR) != 0
|
|---|
| 2520 | && (h->elf_link_hash_flags
|
|---|
| 2521 | & ELF_LINK_HASH_DEF_REGULAR) == 0)));
|
|---|
| 2522 |
|
|---|
| 2523 | /* Deal with function syms. */
|
|---|
| 2524 | if (h->type == STT_FUNC
|
|---|
| 2525 | || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
|
|---|
| 2526 | {
|
|---|
| 2527 | /* Clear procedure linkage table information for any symbol that
|
|---|
| 2528 | won't need a .plt entry. */
|
|---|
| 2529 | if (! htab->elf.dynamic_sections_created
|
|---|
| 2530 | || SYMBOL_CALLS_LOCAL (info, h)
|
|---|
| 2531 | || h->plt.refcount <= 0)
|
|---|
| 2532 | {
|
|---|
| 2533 | /* A PLT entry is not required/allowed when:
|
|---|
| 2534 |
|
|---|
| 2535 | 1. We are not using ld.so; because then the PLT entry
|
|---|
| 2536 | can't be set up, so we can't use one.
|
|---|
| 2537 |
|
|---|
| 2538 | 2. We know for certain that a call to this symbol
|
|---|
| 2539 | will go to this object.
|
|---|
| 2540 |
|
|---|
| 2541 | 3. GC has rendered the entry unused. */
|
|---|
| 2542 | h->plt.offset = (bfd_vma) -1;
|
|---|
| 2543 | h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
|
|---|
| 2544 | }
|
|---|
| 2545 | return TRUE;
|
|---|
| 2546 | }
|
|---|
| 2547 | else
|
|---|
| 2548 | h->plt.offset = (bfd_vma) -1;
|
|---|
| 2549 |
|
|---|
| 2550 | /* If this is a weak symbol, and there is a real definition, the
|
|---|
| 2551 | processor independent code will have arranged for us to see the
|
|---|
| 2552 | real definition first, and we can just use the same value. */
|
|---|
| 2553 | if (h->weakdef != NULL)
|
|---|
| 2554 | {
|
|---|
| 2555 | BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
|
|---|
| 2556 | || h->weakdef->root.type == bfd_link_hash_defweak);
|
|---|
| 2557 | h->root.u.def.section = h->weakdef->root.u.def.section;
|
|---|
| 2558 | h->root.u.def.value = h->weakdef->root.u.def.value;
|
|---|
| 2559 | if (ELIMINATE_COPY_RELOCS)
|
|---|
| 2560 | h->elf_link_hash_flags
|
|---|
| 2561 | = ((h->elf_link_hash_flags & ~ELF_LINK_NON_GOT_REF)
|
|---|
| 2562 | | (h->weakdef->elf_link_hash_flags & ELF_LINK_NON_GOT_REF));
|
|---|
| 2563 | return TRUE;
|
|---|
| 2564 | }
|
|---|
| 2565 |
|
|---|
| 2566 | /* This is a reference to a symbol defined by a dynamic object which
|
|---|
| 2567 | is not a function. */
|
|---|
| 2568 |
|
|---|
| 2569 | /* If we are creating a shared library, we must presume that the
|
|---|
| 2570 | only references to the symbol are via the global offset table.
|
|---|
| 2571 | For such cases we need not do anything here; the relocations will
|
|---|
| 2572 | be handled correctly by relocate_section. */
|
|---|
| 2573 | if (info->shared)
|
|---|
| 2574 | return TRUE;
|
|---|
| 2575 |
|
|---|
| 2576 | /* If there are no references to this symbol that do not use the
|
|---|
| 2577 | GOT, we don't need to generate a copy reloc. */
|
|---|
| 2578 | if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0)
|
|---|
| 2579 | return TRUE;
|
|---|
| 2580 |
|
|---|
| 2581 | if (ELIMINATE_COPY_RELOCS)
|
|---|
| 2582 | {
|
|---|
| 2583 | struct ppc_elf_dyn_relocs *p;
|
|---|
| 2584 | for (p = ppc_elf_hash_entry (h)->dyn_relocs; p != NULL; p = p->next)
|
|---|
| 2585 | {
|
|---|
| 2586 | s = p->sec->output_section;
|
|---|
| 2587 | if (s != NULL && (s->flags & SEC_READONLY) != 0)
|
|---|
| 2588 | break;
|
|---|
| 2589 | }
|
|---|
| 2590 |
|
|---|
| 2591 | /* If we didn't find any dynamic relocs in read-only sections, then
|
|---|
| 2592 | we'll be keeping the dynamic relocs and avoiding the copy reloc. */
|
|---|
| 2593 | if (p == NULL)
|
|---|
| 2594 | {
|
|---|
| 2595 | h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
|
|---|
| 2596 | return TRUE;
|
|---|
| 2597 | }
|
|---|
| 2598 | }
|
|---|
| 2599 |
|
|---|
| 2600 | /* We must allocate the symbol in our .dynbss section, which will
|
|---|
| 2601 | become part of the .bss section of the executable. There will be
|
|---|
| 2602 | an entry for this symbol in the .dynsym section. The dynamic
|
|---|
| 2603 | object will contain position independent code, so all references
|
|---|
| 2604 | from the dynamic object to this symbol will go through the global
|
|---|
| 2605 | offset table. The dynamic linker will use the .dynsym entry to
|
|---|
| 2606 | determine the address it must put in the global offset table, so
|
|---|
| 2607 | both the dynamic object and the regular object will refer to the
|
|---|
| 2608 | same memory location for the variable.
|
|---|
| 2609 |
|
|---|
| 2610 | Of course, if the symbol is sufficiently small, we must instead
|
|---|
| 2611 | allocate it in .sbss. FIXME: It would be better to do this if and
|
|---|
| 2612 | only if there were actually SDAREL relocs for that symbol. */
|
|---|
| 2613 |
|
|---|
| 2614 | if (h->size <= elf_gp_size (htab->elf.dynobj))
|
|---|
| 2615 | s = htab->dynsbss;
|
|---|
| 2616 | else
|
|---|
| 2617 | s = htab->dynbss;
|
|---|
| 2618 | BFD_ASSERT (s != NULL);
|
|---|
| 2619 |
|
|---|
| 2620 | /* We must generate a R_PPC_COPY reloc to tell the dynamic linker to
|
|---|
| 2621 | copy the initial value out of the dynamic object and into the
|
|---|
| 2622 | runtime process image. We need to remember the offset into the
|
|---|
| 2623 | .rela.bss section we are going to use. */
|
|---|
| 2624 | if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
|
|---|
| 2625 | {
|
|---|
| 2626 | asection *srel;
|
|---|
| 2627 |
|
|---|
| 2628 | if (h->size <= elf_gp_size (htab->elf.dynobj))
|
|---|
| 2629 | srel = htab->relsbss;
|
|---|
| 2630 | else
|
|---|
| 2631 | srel = htab->relbss;
|
|---|
| 2632 | BFD_ASSERT (srel != NULL);
|
|---|
| 2633 | srel->_raw_size += sizeof (Elf32_External_Rela);
|
|---|
| 2634 | h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
|
|---|
| 2635 | }
|
|---|
| 2636 |
|
|---|
| 2637 | /* We need to figure out the alignment required for this symbol. I
|
|---|
| 2638 | have no idea how ELF linkers handle this. */
|
|---|
| 2639 | power_of_two = bfd_log2 (h->size);
|
|---|
| 2640 | if (power_of_two > 4)
|
|---|
| 2641 | power_of_two = 4;
|
|---|
| 2642 |
|
|---|
| 2643 | /* Apply the required alignment. */
|
|---|
| 2644 | s->_raw_size = BFD_ALIGN (s->_raw_size,
|
|---|
| 2645 | (bfd_size_type) (1 << power_of_two));
|
|---|
| 2646 | if (power_of_two > bfd_get_section_alignment (htab->elf.dynobj, s))
|
|---|
| 2647 | {
|
|---|
| 2648 | if (! bfd_set_section_alignment (htab->elf.dynobj, s, power_of_two))
|
|---|
| 2649 | return FALSE;
|
|---|
| 2650 | }
|
|---|
| 2651 |
|
|---|
| 2652 | /* Define the symbol as being at this point in the section. */
|
|---|
| 2653 | h->root.u.def.section = s;
|
|---|
| 2654 | h->root.u.def.value = s->_raw_size;
|
|---|
| 2655 |
|
|---|
| 2656 | /* Increment the section size to make room for the symbol. */
|
|---|
| 2657 | s->_raw_size += h->size;
|
|---|
| 2658 |
|
|---|
| 2659 | return TRUE;
|
|---|
| 2660 | }
|
|---|
| 2661 | |
|---|
| 2662 |
|
|---|
| 2663 | /* This is the condition under which finish_dynamic_symbol will be
|
|---|
| 2664 | called from elflink.h. If elflink.h doesn't call our
|
|---|
| 2665 | finish_dynamic_symbol routine, we'll need to do something about
|
|---|
| 2666 | initializing any .plt and .got entries in relocate_section. */
|
|---|
| 2667 | #define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, SHARED, H) \
|
|---|
| 2668 | ((DYN) \
|
|---|
| 2669 | && ((SHARED) \
|
|---|
| 2670 | || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) \
|
|---|
| 2671 | && ((H)->dynindx != -1 \
|
|---|
| 2672 | || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
|
|---|
| 2673 |
|
|---|
| 2674 | /* Of those relocs that might be copied as dynamic relocs, this macro
|
|---|
| 2675 | selects those that must be copied when linking a shared library,
|
|---|
| 2676 | even when the symbol is local. */
|
|---|
| 2677 |
|
|---|
| 2678 | #define MUST_BE_DYN_RELOC(RTYPE) \
|
|---|
| 2679 | ((RTYPE) != R_PPC_REL24 \
|
|---|
| 2680 | && (RTYPE) != R_PPC_REL14 \
|
|---|
| 2681 | && (RTYPE) != R_PPC_REL14_BRTAKEN \
|
|---|
| 2682 | && (RTYPE) != R_PPC_REL14_BRNTAKEN \
|
|---|
| 2683 | && (RTYPE) != R_PPC_REL32)
|
|---|
| 2684 |
|
|---|
| 2685 | /* Allocate space in associated reloc sections for dynamic relocs. */
|
|---|
| 2686 |
|
|---|
| 2687 | static bfd_boolean
|
|---|
| 2688 | allocate_dynrelocs (h, inf)
|
|---|
| 2689 | struct elf_link_hash_entry *h;
|
|---|
| 2690 | PTR inf;
|
|---|
| 2691 | {
|
|---|
| 2692 | struct bfd_link_info *info = (struct bfd_link_info *) inf;
|
|---|
| 2693 | struct ppc_elf_link_hash_entry *eh;
|
|---|
| 2694 | struct ppc_elf_link_hash_table *htab;
|
|---|
| 2695 | struct ppc_elf_dyn_relocs *p;
|
|---|
| 2696 |
|
|---|
| 2697 | if (h->root.type == bfd_link_hash_indirect)
|
|---|
| 2698 | return TRUE;
|
|---|
| 2699 |
|
|---|
| 2700 | if (h->root.type == bfd_link_hash_warning)
|
|---|
| 2701 | /* When warning symbols are created, they **replace** the "real"
|
|---|
| 2702 | entry in the hash table, thus we never get to see the real
|
|---|
| 2703 | symbol in a hash traversal. So look at it now. */
|
|---|
| 2704 | h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|---|
| 2705 |
|
|---|
| 2706 | htab = ppc_elf_hash_table (info);
|
|---|
| 2707 | if (htab->elf.dynamic_sections_created
|
|---|
| 2708 | && h->plt.refcount > 0)
|
|---|
| 2709 | {
|
|---|
| 2710 | /* Make sure this symbol is output as a dynamic symbol. */
|
|---|
| 2711 | if (h->dynindx == -1
|
|---|
| 2712 | && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
|
|---|
| 2713 | {
|
|---|
| 2714 | if (! bfd_elf32_link_record_dynamic_symbol (info, h))
|
|---|
| 2715 | return FALSE;
|
|---|
| 2716 | }
|
|---|
| 2717 |
|
|---|
| 2718 | if (info->shared
|
|---|
| 2719 | || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h))
|
|---|
| 2720 | {
|
|---|
| 2721 | asection *s = htab->plt;
|
|---|
| 2722 |
|
|---|
| 2723 | /* If this is the first .plt entry, make room for the special
|
|---|
| 2724 | first entry. */
|
|---|
| 2725 | if (s->_raw_size == 0)
|
|---|
| 2726 | s->_raw_size += PLT_INITIAL_ENTRY_SIZE;
|
|---|
| 2727 |
|
|---|
| 2728 | /* The PowerPC PLT is actually composed of two parts, the
|
|---|
| 2729 | first part is 2 words (for a load and a jump), and then
|
|---|
| 2730 | there is a remaining word available at the end. */
|
|---|
| 2731 | h->plt.offset = (PLT_INITIAL_ENTRY_SIZE
|
|---|
| 2732 | + (PLT_SLOT_SIZE
|
|---|
| 2733 | * ((s->_raw_size - PLT_INITIAL_ENTRY_SIZE)
|
|---|
| 2734 | / PLT_ENTRY_SIZE)));
|
|---|
| 2735 |
|
|---|
| 2736 | /* If this symbol is not defined in a regular file, and we
|
|---|
| 2737 | are not generating a shared library, then set the symbol
|
|---|
| 2738 | to this location in the .plt. This is required to make
|
|---|
| 2739 | function pointers compare as equal between the normal
|
|---|
| 2740 | executable and the shared library. */
|
|---|
| 2741 | if (! info->shared
|
|---|
| 2742 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
|
|---|
| 2743 | {
|
|---|
| 2744 | h->root.u.def.section = s;
|
|---|
| 2745 | h->root.u.def.value = h->plt.offset;
|
|---|
| 2746 | }
|
|---|
| 2747 |
|
|---|
| 2748 | /* Make room for this entry. After the 8192nd entry, room
|
|---|
| 2749 | for two entries is allocated. */
|
|---|
| 2750 | s->_raw_size += PLT_ENTRY_SIZE;
|
|---|
| 2751 | if ((s->_raw_size - PLT_INITIAL_ENTRY_SIZE) / PLT_ENTRY_SIZE
|
|---|
| 2752 | > PLT_NUM_SINGLE_ENTRIES)
|
|---|
| 2753 | s->_raw_size += PLT_ENTRY_SIZE;
|
|---|
| 2754 |
|
|---|
| 2755 | /* We also need to make an entry in the .rela.plt section. */
|
|---|
| 2756 | htab->relplt->_raw_size += sizeof (Elf32_External_Rela);
|
|---|
| 2757 | }
|
|---|
| 2758 | else
|
|---|
| 2759 | {
|
|---|
| 2760 | h->plt.offset = (bfd_vma) -1;
|
|---|
| 2761 | h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
|
|---|
| 2762 | }
|
|---|
| 2763 | }
|
|---|
| 2764 | else
|
|---|
| 2765 | {
|
|---|
| 2766 | h->plt.offset = (bfd_vma) -1;
|
|---|
| 2767 | h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
|
|---|
| 2768 | }
|
|---|
| 2769 |
|
|---|
| 2770 | eh = (struct ppc_elf_link_hash_entry *) h;
|
|---|
| 2771 | if (eh->elf.got.refcount > 0)
|
|---|
| 2772 | {
|
|---|
| 2773 | /* Make sure this symbol is output as a dynamic symbol. */
|
|---|
| 2774 | if (eh->elf.dynindx == -1
|
|---|
| 2775 | && (eh->elf.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
|
|---|
| 2776 | {
|
|---|
| 2777 | if (!bfd_elf32_link_record_dynamic_symbol (info, &eh->elf))
|
|---|
| 2778 | return FALSE;
|
|---|
| 2779 | }
|
|---|
| 2780 |
|
|---|
| 2781 | if (eh->tls_mask == (TLS_TLS | TLS_LD)
|
|---|
| 2782 | && !(eh->elf.elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC))
|
|---|
| 2783 | /* If just an LD reloc, we'll just use htab->tlsld_got.offset. */
|
|---|
| 2784 | eh->elf.got.offset = (bfd_vma) -1;
|
|---|
| 2785 | else
|
|---|
| 2786 | {
|
|---|
| 2787 | bfd_boolean dyn;
|
|---|
| 2788 | eh->elf.got.offset = htab->got->_raw_size;
|
|---|
| 2789 | if ((eh->tls_mask & TLS_TLS) != 0)
|
|---|
| 2790 | {
|
|---|
| 2791 | if ((eh->tls_mask & TLS_LD) != 0)
|
|---|
| 2792 | htab->got->_raw_size += 8;
|
|---|
| 2793 | if ((eh->tls_mask & TLS_GD) != 0)
|
|---|
| 2794 | htab->got->_raw_size += 8;
|
|---|
| 2795 | if ((eh->tls_mask & (TLS_TPREL | TLS_TPRELGD)) != 0)
|
|---|
| 2796 | htab->got->_raw_size += 4;
|
|---|
| 2797 | if ((eh->tls_mask & TLS_DTPREL) != 0)
|
|---|
| 2798 | htab->got->_raw_size += 4;
|
|---|
| 2799 | }
|
|---|
| 2800 | else
|
|---|
| 2801 | htab->got->_raw_size += 4;
|
|---|
| 2802 | dyn = htab->elf.dynamic_sections_created;
|
|---|
| 2803 | if (info->shared
|
|---|
| 2804 | || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, &eh->elf))
|
|---|
| 2805 | {
|
|---|
| 2806 | /* All the entries we allocated need relocs. */
|
|---|
| 2807 | htab->relgot->_raw_size
|
|---|
| 2808 | += ((htab->got->_raw_size - eh->elf.got.offset) / 4
|
|---|
| 2809 | * sizeof (Elf32_External_Rela));
|
|---|
| 2810 | /* Except LD only needs one. */
|
|---|
| 2811 | if ((eh->tls_mask & TLS_LD) != 0)
|
|---|
| 2812 | htab->relgot->_raw_size -= sizeof (Elf32_External_Rela);
|
|---|
| 2813 | }
|
|---|
| 2814 | }
|
|---|
| 2815 | }
|
|---|
| 2816 | else
|
|---|
| 2817 | eh->elf.got.offset = (bfd_vma) -1;
|
|---|
| 2818 |
|
|---|
| 2819 | if (eh->dyn_relocs == NULL)
|
|---|
| 2820 | return TRUE;
|
|---|
| 2821 |
|
|---|
| 2822 | /* In the shared -Bsymbolic case, discard space allocated for
|
|---|
| 2823 | dynamic pc-relative relocs against symbols which turn out to be
|
|---|
| 2824 | defined in regular objects. For the normal shared case, discard
|
|---|
| 2825 | space for relocs that have become local due to symbol visibility
|
|---|
| 2826 | changes. */
|
|---|
| 2827 | if (info->shared)
|
|---|
| 2828 | {
|
|---|
| 2829 | if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0
|
|---|
| 2830 | && ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0
|
|---|
| 2831 | || info->symbolic))
|
|---|
| 2832 | {
|
|---|
| 2833 | struct ppc_elf_dyn_relocs **pp;
|
|---|
| 2834 |
|
|---|
| 2835 | for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
|
|---|
| 2836 | {
|
|---|
| 2837 | p->count -= p->pc_count;
|
|---|
| 2838 | p->pc_count = 0;
|
|---|
| 2839 | if (p->count == 0)
|
|---|
| 2840 | *pp = p->next;
|
|---|
| 2841 | else
|
|---|
| 2842 | pp = &p->next;
|
|---|
| 2843 | }
|
|---|
| 2844 | }
|
|---|
| 2845 | }
|
|---|
| 2846 | else if (ELIMINATE_COPY_RELOCS)
|
|---|
| 2847 | {
|
|---|
| 2848 | /* For the non-shared case, discard space for relocs against
|
|---|
| 2849 | symbols which turn out to need copy relocs or are not
|
|---|
| 2850 | dynamic. */
|
|---|
| 2851 |
|
|---|
| 2852 | if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
|
|---|
| 2853 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
|
|---|
| 2854 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
|
|---|
| 2855 | {
|
|---|
| 2856 | /* Make sure this symbol is output as a dynamic symbol.
|
|---|
| 2857 | Undefined weak syms won't yet be marked as dynamic. */
|
|---|
| 2858 | if (h->dynindx == -1
|
|---|
| 2859 | && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
|
|---|
| 2860 | {
|
|---|
| 2861 | if (! bfd_elf64_link_record_dynamic_symbol (info, h))
|
|---|
| 2862 | return FALSE;
|
|---|
| 2863 | }
|
|---|
| 2864 |
|
|---|
| 2865 | /* If that succeeded, we know we'll be keeping all the
|
|---|
| 2866 | relocs. */
|
|---|
| 2867 | if (h->dynindx != -1)
|
|---|
| 2868 | goto keep;
|
|---|
| 2869 | }
|
|---|
| 2870 |
|
|---|
| 2871 | eh->dyn_relocs = NULL;
|
|---|
| 2872 |
|
|---|
| 2873 | keep: ;
|
|---|
| 2874 | }
|
|---|
| 2875 |
|
|---|
| 2876 | /* Finally, allocate space. */
|
|---|
| 2877 | for (p = eh->dyn_relocs; p != NULL; p = p->next)
|
|---|
| 2878 | {
|
|---|
| 2879 | asection *sreloc = elf_section_data (p->sec)->sreloc;
|
|---|
| 2880 | sreloc->_raw_size += p->count * sizeof (Elf32_External_Rela);
|
|---|
| 2881 | }
|
|---|
| 2882 |
|
|---|
| 2883 | return TRUE;
|
|---|
| 2884 | }
|
|---|
| 2885 |
|
|---|
| 2886 | /* Find any dynamic relocs that apply to read-only sections. */
|
|---|
| 2887 |
|
|---|
| 2888 | static bfd_boolean
|
|---|
| 2889 | readonly_dynrelocs (h, info)
|
|---|
| 2890 | struct elf_link_hash_entry *h;
|
|---|
| 2891 | PTR info;
|
|---|
| 2892 | {
|
|---|
| 2893 | struct ppc_elf_dyn_relocs *p;
|
|---|
| 2894 |
|
|---|
| 2895 | if (h->root.type == bfd_link_hash_indirect)
|
|---|
| 2896 | return TRUE;
|
|---|
| 2897 |
|
|---|
| 2898 | if (h->root.type == bfd_link_hash_warning)
|
|---|
| 2899 | h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|---|
| 2900 |
|
|---|
| 2901 | for (p = ppc_elf_hash_entry (h)->dyn_relocs; p != NULL; p = p->next)
|
|---|
| 2902 | {
|
|---|
| 2903 | asection *s = p->sec->output_section;
|
|---|
| 2904 |
|
|---|
| 2905 | if (s != NULL
|
|---|
| 2906 | && ((s->flags & (SEC_READONLY | SEC_ALLOC))
|
|---|
| 2907 | == (SEC_READONLY | SEC_ALLOC)))
|
|---|
| 2908 | {
|
|---|
| 2909 | ((struct bfd_link_info *) info)->flags |= DF_TEXTREL;
|
|---|
| 2910 |
|
|---|
| 2911 | /* Not an error, just cut short the traversal. */
|
|---|
| 2912 | return FALSE;
|
|---|
| 2913 | }
|
|---|
| 2914 | }
|
|---|
| 2915 | return TRUE;
|
|---|
| 2916 | }
|
|---|
| 2917 |
|
|---|
| 2918 | /* Set the sizes of the dynamic sections. */
|
|---|
| 2919 |
|
|---|
| 2920 | static bfd_boolean
|
|---|
| 2921 | ppc_elf_size_dynamic_sections (output_bfd, info)
|
|---|
| 2922 | bfd *output_bfd ATTRIBUTE_UNUSED;
|
|---|
| 2923 | struct bfd_link_info *info;
|
|---|
| 2924 | {
|
|---|
| 2925 | struct ppc_elf_link_hash_table *htab;
|
|---|
| 2926 | asection *s;
|
|---|
| 2927 | bfd_boolean relocs;
|
|---|
| 2928 | bfd *ibfd;
|
|---|
| 2929 |
|
|---|
| 2930 | #ifdef DEBUG
|
|---|
| 2931 | fprintf (stderr, "ppc_elf_size_dynamic_sections called\n");
|
|---|
| 2932 | #endif
|
|---|
| 2933 |
|
|---|
| 2934 | htab = ppc_elf_hash_table (info);
|
|---|
| 2935 | BFD_ASSERT (htab->elf.dynobj != NULL);
|
|---|
| 2936 |
|
|---|
| 2937 | if (elf_hash_table (info)->dynamic_sections_created)
|
|---|
| 2938 | {
|
|---|
| 2939 | /* Set the contents of the .interp section to the interpreter. */
|
|---|
| 2940 | if (! info->shared)
|
|---|
| 2941 | {
|
|---|
| 2942 | s = bfd_get_section_by_name (htab->elf.dynobj, ".interp");
|
|---|
| 2943 | BFD_ASSERT (s != NULL);
|
|---|
| 2944 | s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
|
|---|
| 2945 | s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
|
|---|
| 2946 | }
|
|---|
| 2947 | }
|
|---|
| 2948 |
|
|---|
| 2949 | if (htab->tlsld_got.refcount > 0)
|
|---|
| 2950 | {
|
|---|
| 2951 | htab->tlsld_got.offset = htab->got->_raw_size;
|
|---|
| 2952 | htab->got->_raw_size += 8;
|
|---|
| 2953 | if (info->shared)
|
|---|
| 2954 | htab->relgot->_raw_size += sizeof (Elf32_External_Rela);
|
|---|
| 2955 | }
|
|---|
| 2956 | else
|
|---|
| 2957 | htab->tlsld_got.offset = (bfd_vma) -1;
|
|---|
| 2958 |
|
|---|
| 2959 | /* Set up .got offsets for local syms, and space for local dynamic
|
|---|
| 2960 | relocs. */
|
|---|
| 2961 | for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
|
|---|
| 2962 | {
|
|---|
| 2963 | bfd_signed_vma *local_got;
|
|---|
| 2964 | bfd_signed_vma *end_local_got;
|
|---|
| 2965 | char *lgot_masks;
|
|---|
| 2966 | bfd_size_type locsymcount;
|
|---|
| 2967 | Elf_Internal_Shdr *symtab_hdr;
|
|---|
| 2968 | asection *srel;
|
|---|
| 2969 |
|
|---|
| 2970 | if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
|
|---|
| 2971 | continue;
|
|---|
| 2972 |
|
|---|
| 2973 | for (s = ibfd->sections; s != NULL; s = s->next)
|
|---|
| 2974 | {
|
|---|
| 2975 | struct ppc_elf_dyn_relocs *p;
|
|---|
| 2976 |
|
|---|
| 2977 | for (p = ((struct ppc_elf_dyn_relocs *)
|
|---|
| 2978 | elf_section_data (s)->local_dynrel);
|
|---|
| 2979 | p != NULL;
|
|---|
| 2980 | p = p->next)
|
|---|
| 2981 | {
|
|---|
| 2982 | if (!bfd_is_abs_section (p->sec)
|
|---|
| 2983 | && bfd_is_abs_section (p->sec->output_section))
|
|---|
| 2984 | {
|
|---|
| 2985 | /* Input section has been discarded, either because
|
|---|
| 2986 | it is a copy of a linkonce section or due to
|
|---|
| 2987 | linker script /DISCARD/, so we'll be discarding
|
|---|
| 2988 | the relocs too. */
|
|---|
| 2989 | }
|
|---|
| 2990 | else if (p->count != 0)
|
|---|
| 2991 | {
|
|---|
| 2992 | elf_section_data (p->sec)->sreloc->_raw_size
|
|---|
| 2993 | += p->count * sizeof (Elf32_External_Rela);
|
|---|
| 2994 | if ((p->sec->output_section->flags
|
|---|
| 2995 | & (SEC_READONLY | SEC_ALLOC))
|
|---|
| 2996 | == (SEC_READONLY | SEC_ALLOC))
|
|---|
| 2997 | info->flags |= DF_TEXTREL;
|
|---|
| 2998 | }
|
|---|
| 2999 | }
|
|---|
| 3000 | }
|
|---|
| 3001 |
|
|---|
| 3002 | local_got = elf_local_got_refcounts (ibfd);
|
|---|
| 3003 | if (!local_got)
|
|---|
| 3004 | continue;
|
|---|
| 3005 |
|
|---|
| 3006 | symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
|
|---|
| 3007 | locsymcount = symtab_hdr->sh_info;
|
|---|
| 3008 | end_local_got = local_got + locsymcount;
|
|---|
| 3009 | lgot_masks = (char *) end_local_got;
|
|---|
| 3010 | s = htab->got;
|
|---|
| 3011 | srel = htab->relgot;
|
|---|
| 3012 | for (; local_got < end_local_got; ++local_got, ++lgot_masks)
|
|---|
| 3013 | if (*local_got > 0)
|
|---|
| 3014 | {
|
|---|
| 3015 | if (*lgot_masks == (TLS_TLS | TLS_LD))
|
|---|
| 3016 | {
|
|---|
| 3017 | /* If just an LD reloc, we'll just use
|
|---|
| 3018 | htab->tlsld_got.offset. */
|
|---|
| 3019 | if (htab->tlsld_got.offset == (bfd_vma) -1)
|
|---|
| 3020 | {
|
|---|
| 3021 | htab->tlsld_got.offset = s->_raw_size;
|
|---|
| 3022 | s->_raw_size += 8;
|
|---|
| 3023 | if (info->shared)
|
|---|
| 3024 | srel->_raw_size += sizeof (Elf32_External_Rela);
|
|---|
| 3025 | }
|
|---|
| 3026 | *local_got = (bfd_vma) -1;
|
|---|
| 3027 | }
|
|---|
| 3028 | else
|
|---|
| 3029 | {
|
|---|
| 3030 | *local_got = s->_raw_size;
|
|---|
| 3031 | if ((*lgot_masks & TLS_TLS) != 0)
|
|---|
| 3032 | {
|
|---|
| 3033 | if ((*lgot_masks & TLS_GD) != 0)
|
|---|
| 3034 | s->_raw_size += 8;
|
|---|
| 3035 | if ((*lgot_masks & (TLS_TPREL | TLS_TPRELGD)) != 0)
|
|---|
| 3036 | s->_raw_size += 4;
|
|---|
| 3037 | if ((*lgot_masks & TLS_DTPREL) != 0)
|
|---|
| 3038 | s->_raw_size += 4;
|
|---|
| 3039 | }
|
|---|
| 3040 | else
|
|---|
| 3041 | s->_raw_size += 4;
|
|---|
| 3042 | if (info->shared)
|
|---|
| 3043 | srel->_raw_size += ((s->_raw_size - *local_got) / 4
|
|---|
| 3044 | * sizeof (Elf32_External_Rela));
|
|---|
| 3045 | }
|
|---|
| 3046 | }
|
|---|
| 3047 | else
|
|---|
| 3048 | *local_got = (bfd_vma) -1;
|
|---|
| 3049 | }
|
|---|
| 3050 |
|
|---|
| 3051 | /* Allocate space for global sym dynamic relocs. */
|
|---|
| 3052 | elf_link_hash_traverse (elf_hash_table (info), allocate_dynrelocs, info);
|
|---|
| 3053 |
|
|---|
| 3054 | /* We've now determined the sizes of the various dynamic sections.
|
|---|
| 3055 | Allocate memory for them. */
|
|---|
| 3056 | relocs = FALSE;
|
|---|
| 3057 | for (s = htab->elf.dynobj->sections; s != NULL; s = s->next)
|
|---|
| 3058 | {
|
|---|
| 3059 | if ((s->flags & SEC_LINKER_CREATED) == 0)
|
|---|
| 3060 | continue;
|
|---|
| 3061 |
|
|---|
| 3062 | if (s == htab->plt
|
|---|
| 3063 | || s == htab->got
|
|---|
| 3064 | || (htab->sdata != NULL && s == htab->sdata->section)
|
|---|
| 3065 | || (htab->sdata2 != NULL && s == htab->sdata2->section))
|
|---|
| 3066 | {
|
|---|
| 3067 | /* Strip this section if we don't need it; see the
|
|---|
| 3068 | comment below. */
|
|---|
| 3069 | }
|
|---|
| 3070 | else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0)
|
|---|
| 3071 | {
|
|---|
| 3072 | if (s->_raw_size == 0)
|
|---|
| 3073 | {
|
|---|
| 3074 | /* If we don't need this section, strip it from the
|
|---|
| 3075 | output file. This is mostly to handle .rela.bss and
|
|---|
| 3076 | .rela.plt. We must create both sections in
|
|---|
| 3077 | create_dynamic_sections, because they must be created
|
|---|
| 3078 | before the linker maps input sections to output
|
|---|
| 3079 | sections. The linker does that before
|
|---|
| 3080 | adjust_dynamic_symbol is called, and it is that
|
|---|
| 3081 | function which decides whether anything needs to go
|
|---|
| 3082 | into these sections. */
|
|---|
| 3083 | }
|
|---|
| 3084 | else
|
|---|
| 3085 | {
|
|---|
| 3086 | /* Remember whether there are any relocation sections. */
|
|---|
| 3087 | relocs = TRUE;
|
|---|
| 3088 |
|
|---|
| 3089 | /* We use the reloc_count field as a counter if we need
|
|---|
| 3090 | to copy relocs into the output file. */
|
|---|
| 3091 | s->reloc_count = 0;
|
|---|
| 3092 | }
|
|---|
| 3093 | }
|
|---|
| 3094 | else
|
|---|
| 3095 | {
|
|---|
| 3096 | /* It's not one of our sections, so don't allocate space. */
|
|---|
| 3097 | continue;
|
|---|
| 3098 | }
|
|---|
| 3099 |
|
|---|
| 3100 | if (s->_raw_size == 0)
|
|---|
| 3101 | {
|
|---|
| 3102 | _bfd_strip_section_from_output (info, s);
|
|---|
| 3103 | continue;
|
|---|
| 3104 | }
|
|---|
| 3105 |
|
|---|
| 3106 | /* Allocate memory for the section contents. */
|
|---|
| 3107 | s->contents = (bfd_byte *) bfd_zalloc (htab->elf.dynobj, s->_raw_size);
|
|---|
| 3108 | if (s->contents == NULL)
|
|---|
| 3109 | return FALSE;
|
|---|
| 3110 | }
|
|---|
| 3111 |
|
|---|
| 3112 | if (htab->elf.dynamic_sections_created)
|
|---|
| 3113 | {
|
|---|
| 3114 | /* Add some entries to the .dynamic section. We fill in the
|
|---|
| 3115 | values later, in ppc_elf_finish_dynamic_sections, but we
|
|---|
| 3116 | must add the entries now so that we get the correct size for
|
|---|
| 3117 | the .dynamic section. The DT_DEBUG entry is filled in by the
|
|---|
| 3118 | dynamic linker and used by the debugger. */
|
|---|
| 3119 | #define add_dynamic_entry(TAG, VAL) \
|
|---|
| 3120 | bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
|
|---|
| 3121 |
|
|---|
| 3122 | if (!info->shared)
|
|---|
| 3123 | {
|
|---|
| 3124 | if (!add_dynamic_entry (DT_DEBUG, 0))
|
|---|
| 3125 | return FALSE;
|
|---|
| 3126 | }
|
|---|
| 3127 |
|
|---|
| 3128 | if (htab->plt != NULL && htab->plt->_raw_size != 0)
|
|---|
| 3129 | {
|
|---|
| 3130 | if (!add_dynamic_entry (DT_PLTGOT, 0)
|
|---|
| 3131 | || !add_dynamic_entry (DT_PLTRELSZ, 0)
|
|---|
| 3132 | || !add_dynamic_entry (DT_PLTREL, DT_RELA)
|
|---|
| 3133 | || !add_dynamic_entry (DT_JMPREL, 0))
|
|---|
| 3134 | return FALSE;
|
|---|
| 3135 | }
|
|---|
| 3136 |
|
|---|
| 3137 | if (relocs)
|
|---|
| 3138 | {
|
|---|
| 3139 | if (!add_dynamic_entry (DT_RELA, 0)
|
|---|
| 3140 | || !add_dynamic_entry (DT_RELASZ, 0)
|
|---|
| 3141 | || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
|
|---|
| 3142 | return FALSE;
|
|---|
| 3143 | }
|
|---|
| 3144 |
|
|---|
| 3145 | /* If any dynamic relocs apply to a read-only section, then we
|
|---|
| 3146 | need a DT_TEXTREL entry. */
|
|---|
| 3147 | if ((info->flags & DF_TEXTREL) == 0)
|
|---|
| 3148 | elf_link_hash_traverse (elf_hash_table (info), readonly_dynrelocs,
|
|---|
| 3149 | (PTR) info);
|
|---|
| 3150 |
|
|---|
| 3151 | if ((info->flags & DF_TEXTREL) != 0)
|
|---|
| 3152 | {
|
|---|
| 3153 | if (!add_dynamic_entry (DT_TEXTREL, 0))
|
|---|
| 3154 | return FALSE;
|
|---|
| 3155 | }
|
|---|
| 3156 | }
|
|---|
| 3157 | #undef add_dynamic_entry
|
|---|
| 3158 |
|
|---|
| 3159 | return TRUE;
|
|---|
| 3160 | }
|
|---|
| 3161 | |
|---|
| 3162 |
|
|---|
| 3163 | static bfd_boolean
|
|---|
| 3164 | update_local_sym_info (abfd, symtab_hdr, r_symndx, tls_type)
|
|---|
| 3165 | bfd *abfd;
|
|---|
| 3166 | Elf_Internal_Shdr *symtab_hdr;
|
|---|
| 3167 | unsigned long r_symndx;
|
|---|
| 3168 | int tls_type;
|
|---|
| 3169 | {
|
|---|
| 3170 | bfd_signed_vma *local_got_refcounts = elf_local_got_refcounts (abfd);
|
|---|
| 3171 | char *local_got_tls_masks;
|
|---|
| 3172 |
|
|---|
| 3173 | if (local_got_refcounts == NULL)
|
|---|
| 3174 | {
|
|---|
| 3175 | bfd_size_type size = symtab_hdr->sh_info;
|
|---|
| 3176 |
|
|---|
| 3177 | size *= sizeof (*local_got_refcounts) + sizeof (*local_got_tls_masks);
|
|---|
| 3178 | local_got_refcounts = (bfd_signed_vma *) bfd_zalloc (abfd, size);
|
|---|
| 3179 | if (local_got_refcounts == NULL)
|
|---|
| 3180 | return FALSE;
|
|---|
| 3181 | elf_local_got_refcounts (abfd) = local_got_refcounts;
|
|---|
| 3182 | }
|
|---|
| 3183 |
|
|---|
| 3184 | local_got_refcounts[r_symndx] += 1;
|
|---|
| 3185 | local_got_tls_masks = (char *) (local_got_refcounts + symtab_hdr->sh_info);
|
|---|
| 3186 | local_got_tls_masks[r_symndx] |= tls_type;
|
|---|
| 3187 | return TRUE;
|
|---|
| 3188 | }
|
|---|
| 3189 |
|
|---|
| 3190 | static void
|
|---|
| 3191 | bad_shared_reloc (abfd, r_type)
|
|---|
| 3192 | bfd *abfd;
|
|---|
| 3193 | enum elf_ppc_reloc_type r_type;
|
|---|
| 3194 | {
|
|---|
| 3195 | (*_bfd_error_handler)
|
|---|
| 3196 | (_("%s: relocation %s cannot be used when making a shared object"),
|
|---|
| 3197 | bfd_archive_filename (abfd),
|
|---|
| 3198 | ppc_elf_howto_table[(int) r_type]->name);
|
|---|
| 3199 | bfd_set_error (bfd_error_bad_value);
|
|---|
| 3200 | }
|
|---|
| 3201 |
|
|---|
| 3202 | /* Look through the relocs for a section during the first phase, and
|
|---|
| 3203 | allocate space in the global offset table or procedure linkage
|
|---|
| 3204 | table. */
|
|---|
| 3205 |
|
|---|
| 3206 | static bfd_boolean
|
|---|
| 3207 | ppc_elf_check_relocs (abfd, info, sec, relocs)
|
|---|
| 3208 | bfd *abfd;
|
|---|
| 3209 | struct bfd_link_info *info;
|
|---|
| 3210 | asection *sec;
|
|---|
| 3211 | const Elf_Internal_Rela *relocs;
|
|---|
| 3212 | {
|
|---|
| 3213 | struct ppc_elf_link_hash_table *htab;
|
|---|
| 3214 | Elf_Internal_Shdr *symtab_hdr;
|
|---|
| 3215 | struct elf_link_hash_entry **sym_hashes;
|
|---|
| 3216 | const Elf_Internal_Rela *rel;
|
|---|
| 3217 | const Elf_Internal_Rela *rel_end;
|
|---|
| 3218 | asection *sreloc;
|
|---|
| 3219 |
|
|---|
| 3220 | if (info->relocateable)
|
|---|
| 3221 | return TRUE;
|
|---|
| 3222 |
|
|---|
| 3223 | #ifdef DEBUG
|
|---|
| 3224 | fprintf (stderr, "ppc_elf_check_relocs called for section %s in %s\n",
|
|---|
| 3225 | bfd_get_section_name (abfd, sec),
|
|---|
| 3226 | bfd_archive_filename (abfd));
|
|---|
| 3227 | #endif
|
|---|
| 3228 |
|
|---|
| 3229 | /* Create the linker generated sections all the time so that the
|
|---|
| 3230 | special symbols are created. */
|
|---|
| 3231 |
|
|---|
| 3232 | htab = ppc_elf_hash_table (info);
|
|---|
| 3233 | if (htab->sdata == NULL)
|
|---|
| 3234 | {
|
|---|
| 3235 | htab->sdata = elf_linker_section (abfd, LINKER_SECTION_SDATA);
|
|---|
| 3236 | if (htab->sdata == NULL)
|
|---|
| 3237 | htab->sdata = ppc_elf_create_linker_section (abfd, info,
|
|---|
| 3238 | LINKER_SECTION_SDATA);
|
|---|
| 3239 | if (htab->sdata == NULL)
|
|---|
| 3240 | return FALSE;
|
|---|
| 3241 | }
|
|---|
| 3242 |
|
|---|
| 3243 | if (htab->sdata2 == NULL)
|
|---|
| 3244 | {
|
|---|
| 3245 | htab->sdata2 = elf_linker_section (abfd, LINKER_SECTION_SDATA2);
|
|---|
| 3246 | if (htab->sdata2 == NULL)
|
|---|
| 3247 | htab->sdata2 = ppc_elf_create_linker_section (abfd, info,
|
|---|
| 3248 | LINKER_SECTION_SDATA2);
|
|---|
| 3249 | if (htab->sdata2 == NULL)
|
|---|
| 3250 | return FALSE;
|
|---|
| 3251 | }
|
|---|
| 3252 |
|
|---|
| 3253 | symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
|
|---|
| 3254 | sym_hashes = elf_sym_hashes (abfd);
|
|---|
| 3255 | sreloc = NULL;
|
|---|
| 3256 |
|
|---|
| 3257 | rel_end = relocs + sec->reloc_count;
|
|---|
| 3258 | for (rel = relocs; rel < rel_end; rel++)
|
|---|
| 3259 | {
|
|---|
| 3260 | unsigned long r_symndx;
|
|---|
| 3261 | enum elf_ppc_reloc_type r_type;
|
|---|
| 3262 | struct elf_link_hash_entry *h;
|
|---|
| 3263 | int tls_type = 0;
|
|---|
| 3264 |
|
|---|
| 3265 | r_symndx = ELF32_R_SYM (rel->r_info);
|
|---|
| 3266 | if (r_symndx < symtab_hdr->sh_info)
|
|---|
| 3267 | h = NULL;
|
|---|
| 3268 | else
|
|---|
| 3269 | h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
|---|
| 3270 |
|
|---|
| 3271 | /* If a relocation refers to _GLOBAL_OFFSET_TABLE_, create the .got.
|
|---|
| 3272 | This shows up in particular in an R_PPC_ADDR32 in the eabi
|
|---|
| 3273 | startup code. */
|
|---|
| 3274 | if (h && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
|
|---|
| 3275 | {
|
|---|
| 3276 | if (htab->got == NULL)
|
|---|
| 3277 | {
|
|---|
| 3278 | if (htab->elf.dynobj == NULL)
|
|---|
| 3279 | htab->elf.dynobj = abfd;
|
|---|
| 3280 | if (!ppc_elf_create_got (htab->elf.dynobj, info))
|
|---|
| 3281 | return FALSE;
|
|---|
| 3282 | }
|
|---|
| 3283 | }
|
|---|
| 3284 |
|
|---|
| 3285 | r_type = (enum elf_ppc_reloc_type) ELF32_R_TYPE (rel->r_info);
|
|---|
| 3286 | switch (r_type)
|
|---|
| 3287 | {
|
|---|
| 3288 | case R_PPC_GOT_TLSLD16:
|
|---|
| 3289 | case R_PPC_GOT_TLSLD16_LO:
|
|---|
| 3290 | case R_PPC_GOT_TLSLD16_HI:
|
|---|
| 3291 | case R_PPC_GOT_TLSLD16_HA:
|
|---|
| 3292 | htab->tlsld_got.refcount += 1;
|
|---|
| 3293 | tls_type = TLS_TLS | TLS_LD;
|
|---|
| 3294 | goto dogottls;
|
|---|
| 3295 |
|
|---|
| 3296 | case R_PPC_GOT_TLSGD16:
|
|---|
| 3297 | case R_PPC_GOT_TLSGD16_LO:
|
|---|
| 3298 | case R_PPC_GOT_TLSGD16_HI:
|
|---|
| 3299 | case R_PPC_GOT_TLSGD16_HA:
|
|---|
| 3300 | tls_type = TLS_TLS | TLS_GD;
|
|---|
| 3301 | goto dogottls;
|
|---|
| 3302 |
|
|---|
| 3303 | case R_PPC_GOT_TPREL16:
|
|---|
| 3304 | case R_PPC_GOT_TPREL16_LO:
|
|---|
| 3305 | case R_PPC_GOT_TPREL16_HI:
|
|---|
| 3306 | case R_PPC_GOT_TPREL16_HA:
|
|---|
| 3307 | if (info->shared)
|
|---|
| 3308 | info->flags |= DF_STATIC_TLS;
|
|---|
| 3309 | tls_type = TLS_TLS | TLS_TPREL;
|
|---|
| 3310 | goto dogottls;
|
|---|
| 3311 |
|
|---|
| 3312 | case R_PPC_GOT_DTPREL16:
|
|---|
| 3313 | case R_PPC_GOT_DTPREL16_LO:
|
|---|
| 3314 | case R_PPC_GOT_DTPREL16_HI:
|
|---|
| 3315 | case R_PPC_GOT_DTPREL16_HA:
|
|---|
| 3316 | tls_type = TLS_TLS | TLS_DTPREL;
|
|---|
| 3317 | dogottls:
|
|---|
| 3318 | sec->has_tls_reloc = 1;
|
|---|
| 3319 | /* Fall thru */
|
|---|
| 3320 |
|
|---|
| 3321 | /* GOT16 relocations */
|
|---|
| 3322 | case R_PPC_GOT16:
|
|---|
| 3323 | case R_PPC_GOT16_LO:
|
|---|
| 3324 | case R_PPC_GOT16_HI:
|
|---|
| 3325 | case R_PPC_GOT16_HA:
|
|---|
| 3326 | /* This symbol requires a global offset table entry. */
|
|---|
| 3327 | if (htab->got == NULL)
|
|---|
| 3328 | {
|
|---|
| 3329 | if (htab->elf.dynobj == NULL)
|
|---|
| 3330 | htab->elf.dynobj = abfd;
|
|---|
| 3331 | if (!ppc_elf_create_got (htab->elf.dynobj, info))
|
|---|
| 3332 | return FALSE;
|
|---|
| 3333 | }
|
|---|
| 3334 | if (h != NULL)
|
|---|
| 3335 | {
|
|---|
| 3336 | h->got.refcount += 1;
|
|---|
| 3337 | ppc_elf_hash_entry (h)->tls_mask |= tls_type;
|
|---|
| 3338 | }
|
|---|
| 3339 | else
|
|---|
| 3340 | /* This is a global offset table entry for a local symbol. */
|
|---|
| 3341 | if (!update_local_sym_info (abfd, symtab_hdr, r_symndx, tls_type))
|
|---|
| 3342 | return FALSE;
|
|---|
| 3343 | break;
|
|---|
| 3344 |
|
|---|
| 3345 | /* Indirect .sdata relocation. */
|
|---|
| 3346 | case R_PPC_EMB_SDAI16:
|
|---|
| 3347 | if (info->shared)
|
|---|
| 3348 | {
|
|---|
| 3349 | bad_shared_reloc (abfd, r_type);
|
|---|
| 3350 | return FALSE;
|
|---|
| 3351 | }
|
|---|
| 3352 | if (!bfd_elf32_create_pointer_linker_section (abfd, info,
|
|---|
| 3353 | htab->sdata, h, rel))
|
|---|
| 3354 | return FALSE;
|
|---|
| 3355 | break;
|
|---|
| 3356 |
|
|---|
| 3357 | /* Indirect .sdata2 relocation. */
|
|---|
| 3358 | case R_PPC_EMB_SDA2I16:
|
|---|
| 3359 | if (info->shared)
|
|---|
| 3360 | {
|
|---|
| 3361 | bad_shared_reloc (abfd, r_type);
|
|---|
| 3362 | return FALSE;
|
|---|
| 3363 | }
|
|---|
| 3364 | if (!bfd_elf32_create_pointer_linker_section (abfd, info,
|
|---|
| 3365 | htab->sdata2, h, rel))
|
|---|
| 3366 | return FALSE;
|
|---|
| 3367 | break;
|
|---|
| 3368 |
|
|---|
| 3369 | case R_PPC_SDAREL16:
|
|---|
| 3370 | case R_PPC_EMB_SDA2REL:
|
|---|
| 3371 | case R_PPC_EMB_SDA21:
|
|---|
| 3372 | case R_PPC_EMB_RELSDA:
|
|---|
| 3373 | case R_PPC_EMB_NADDR32:
|
|---|
| 3374 | case R_PPC_EMB_NADDR16:
|
|---|
| 3375 | case R_PPC_EMB_NADDR16_LO:
|
|---|
| 3376 | case R_PPC_EMB_NADDR16_HI:
|
|---|
| 3377 | case R_PPC_EMB_NADDR16_HA:
|
|---|
| 3378 | if (info->shared)
|
|---|
| 3379 | {
|
|---|
| 3380 | bad_shared_reloc (abfd, r_type);
|
|---|
| 3381 | return FALSE;
|
|---|
| 3382 | }
|
|---|
| 3383 | break;
|
|---|
| 3384 |
|
|---|
| 3385 | case R_PPC_PLT32:
|
|---|
| 3386 | case R_PPC_PLTREL24:
|
|---|
| 3387 | case R_PPC_PLTREL32:
|
|---|
| 3388 | case R_PPC_PLT16_LO:
|
|---|
| 3389 | case R_PPC_PLT16_HI:
|
|---|
| 3390 | case R_PPC_PLT16_HA:
|
|---|
| 3391 | #ifdef DEBUG
|
|---|
| 3392 | fprintf (stderr, "Reloc requires a PLT entry\n");
|
|---|
| 3393 | #endif
|
|---|
| 3394 | /* This symbol requires a procedure linkage table entry. We
|
|---|
| 3395 | actually build the entry in finish_dynamic_symbol,
|
|---|
| 3396 | because this might be a case of linking PIC code without
|
|---|
| 3397 | linking in any dynamic objects, in which case we don't
|
|---|
| 3398 | need to generate a procedure linkage table after all. */
|
|---|
| 3399 |
|
|---|
| 3400 | if (h == NULL)
|
|---|
| 3401 | {
|
|---|
| 3402 | /* It does not make sense to have a procedure linkage
|
|---|
| 3403 | table entry for a local symbol. */
|
|---|
| 3404 | bfd_set_error (bfd_error_bad_value);
|
|---|
| 3405 | return FALSE;
|
|---|
| 3406 | }
|
|---|
| 3407 |
|
|---|
| 3408 | h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
|
|---|
| 3409 | h->plt.refcount++;
|
|---|
| 3410 | break;
|
|---|
| 3411 |
|
|---|
| 3412 | /* The following relocations don't need to propagate the
|
|---|
| 3413 | relocation if linking a shared object since they are
|
|---|
| 3414 | section relative. */
|
|---|
| 3415 | case R_PPC_SECTOFF:
|
|---|
| 3416 | case R_PPC_SECTOFF_LO:
|
|---|
| 3417 | case R_PPC_SECTOFF_HI:
|
|---|
| 3418 | case R_PPC_SECTOFF_HA:
|
|---|
| 3419 | case R_PPC_DTPREL16:
|
|---|
| 3420 | case R_PPC_DTPREL16_LO:
|
|---|
| 3421 | case R_PPC_DTPREL16_HI:
|
|---|
| 3422 | case R_PPC_DTPREL16_HA:
|
|---|
| 3423 | case R_PPC_TOC16:
|
|---|
| 3424 | break;
|
|---|
| 3425 |
|
|---|
| 3426 | /* This are just markers. */
|
|---|
| 3427 | case R_PPC_TLS:
|
|---|
| 3428 | case R_PPC_EMB_MRKREF:
|
|---|
| 3429 | case R_PPC_NONE:
|
|---|
| 3430 | case R_PPC_max:
|
|---|
| 3431 | break;
|
|---|
| 3432 |
|
|---|
| 3433 | /* These should only appear in dynamic objects. */
|
|---|
| 3434 | case R_PPC_COPY:
|
|---|
| 3435 | case R_PPC_GLOB_DAT:
|
|---|
| 3436 | case R_PPC_JMP_SLOT:
|
|---|
| 3437 | case R_PPC_RELATIVE:
|
|---|
| 3438 | break;
|
|---|
| 3439 |
|
|---|
| 3440 | /* These aren't handled yet. We'll report an error later. */
|
|---|
| 3441 | case R_PPC_ADDR30:
|
|---|
| 3442 | case R_PPC_EMB_RELSEC16:
|
|---|
| 3443 | case R_PPC_EMB_RELST_LO:
|
|---|
| 3444 | case R_PPC_EMB_RELST_HI:
|
|---|
| 3445 | case R_PPC_EMB_RELST_HA:
|
|---|
| 3446 | case R_PPC_EMB_BIT_FLD:
|
|---|
| 3447 | break;
|
|---|
| 3448 |
|
|---|
| 3449 | /* This refers only to functions defined in the shared library. */
|
|---|
| 3450 | case R_PPC_LOCAL24PC:
|
|---|
| 3451 | break;
|
|---|
| 3452 |
|
|---|
| 3453 | /* This relocation describes the C++ object vtable hierarchy.
|
|---|
| 3454 | Reconstruct it for later use during GC. */
|
|---|
| 3455 | case R_PPC_GNU_VTINHERIT:
|
|---|
| 3456 | if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
|
|---|
| 3457 | return FALSE;
|
|---|
| 3458 | break;
|
|---|
| 3459 |
|
|---|
| 3460 | /* This relocation describes which C++ vtable entries are actually
|
|---|
| 3461 | used. Record for later use during GC. */
|
|---|
| 3462 | case R_PPC_GNU_VTENTRY:
|
|---|
| 3463 | if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
|
|---|
| 3464 | return FALSE;
|
|---|
| 3465 | break;
|
|---|
| 3466 |
|
|---|
| 3467 | /* We shouldn't really be seeing these. */
|
|---|
| 3468 | case R_PPC_TPREL32:
|
|---|
| 3469 | if (info->shared)
|
|---|
| 3470 | info->flags |= DF_STATIC_TLS;
|
|---|
| 3471 | goto dodyn;
|
|---|
| 3472 |
|
|---|
| 3473 | /* Nor these. */
|
|---|
| 3474 | case R_PPC_DTPMOD32:
|
|---|
| 3475 | case R_PPC_DTPREL32:
|
|---|
| 3476 | goto dodyn;
|
|---|
| 3477 |
|
|---|
| 3478 | case R_PPC_TPREL16:
|
|---|
| 3479 | case R_PPC_TPREL16_LO:
|
|---|
| 3480 | case R_PPC_TPREL16_HI:
|
|---|
| 3481 | case R_PPC_TPREL16_HA:
|
|---|
| 3482 | if (info->shared)
|
|---|
| 3483 | info->flags |= DF_STATIC_TLS;
|
|---|
| 3484 | goto dodyn;
|
|---|
| 3485 |
|
|---|
| 3486 | /* When creating a shared object, we must copy these
|
|---|
| 3487 | relocs into the output file. We create a reloc
|
|---|
| 3488 | section in dynobj and make room for the reloc. */
|
|---|
| 3489 | case R_PPC_REL24:
|
|---|
| 3490 | case R_PPC_REL14:
|
|---|
| 3491 | case R_PPC_REL14_BRTAKEN:
|
|---|
| 3492 | case R_PPC_REL14_BRNTAKEN:
|
|---|
| 3493 | case R_PPC_REL32:
|
|---|
| 3494 | if (h == NULL
|
|---|
| 3495 | || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
|
|---|
| 3496 | break;
|
|---|
| 3497 | /* fall through */
|
|---|
| 3498 |
|
|---|
| 3499 | case R_PPC_ADDR32:
|
|---|
| 3500 | case R_PPC_ADDR24:
|
|---|
| 3501 | case R_PPC_ADDR16:
|
|---|
| 3502 | case R_PPC_ADDR16_LO:
|
|---|
| 3503 | case R_PPC_ADDR16_HI:
|
|---|
| 3504 | case R_PPC_ADDR16_HA:
|
|---|
| 3505 | case R_PPC_ADDR14:
|
|---|
| 3506 | case R_PPC_ADDR14_BRTAKEN:
|
|---|
| 3507 | case R_PPC_ADDR14_BRNTAKEN:
|
|---|
| 3508 | case R_PPC_UADDR32:
|
|---|
| 3509 | case R_PPC_UADDR16:
|
|---|
| 3510 | if (h != NULL && !info->shared)
|
|---|
| 3511 | {
|
|---|
| 3512 | /* We may need a plt entry if the symbol turns out to be
|
|---|
| 3513 | a function defined in a dynamic object. */
|
|---|
| 3514 | h->plt.refcount++;
|
|---|
| 3515 |
|
|---|
| 3516 | /* We may need a copy reloc too. */
|
|---|
| 3517 | h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
|
|---|
| 3518 | }
|
|---|
| 3519 |
|
|---|
| 3520 | dodyn:
|
|---|
| 3521 | /* If we are creating a shared library, and this is a reloc
|
|---|
| 3522 | against a global symbol, or a non PC relative reloc
|
|---|
| 3523 | against a local symbol, then we need to copy the reloc
|
|---|
| 3524 | into the shared library. However, if we are linking with
|
|---|
| 3525 | -Bsymbolic, we do not need to copy a reloc against a
|
|---|
| 3526 | global symbol which is defined in an object we are
|
|---|
| 3527 | including in the link (i.e., DEF_REGULAR is set). At
|
|---|
| 3528 | this point we have not seen all the input files, so it is
|
|---|
| 3529 | possible that DEF_REGULAR is not set now but will be set
|
|---|
| 3530 | later (it is never cleared). In case of a weak definition,
|
|---|
| 3531 | DEF_REGULAR may be cleared later by a strong definition in
|
|---|
| 3532 | a shared library. We account for that possibility below by
|
|---|
| 3533 | storing information in the dyn_relocs field of the hash
|
|---|
| 3534 | table entry. A similar situation occurs when creating
|
|---|
| 3535 | shared libraries and symbol visibility changes render the
|
|---|
| 3536 | symbol local.
|
|---|
| 3537 |
|
|---|
| 3538 | If on the other hand, we are creating an executable, we
|
|---|
| 3539 | may need to keep relocations for symbols satisfied by a
|
|---|
| 3540 | dynamic library if we manage to avoid copy relocs for the
|
|---|
| 3541 | symbol. */
|
|---|
| 3542 | if ((info->shared
|
|---|
| 3543 | && (MUST_BE_DYN_RELOC (r_type)
|
|---|
| 3544 | || (h != NULL
|
|---|
| 3545 | && (! info->symbolic
|
|---|
| 3546 | || h->root.type == bfd_link_hash_defweak
|
|---|
| 3547 | || (h->elf_link_hash_flags
|
|---|
| 3548 | & ELF_LINK_HASH_DEF_REGULAR) == 0))))
|
|---|
| 3549 | || (ELIMINATE_COPY_RELOCS
|
|---|
| 3550 | && !info->shared
|
|---|
| 3551 | && (sec->flags & SEC_ALLOC) != 0
|
|---|
| 3552 | && h != NULL
|
|---|
| 3553 | && (h->root.type == bfd_link_hash_defweak
|
|---|
| 3554 | || (h->elf_link_hash_flags
|
|---|
| 3555 | & ELF_LINK_HASH_DEF_REGULAR) == 0)))
|
|---|
| 3556 | {
|
|---|
| 3557 | struct ppc_elf_dyn_relocs *p;
|
|---|
| 3558 | struct ppc_elf_dyn_relocs **head;
|
|---|
| 3559 |
|
|---|
| 3560 | #ifdef DEBUG
|
|---|
| 3561 | fprintf (stderr, "ppc_elf_check_relocs need to create relocation for %s\n",
|
|---|
| 3562 | (h && h->root.root.string
|
|---|
| 3563 | ? h->root.root.string : "<unknown>"));
|
|---|
| 3564 | #endif
|
|---|
| 3565 | if (sreloc == NULL)
|
|---|
| 3566 | {
|
|---|
| 3567 | const char *name;
|
|---|
| 3568 |
|
|---|
| 3569 | name = (bfd_elf_string_from_elf_section
|
|---|
| 3570 | (abfd,
|
|---|
| 3571 | elf_elfheader (abfd)->e_shstrndx,
|
|---|
| 3572 | elf_section_data (sec)->rel_hdr.sh_name));
|
|---|
| 3573 | if (name == NULL)
|
|---|
| 3574 | return FALSE;
|
|---|
| 3575 |
|
|---|
| 3576 | BFD_ASSERT (strncmp (name, ".rela", 5) == 0
|
|---|
| 3577 | && strcmp (bfd_get_section_name (abfd, sec),
|
|---|
| 3578 | name + 5) == 0);
|
|---|
| 3579 |
|
|---|
| 3580 | sreloc = bfd_get_section_by_name (htab->elf.dynobj, name);
|
|---|
| 3581 | if (sreloc == NULL)
|
|---|
| 3582 | {
|
|---|
| 3583 | flagword flags;
|
|---|
| 3584 |
|
|---|
| 3585 | sreloc = bfd_make_section (htab->elf.dynobj, name);
|
|---|
| 3586 | flags = (SEC_HAS_CONTENTS | SEC_READONLY
|
|---|
| 3587 | | SEC_IN_MEMORY | SEC_LINKER_CREATED);
|
|---|
| 3588 | if ((sec->flags & SEC_ALLOC) != 0)
|
|---|
| 3589 | flags |= SEC_ALLOC | SEC_LOAD;
|
|---|
| 3590 | if (sreloc == NULL
|
|---|
| 3591 | || ! bfd_set_section_flags (htab->elf.dynobj,
|
|---|
| 3592 | sreloc, flags)
|
|---|
| 3593 | || ! bfd_set_section_alignment (htab->elf.dynobj,
|
|---|
| 3594 | sreloc, 2))
|
|---|
| 3595 | return FALSE;
|
|---|
| 3596 | }
|
|---|
| 3597 | elf_section_data (sec)->sreloc = sreloc;
|
|---|
| 3598 | }
|
|---|
| 3599 |
|
|---|
| 3600 | /* If this is a global symbol, we count the number of
|
|---|
| 3601 | relocations we need for this symbol. */
|
|---|
| 3602 | if (h != NULL)
|
|---|
| 3603 | {
|
|---|
| 3604 | head = &ppc_elf_hash_entry (h)->dyn_relocs;
|
|---|
| 3605 | }
|
|---|
| 3606 | else
|
|---|
| 3607 | {
|
|---|
| 3608 | /* Track dynamic relocs needed for local syms too.
|
|---|
| 3609 | We really need local syms available to do this
|
|---|
| 3610 | easily. Oh well. */
|
|---|
| 3611 |
|
|---|
| 3612 | asection *s;
|
|---|
| 3613 | s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
|
|---|
| 3614 | sec, r_symndx);
|
|---|
| 3615 | if (s == NULL)
|
|---|
| 3616 | return FALSE;
|
|---|
| 3617 |
|
|---|
| 3618 | head = ((struct ppc_elf_dyn_relocs **)
|
|---|
| 3619 | &elf_section_data (s)->local_dynrel);
|
|---|
| 3620 | }
|
|---|
| 3621 |
|
|---|
| 3622 | p = *head;
|
|---|
| 3623 | if (p == NULL || p->sec != sec)
|
|---|
| 3624 | {
|
|---|
| 3625 | p = ((struct ppc_elf_dyn_relocs *)
|
|---|
| 3626 | bfd_alloc (htab->elf.dynobj, sizeof *p));
|
|---|
| 3627 | if (p == NULL)
|
|---|
| 3628 | return FALSE;
|
|---|
| 3629 | p->next = *head;
|
|---|
| 3630 | *head = p;
|
|---|
| 3631 | p->sec = sec;
|
|---|
| 3632 | p->count = 0;
|
|---|
| 3633 | p->pc_count = 0;
|
|---|
| 3634 | }
|
|---|
| 3635 |
|
|---|
| 3636 | p->count += 1;
|
|---|
| 3637 | if (!MUST_BE_DYN_RELOC (r_type))
|
|---|
| 3638 | p->pc_count += 1;
|
|---|
| 3639 | }
|
|---|
| 3640 |
|
|---|
| 3641 | break;
|
|---|
| 3642 | }
|
|---|
| 3643 | }
|
|---|
| 3644 |
|
|---|
| 3645 | return TRUE;
|
|---|
| 3646 | }
|
|---|
| 3647 |
|
|---|
| 3648 | /* Return the section that should be marked against GC for a given
|
|---|
| 3649 | relocation. */
|
|---|
| 3650 |
|
|---|
| 3651 | static asection *
|
|---|
| 3652 | ppc_elf_gc_mark_hook (sec, info, rel, h, sym)
|
|---|
| 3653 | asection *sec;
|
|---|
| 3654 | struct bfd_link_info *info ATTRIBUTE_UNUSED;
|
|---|
| 3655 | Elf_Internal_Rela *rel;
|
|---|
| 3656 | struct elf_link_hash_entry *h;
|
|---|
| 3657 | Elf_Internal_Sym *sym;
|
|---|
| 3658 | {
|
|---|
| 3659 | if (h != NULL)
|
|---|
| 3660 | {
|
|---|
| 3661 | switch (ELF32_R_TYPE (rel->r_info))
|
|---|
| 3662 | {
|
|---|
| 3663 | case R_PPC_GNU_VTINHERIT:
|
|---|
| 3664 | case R_PPC_GNU_VTENTRY:
|
|---|
| 3665 | break;
|
|---|
| 3666 |
|
|---|
| 3667 | default:
|
|---|
| 3668 | switch (h->root.type)
|
|---|
| 3669 | {
|
|---|
| 3670 | case bfd_link_hash_defined:
|
|---|
| 3671 | case bfd_link_hash_defweak:
|
|---|
| 3672 | return h->root.u.def.section;
|
|---|
| 3673 |
|
|---|
| 3674 | case bfd_link_hash_common:
|
|---|
| 3675 | return h->root.u.c.p->section;
|
|---|
| 3676 |
|
|---|
| 3677 | default:
|
|---|
| 3678 | break;
|
|---|
| 3679 | }
|
|---|
| 3680 | }
|
|---|
| 3681 | }
|
|---|
| 3682 | else
|
|---|
| 3683 | return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
|
|---|
| 3684 |
|
|---|
| 3685 | return NULL;
|
|---|
| 3686 | }
|
|---|
| 3687 |
|
|---|
| 3688 | /* Update the got, plt and dynamic reloc reference counts for the
|
|---|
| 3689 | section being removed. */
|
|---|
| 3690 |
|
|---|
| 3691 | static bfd_boolean
|
|---|
| 3692 | ppc_elf_gc_sweep_hook (abfd, info, sec, relocs)
|
|---|
| 3693 | bfd *abfd;
|
|---|
| 3694 | struct bfd_link_info *info;
|
|---|
| 3695 | asection *sec;
|
|---|
| 3696 | const Elf_Internal_Rela *relocs;
|
|---|
| 3697 | {
|
|---|
| 3698 | struct ppc_elf_link_hash_table *htab;
|
|---|
| 3699 | Elf_Internal_Shdr *symtab_hdr;
|
|---|
| 3700 | struct elf_link_hash_entry **sym_hashes;
|
|---|
| 3701 | bfd_signed_vma *local_got_refcounts;
|
|---|
| 3702 | const Elf_Internal_Rela *rel, *relend;
|
|---|
| 3703 |
|
|---|
| 3704 | elf_section_data (sec)->local_dynrel = NULL;
|
|---|
| 3705 |
|
|---|
| 3706 | htab = ppc_elf_hash_table (info);
|
|---|
| 3707 | symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
|
|---|
| 3708 | sym_hashes = elf_sym_hashes (abfd);
|
|---|
| 3709 | local_got_refcounts = elf_local_got_refcounts (abfd);
|
|---|
| 3710 |
|
|---|
| 3711 | relend = relocs + sec->reloc_count;
|
|---|
| 3712 | for (rel = relocs; rel < relend; rel++)
|
|---|
| 3713 | {
|
|---|
| 3714 | unsigned long r_symndx;
|
|---|
| 3715 | enum elf_ppc_reloc_type r_type;
|
|---|
| 3716 | struct elf_link_hash_entry *h = NULL;
|
|---|
| 3717 |
|
|---|
| 3718 | r_symndx = ELF32_R_SYM (rel->r_info);
|
|---|
| 3719 | if (r_symndx >= symtab_hdr->sh_info)
|
|---|
| 3720 | {
|
|---|
| 3721 | struct ppc_elf_dyn_relocs **pp, *p;
|
|---|
| 3722 | struct ppc_elf_link_hash_entry *eh;
|
|---|
| 3723 |
|
|---|
| 3724 | h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
|---|
| 3725 | eh = (struct ppc_elf_link_hash_entry *) h;
|
|---|
| 3726 |
|
|---|
| 3727 | for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
|
|---|
| 3728 | if (p->sec == sec)
|
|---|
| 3729 | {
|
|---|
| 3730 | /* Everything must go for SEC. */
|
|---|
| 3731 | *pp = p->next;
|
|---|
| 3732 | break;
|
|---|
| 3733 | }
|
|---|
| 3734 | }
|
|---|
| 3735 |
|
|---|
| 3736 | r_type = (enum elf_ppc_reloc_type) ELF32_R_TYPE (rel->r_info);
|
|---|
| 3737 | switch (r_type)
|
|---|
| 3738 | {
|
|---|
| 3739 | case R_PPC_GOT_TLSLD16:
|
|---|
| 3740 | case R_PPC_GOT_TLSLD16_LO:
|
|---|
| 3741 | case R_PPC_GOT_TLSLD16_HI:
|
|---|
| 3742 | case R_PPC_GOT_TLSLD16_HA:
|
|---|
| 3743 | htab->tlsld_got.refcount -= 1;
|
|---|
| 3744 | /* Fall thru */
|
|---|
| 3745 |
|
|---|
| 3746 | case R_PPC_GOT_TLSGD16:
|
|---|
| 3747 | case R_PPC_GOT_TLSGD16_LO:
|
|---|
| 3748 | case R_PPC_GOT_TLSGD16_HI:
|
|---|
| 3749 | case R_PPC_GOT_TLSGD16_HA:
|
|---|
| 3750 | case R_PPC_GOT_TPREL16:
|
|---|
| 3751 | case R_PPC_GOT_TPREL16_LO:
|
|---|
| 3752 | case R_PPC_GOT_TPREL16_HI:
|
|---|
| 3753 | case R_PPC_GOT_TPREL16_HA:
|
|---|
| 3754 | case R_PPC_GOT_DTPREL16:
|
|---|
| 3755 | case R_PPC_GOT_DTPREL16_LO:
|
|---|
| 3756 | case R_PPC_GOT_DTPREL16_HI:
|
|---|
| 3757 | case R_PPC_GOT_DTPREL16_HA:
|
|---|
| 3758 | case R_PPC_GOT16:
|
|---|
| 3759 | case R_PPC_GOT16_LO:
|
|---|
| 3760 | case R_PPC_GOT16_HI:
|
|---|
| 3761 | case R_PPC_GOT16_HA:
|
|---|
| 3762 | if (h != NULL)
|
|---|
| 3763 | {
|
|---|
| 3764 | if (h->got.refcount > 0)
|
|---|
| 3765 | h->got.refcount--;
|
|---|
| 3766 | }
|
|---|
| 3767 | else if (local_got_refcounts != NULL)
|
|---|
| 3768 | {
|
|---|
| 3769 | if (local_got_refcounts[r_symndx] > 0)
|
|---|
| 3770 | local_got_refcounts[r_symndx]--;
|
|---|
| 3771 | }
|
|---|
| 3772 | break;
|
|---|
| 3773 |
|
|---|
| 3774 | case R_PPC_REL24:
|
|---|
| 3775 | case R_PPC_REL14:
|
|---|
| 3776 | case R_PPC_REL14_BRTAKEN:
|
|---|
| 3777 | case R_PPC_REL14_BRNTAKEN:
|
|---|
| 3778 | case R_PPC_REL32:
|
|---|
| 3779 | if (h == NULL
|
|---|
| 3780 | || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
|
|---|
| 3781 | break;
|
|---|
| 3782 | /* Fall thru */
|
|---|
| 3783 |
|
|---|
| 3784 | case R_PPC_ADDR32:
|
|---|
| 3785 | case R_PPC_ADDR24:
|
|---|
| 3786 | case R_PPC_ADDR16:
|
|---|
| 3787 | case R_PPC_ADDR16_LO:
|
|---|
| 3788 | case R_PPC_ADDR16_HI:
|
|---|
| 3789 | case R_PPC_ADDR16_HA:
|
|---|
| 3790 | case R_PPC_ADDR14:
|
|---|
| 3791 | case R_PPC_ADDR14_BRTAKEN:
|
|---|
| 3792 | case R_PPC_ADDR14_BRNTAKEN:
|
|---|
| 3793 | case R_PPC_UADDR32:
|
|---|
| 3794 | case R_PPC_UADDR16:
|
|---|
| 3795 | case R_PPC_PLT32:
|
|---|
| 3796 | case R_PPC_PLTREL24:
|
|---|
| 3797 | case R_PPC_PLT16_LO:
|
|---|
| 3798 | case R_PPC_PLT16_HI:
|
|---|
| 3799 | case R_PPC_PLT16_HA:
|
|---|
| 3800 | if (h != NULL)
|
|---|
| 3801 | {
|
|---|
| 3802 | if (h->plt.refcount > 0)
|
|---|
| 3803 | h->plt.refcount--;
|
|---|
| 3804 | }
|
|---|
| 3805 | break;
|
|---|
| 3806 |
|
|---|
| 3807 | default:
|
|---|
| 3808 | break;
|
|---|
| 3809 | }
|
|---|
| 3810 | }
|
|---|
| 3811 | return TRUE;
|
|---|
| 3812 | }
|
|---|
| 3813 |
|
|---|
| 3814 | /* Set htab->tls_sec and htab->tls_get_addr. */
|
|---|
| 3815 |
|
|---|
| 3816 | bfd_boolean
|
|---|
| 3817 | ppc_elf_tls_setup (obfd, info)
|
|---|
| 3818 | bfd *obfd;
|
|---|
| 3819 | struct bfd_link_info *info;
|
|---|
| 3820 | {
|
|---|
| 3821 | asection *tls;
|
|---|
| 3822 | struct ppc_elf_link_hash_table *htab;
|
|---|
| 3823 |
|
|---|
| 3824 | htab = ppc_elf_hash_table (info);
|
|---|
| 3825 | htab->tls_get_addr = elf_link_hash_lookup (&htab->elf, "__tls_get_addr",
|
|---|
| 3826 | FALSE, FALSE, TRUE);
|
|---|
| 3827 |
|
|---|
| 3828 | for (tls = obfd->sections; tls != NULL; tls = tls->next)
|
|---|
| 3829 | if ((tls->flags & (SEC_THREAD_LOCAL | SEC_LOAD))
|
|---|
| 3830 | == (SEC_THREAD_LOCAL | SEC_LOAD))
|
|---|
| 3831 | break;
|
|---|
| 3832 | htab->tls_sec = tls;
|
|---|
| 3833 |
|
|---|
| 3834 | return tls != NULL;
|
|---|
| 3835 | }
|
|---|
| 3836 |
|
|---|
| 3837 | /* Run through all the TLS relocs looking for optimization
|
|---|
| 3838 | opportunities. */
|
|---|
| 3839 |
|
|---|
| 3840 | bfd_boolean
|
|---|
| 3841 | ppc_elf_tls_optimize (obfd, info)
|
|---|
| 3842 | bfd *obfd ATTRIBUTE_UNUSED;
|
|---|
| 3843 | struct bfd_link_info *info;
|
|---|
| 3844 | {
|
|---|
| 3845 | bfd *ibfd;
|
|---|
| 3846 | asection *sec;
|
|---|
| 3847 | struct ppc_elf_link_hash_table *htab;
|
|---|
| 3848 |
|
|---|
| 3849 | if (info->relocateable || info->shared)
|
|---|
| 3850 | return TRUE;
|
|---|
| 3851 |
|
|---|
| 3852 | htab = ppc_elf_hash_table (info);
|
|---|
| 3853 | for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
|
|---|
| 3854 | {
|
|---|
| 3855 | Elf_Internal_Sym *locsyms = NULL;
|
|---|
| 3856 | Elf_Internal_Shdr *symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
|
|---|
| 3857 |
|
|---|
| 3858 | for (sec = ibfd->sections; sec != NULL; sec = sec->next)
|
|---|
| 3859 | if (sec->has_tls_reloc && !bfd_is_abs_section (sec->output_section))
|
|---|
| 3860 | {
|
|---|
| 3861 | Elf_Internal_Rela *relstart, *rel, *relend;
|
|---|
| 3862 | int expecting_tls_get_addr;
|
|---|
| 3863 |
|
|---|
| 3864 | /* Read the relocations. */
|
|---|
| 3865 | relstart = _bfd_elf32_link_read_relocs (ibfd, sec, (PTR) NULL,
|
|---|
| 3866 | (Elf_Internal_Rela *) NULL,
|
|---|
| 3867 | info->keep_memory);
|
|---|
| 3868 | if (relstart == NULL)
|
|---|
| 3869 | return FALSE;
|
|---|
| 3870 |
|
|---|
| 3871 | expecting_tls_get_addr = 0;
|
|---|
| 3872 | relend = relstart + sec->reloc_count;
|
|---|
| 3873 | for (rel = relstart; rel < relend; rel++)
|
|---|
| 3874 | {
|
|---|
| 3875 | enum elf_ppc_reloc_type r_type;
|
|---|
| 3876 | unsigned long r_symndx;
|
|---|
| 3877 | struct elf_link_hash_entry *h = NULL;
|
|---|
| 3878 | char *tls_mask;
|
|---|
| 3879 | char tls_set, tls_clear;
|
|---|
| 3880 | bfd_boolean is_local;
|
|---|
| 3881 |
|
|---|
| 3882 | r_symndx = ELF32_R_SYM (rel->r_info);
|
|---|
| 3883 | if (r_symndx >= symtab_hdr->sh_info)
|
|---|
| 3884 | {
|
|---|
| 3885 | struct elf_link_hash_entry **sym_hashes;
|
|---|
| 3886 |
|
|---|
| 3887 | sym_hashes = elf_sym_hashes (ibfd);
|
|---|
| 3888 | h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
|---|
| 3889 | while (h->root.type == bfd_link_hash_indirect
|
|---|
| 3890 | || h->root.type == bfd_link_hash_warning)
|
|---|
| 3891 | h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|---|
| 3892 | }
|
|---|
| 3893 |
|
|---|
| 3894 | is_local = FALSE;
|
|---|
| 3895 | if (h == NULL
|
|---|
| 3896 | || !(h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC))
|
|---|
| 3897 | is_local = TRUE;
|
|---|
| 3898 |
|
|---|
| 3899 | r_type = (enum elf_ppc_reloc_type) ELF32_R_TYPE (rel->r_info);
|
|---|
| 3900 | switch (r_type)
|
|---|
| 3901 | {
|
|---|
| 3902 | case R_PPC_GOT_TLSLD16:
|
|---|
| 3903 | case R_PPC_GOT_TLSLD16_LO:
|
|---|
| 3904 | case R_PPC_GOT_TLSLD16_HI:
|
|---|
| 3905 | case R_PPC_GOT_TLSLD16_HA:
|
|---|
| 3906 | /* These relocs should never be against a symbol
|
|---|
| 3907 | defined in a shared lib. Leave them alone if
|
|---|
| 3908 | that turns out to be the case. */
|
|---|
| 3909 | expecting_tls_get_addr = 0;
|
|---|
| 3910 | htab->tlsld_got.refcount -= 1;
|
|---|
| 3911 | if (!is_local)
|
|---|
| 3912 | continue;
|
|---|
| 3913 |
|
|---|
| 3914 | /* LD -> LE */
|
|---|
| 3915 | tls_set = 0;
|
|---|
| 3916 | tls_clear = TLS_LD;
|
|---|
| 3917 | expecting_tls_get_addr = 1;
|
|---|
| 3918 | break;
|
|---|
| 3919 |
|
|---|
| 3920 | case R_PPC_GOT_TLSGD16:
|
|---|
| 3921 | case R_PPC_GOT_TLSGD16_LO:
|
|---|
| 3922 | case R_PPC_GOT_TLSGD16_HI:
|
|---|
| 3923 | case R_PPC_GOT_TLSGD16_HA:
|
|---|
| 3924 | if (is_local)
|
|---|
| 3925 | /* GD -> LE */
|
|---|
| 3926 | tls_set = 0;
|
|---|
| 3927 | else
|
|---|
| 3928 | /* GD -> IE */
|
|---|
| 3929 | tls_set = TLS_TLS | TLS_TPRELGD;
|
|---|
| 3930 | tls_clear = TLS_GD;
|
|---|
| 3931 | expecting_tls_get_addr = 1;
|
|---|
| 3932 | break;
|
|---|
| 3933 |
|
|---|
| 3934 | case R_PPC_GOT_TPREL16:
|
|---|
| 3935 | case R_PPC_GOT_TPREL16_LO:
|
|---|
| 3936 | case R_PPC_GOT_TPREL16_HI:
|
|---|
| 3937 | case R_PPC_GOT_TPREL16_HA:
|
|---|
| 3938 | expecting_tls_get_addr = 0;
|
|---|
| 3939 | if (is_local)
|
|---|
| 3940 | {
|
|---|
| 3941 | /* IE -> LE */
|
|---|
| 3942 | tls_set = 0;
|
|---|
| 3943 | tls_clear = TLS_TPREL;
|
|---|
| 3944 | break;
|
|---|
| 3945 | }
|
|---|
| 3946 | else
|
|---|
| 3947 | continue;
|
|---|
| 3948 |
|
|---|
| 3949 | case R_PPC_REL14:
|
|---|
| 3950 | case R_PPC_REL14_BRTAKEN:
|
|---|
| 3951 | case R_PPC_REL14_BRNTAKEN:
|
|---|
| 3952 | case R_PPC_REL24:
|
|---|
| 3953 | if (expecting_tls_get_addr
|
|---|
| 3954 | && h != NULL
|
|---|
| 3955 | && h == htab->tls_get_addr)
|
|---|
| 3956 | {
|
|---|
| 3957 | if (h->plt.refcount > 0)
|
|---|
| 3958 | h->plt.refcount -= 1;
|
|---|
| 3959 | }
|
|---|
| 3960 | expecting_tls_get_addr = 0;
|
|---|
| 3961 | continue;
|
|---|
| 3962 |
|
|---|
| 3963 | default:
|
|---|
| 3964 | expecting_tls_get_addr = 0;
|
|---|
| 3965 | continue;
|
|---|
| 3966 | }
|
|---|
| 3967 |
|
|---|
| 3968 | if (h != NULL)
|
|---|
| 3969 | {
|
|---|
| 3970 | if (tls_set == 0)
|
|---|
| 3971 | {
|
|---|
| 3972 | /* We managed to get rid of a got entry. */
|
|---|
| 3973 | if (h->got.refcount > 0)
|
|---|
| 3974 | h->got.refcount -= 1;
|
|---|
| 3975 | }
|
|---|
| 3976 | tls_mask = &ppc_elf_hash_entry (h)->tls_mask;
|
|---|
| 3977 | }
|
|---|
| 3978 | else
|
|---|
| 3979 | {
|
|---|
| 3980 | Elf_Internal_Sym *sym;
|
|---|
| 3981 | bfd_signed_vma *lgot_refs;
|
|---|
| 3982 | char *lgot_masks;
|
|---|
| 3983 |
|
|---|
| 3984 | if (locsyms == NULL)
|
|---|
| 3985 | {
|
|---|
| 3986 | locsyms = (Elf_Internal_Sym *) symtab_hdr->contents;
|
|---|
| 3987 | if (locsyms == NULL)
|
|---|
| 3988 | locsyms = bfd_elf_get_elf_syms (ibfd, symtab_hdr,
|
|---|
| 3989 | symtab_hdr->sh_info,
|
|---|
| 3990 | 0, NULL, NULL, NULL);
|
|---|
| 3991 | if (locsyms == NULL)
|
|---|
| 3992 | {
|
|---|
| 3993 | if (elf_section_data (sec)->relocs != relstart)
|
|---|
| 3994 | free (relstart);
|
|---|
| 3995 | return FALSE;
|
|---|
| 3996 | }
|
|---|
| 3997 | }
|
|---|
| 3998 | sym = locsyms + r_symndx;
|
|---|
| 3999 | lgot_refs = elf_local_got_refcounts (ibfd);
|
|---|
| 4000 | if (lgot_refs == NULL)
|
|---|
| 4001 | abort ();
|
|---|
| 4002 | if (tls_set == 0)
|
|---|
| 4003 | {
|
|---|
| 4004 | /* We managed to get rid of a got entry. */
|
|---|
| 4005 | if (lgot_refs[r_symndx] > 0)
|
|---|
| 4006 | lgot_refs[r_symndx] -= 1;
|
|---|
| 4007 | }
|
|---|
| 4008 | lgot_masks = (char *) (lgot_refs + symtab_hdr->sh_info);
|
|---|
| 4009 | tls_mask = &lgot_masks[r_symndx];
|
|---|
| 4010 | }
|
|---|
| 4011 |
|
|---|
| 4012 | *tls_mask |= tls_set;
|
|---|
| 4013 | *tls_mask &= ~tls_clear;
|
|---|
| 4014 | }
|
|---|
| 4015 |
|
|---|
| 4016 | if (elf_section_data (sec)->relocs != relstart)
|
|---|
| 4017 | free (relstart);
|
|---|
| 4018 | }
|
|---|
| 4019 |
|
|---|
| 4020 | if (locsyms != NULL
|
|---|
| 4021 | && (symtab_hdr->contents != (unsigned char *) locsyms))
|
|---|
| 4022 | {
|
|---|
| 4023 | if (!info->keep_memory)
|
|---|
| 4024 | free (locsyms);
|
|---|
| 4025 | else
|
|---|
| 4026 | symtab_hdr->contents = (unsigned char *) locsyms;
|
|---|
| 4027 | }
|
|---|
| 4028 | }
|
|---|
| 4029 | return TRUE;
|
|---|
| 4030 | }
|
|---|
| 4031 | |
|---|
| 4032 |
|
|---|
| 4033 | /* Hook called by the linker routine which adds symbols from an object
|
|---|
| 4034 | file. We use it to put .comm items in .sbss, and not .bss. */
|
|---|
| 4035 |
|
|---|
| 4036 | static bfd_boolean
|
|---|
| 4037 | ppc_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
|
|---|
| 4038 | bfd *abfd;
|
|---|
| 4039 | struct bfd_link_info *info;
|
|---|
| 4040 | const Elf_Internal_Sym *sym;
|
|---|
| 4041 | const char **namep ATTRIBUTE_UNUSED;
|
|---|
| 4042 | flagword *flagsp ATTRIBUTE_UNUSED;
|
|---|
| 4043 | asection **secp;
|
|---|
| 4044 | bfd_vma *valp;
|
|---|
| 4045 | {
|
|---|
| 4046 | if (sym->st_shndx == SHN_COMMON
|
|---|
| 4047 | && !info->relocateable
|
|---|
| 4048 | && sym->st_size <= elf_gp_size (abfd)
|
|---|
| 4049 | && info->hash->creator->flavour == bfd_target_elf_flavour)
|
|---|
| 4050 | {
|
|---|
| 4051 | /* Common symbols less than or equal to -G nn bytes are automatically
|
|---|
| 4052 | put into .sdata. */
|
|---|
| 4053 | elf_linker_section_t *sdata
|
|---|
| 4054 | = ppc_elf_create_linker_section (abfd, info, LINKER_SECTION_SDATA);
|
|---|
| 4055 |
|
|---|
| 4056 | if (!sdata->bss_section)
|
|---|
| 4057 | {
|
|---|
| 4058 | bfd_size_type amt;
|
|---|
| 4059 |
|
|---|
| 4060 | /* We don't go through bfd_make_section, because we don't
|
|---|
| 4061 | want to attach this common section to DYNOBJ. The linker
|
|---|
| 4062 | will move the symbols to the appropriate output section
|
|---|
| 4063 | when it defines common symbols. */
|
|---|
| 4064 | amt = sizeof (asection);
|
|---|
| 4065 | sdata->bss_section = (asection *) bfd_zalloc (abfd, amt);
|
|---|
| 4066 | if (sdata->bss_section == NULL)
|
|---|
| 4067 | return FALSE;
|
|---|
| 4068 | sdata->bss_section->name = sdata->bss_name;
|
|---|
| 4069 | sdata->bss_section->flags = SEC_IS_COMMON;
|
|---|
| 4070 | sdata->bss_section->output_section = sdata->bss_section;
|
|---|
| 4071 | amt = sizeof (asymbol);
|
|---|
| 4072 | sdata->bss_section->symbol = (asymbol *) bfd_zalloc (abfd, amt);
|
|---|
| 4073 | amt = sizeof (asymbol *);
|
|---|
| 4074 | sdata->bss_section->symbol_ptr_ptr =
|
|---|
| 4075 | (asymbol **) bfd_zalloc (abfd, amt);
|
|---|
| 4076 | if (sdata->bss_section->symbol == NULL
|
|---|
| 4077 | || sdata->bss_section->symbol_ptr_ptr == NULL)
|
|---|
| 4078 | return FALSE;
|
|---|
| 4079 | sdata->bss_section->symbol->name = sdata->bss_name;
|
|---|
| 4080 | sdata->bss_section->symbol->flags = BSF_SECTION_SYM;
|
|---|
| 4081 | sdata->bss_section->symbol->section = sdata->bss_section;
|
|---|
| 4082 | *sdata->bss_section->symbol_ptr_ptr = sdata->bss_section->symbol;
|
|---|
| 4083 | }
|
|---|
| 4084 |
|
|---|
| 4085 | *secp = sdata->bss_section;
|
|---|
| 4086 | *valp = sym->st_size;
|
|---|
| 4087 | }
|
|---|
| 4088 |
|
|---|
| 4089 | return TRUE;
|
|---|
| 4090 | }
|
|---|
| 4091 | |
|---|
| 4092 |
|
|---|
| 4093 | /* Finish up dynamic symbol handling. We set the contents of various
|
|---|
| 4094 | dynamic sections here. */
|
|---|
| 4095 |
|
|---|
| 4096 | static bfd_boolean
|
|---|
| 4097 | ppc_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
|
|---|
| 4098 | bfd *output_bfd;
|
|---|
| 4099 | struct bfd_link_info *info;
|
|---|
| 4100 | struct elf_link_hash_entry *h;
|
|---|
| 4101 | Elf_Internal_Sym *sym;
|
|---|
| 4102 | {
|
|---|
| 4103 | struct ppc_elf_link_hash_table *htab;
|
|---|
| 4104 |
|
|---|
| 4105 | #ifdef DEBUG
|
|---|
| 4106 | fprintf (stderr, "ppc_elf_finish_dynamic_symbol called for %s",
|
|---|
| 4107 | h->root.root.string);
|
|---|
| 4108 | #endif
|
|---|
| 4109 |
|
|---|
| 4110 | htab = ppc_elf_hash_table (info);
|
|---|
| 4111 | BFD_ASSERT (htab->elf.dynobj != NULL);
|
|---|
| 4112 |
|
|---|
| 4113 | if (h->plt.offset != (bfd_vma) -1)
|
|---|
| 4114 | {
|
|---|
| 4115 | Elf_Internal_Rela rela;
|
|---|
| 4116 | bfd_byte *loc;
|
|---|
| 4117 | bfd_vma reloc_index;
|
|---|
| 4118 |
|
|---|
| 4119 | #ifdef DEBUG
|
|---|
| 4120 | fprintf (stderr, ", plt_offset = %d", h->plt.offset);
|
|---|
| 4121 | #endif
|
|---|
| 4122 |
|
|---|
| 4123 | /* This symbol has an entry in the procedure linkage table. Set
|
|---|
| 4124 | it up. */
|
|---|
| 4125 |
|
|---|
| 4126 | BFD_ASSERT (h->dynindx != -1);
|
|---|
| 4127 | BFD_ASSERT (htab->plt != NULL && htab->relplt != NULL);
|
|---|
| 4128 |
|
|---|
| 4129 | /* We don't need to fill in the .plt. The ppc dynamic linker
|
|---|
| 4130 | will fill it in. */
|
|---|
| 4131 |
|
|---|
| 4132 | /* Fill in the entry in the .rela.plt section. */
|
|---|
| 4133 | rela.r_offset = (htab->plt->output_section->vma
|
|---|
| 4134 | + htab->plt->output_offset
|
|---|
| 4135 | + h->plt.offset);
|
|---|
| 4136 | rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_JMP_SLOT);
|
|---|
| 4137 | rela.r_addend = 0;
|
|---|
| 4138 |
|
|---|
| 4139 | reloc_index = (h->plt.offset - PLT_INITIAL_ENTRY_SIZE) / PLT_SLOT_SIZE;
|
|---|
| 4140 | if (reloc_index > PLT_NUM_SINGLE_ENTRIES)
|
|---|
| 4141 | reloc_index -= (reloc_index - PLT_NUM_SINGLE_ENTRIES) / 2;
|
|---|
| 4142 | loc = (htab->relplt->contents
|
|---|
| 4143 | + reloc_index * sizeof (Elf32_External_Rela));
|
|---|
| 4144 | bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
|
|---|
| 4145 |
|
|---|
| 4146 | if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
|
|---|
| 4147 | {
|
|---|
| 4148 | /* Mark the symbol as undefined, rather than as defined in
|
|---|
| 4149 | the .plt section. Leave the value alone. */
|
|---|
| 4150 | sym->st_shndx = SHN_UNDEF;
|
|---|
| 4151 | /* If the symbol is weak, we do need to clear the value.
|
|---|
| 4152 | Otherwise, the PLT entry would provide a definition for
|
|---|
| 4153 | the symbol even if the symbol wasn't defined anywhere,
|
|---|
| 4154 | and so the symbol would never be NULL. */
|
|---|
| 4155 | if ((h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR_NONWEAK)
|
|---|
| 4156 | == 0)
|
|---|
| 4157 | sym->st_value = 0;
|
|---|
| 4158 | }
|
|---|
| 4159 | }
|
|---|
| 4160 |
|
|---|
| 4161 | if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
|
|---|
| 4162 | {
|
|---|
| 4163 | asection *s;
|
|---|
| 4164 | Elf_Internal_Rela rela;
|
|---|
| 4165 | bfd_byte *loc;
|
|---|
| 4166 |
|
|---|
| 4167 | /* This symbols needs a copy reloc. Set it up. */
|
|---|
| 4168 |
|
|---|
| 4169 | #ifdef DEBUG
|
|---|
| 4170 | fprintf (stderr, ", copy");
|
|---|
| 4171 | #endif
|
|---|
| 4172 |
|
|---|
| 4173 | BFD_ASSERT (h->dynindx != -1);
|
|---|
| 4174 |
|
|---|
| 4175 | if (h->size <= elf_gp_size (htab->elf.dynobj))
|
|---|
| 4176 | s = htab->relsbss;
|
|---|
| 4177 | else
|
|---|
| 4178 | s = htab->relbss;
|
|---|
| 4179 | BFD_ASSERT (s != NULL);
|
|---|
| 4180 |
|
|---|
| 4181 | rela.r_offset = (h->root.u.def.value
|
|---|
| 4182 | + h->root.u.def.section->output_section->vma
|
|---|
| 4183 | + h->root.u.def.section->output_offset);
|
|---|
| 4184 | rela.r_info = ELF32_R_INFO (h->dynindx, R_PPC_COPY);
|
|---|
| 4185 | rela.r_addend = 0;
|
|---|
| 4186 | loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela);
|
|---|
| 4187 | bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
|
|---|
| 4188 | }
|
|---|
| 4189 |
|
|---|
| 4190 | #ifdef DEBUG
|
|---|
| 4191 | fprintf (stderr, "\n");
|
|---|
| 4192 | #endif
|
|---|
| 4193 |
|
|---|
| 4194 | /* Mark some specially defined symbols as absolute. */
|
|---|
| 4195 | if (strcmp (h->root.root.string, "_DYNAMIC") == 0
|
|---|
| 4196 | || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0
|
|---|
| 4197 | || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0)
|
|---|
| 4198 | sym->st_shndx = SHN_ABS;
|
|---|
| 4199 |
|
|---|
| 4200 | return TRUE;
|
|---|
| 4201 | }
|
|---|
| 4202 | |
|---|
| 4203 |
|
|---|
| 4204 | /* Finish up the dynamic sections. */
|
|---|
| 4205 |
|
|---|
| 4206 | static bfd_boolean
|
|---|
| 4207 | ppc_elf_finish_dynamic_sections (output_bfd, info)
|
|---|
| 4208 | bfd *output_bfd;
|
|---|
| 4209 | struct bfd_link_info *info;
|
|---|
| 4210 | {
|
|---|
| 4211 | asection *sdyn;
|
|---|
| 4212 | struct ppc_elf_link_hash_table *htab;
|
|---|
| 4213 |
|
|---|
| 4214 | #ifdef DEBUG
|
|---|
| 4215 | fprintf (stderr, "ppc_elf_finish_dynamic_sections called\n");
|
|---|
| 4216 | #endif
|
|---|
| 4217 |
|
|---|
| 4218 | htab = ppc_elf_hash_table (info);
|
|---|
| 4219 | sdyn = bfd_get_section_by_name (htab->elf.dynobj, ".dynamic");
|
|---|
| 4220 |
|
|---|
| 4221 | if (htab->elf.dynamic_sections_created)
|
|---|
| 4222 | {
|
|---|
| 4223 | Elf32_External_Dyn *dyncon, *dynconend;
|
|---|
| 4224 |
|
|---|
| 4225 | BFD_ASSERT (htab->plt != NULL && sdyn != NULL);
|
|---|
| 4226 |
|
|---|
| 4227 | dyncon = (Elf32_External_Dyn *) sdyn->contents;
|
|---|
| 4228 | dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
|
|---|
| 4229 | for (; dyncon < dynconend; dyncon++)
|
|---|
| 4230 | {
|
|---|
| 4231 | Elf_Internal_Dyn dyn;
|
|---|
| 4232 | asection *s;
|
|---|
| 4233 |
|
|---|
| 4234 | bfd_elf32_swap_dyn_in (htab->elf.dynobj, dyncon, &dyn);
|
|---|
| 4235 |
|
|---|
| 4236 | switch (dyn.d_tag)
|
|---|
| 4237 | {
|
|---|
| 4238 | case DT_PLTGOT:
|
|---|
| 4239 | s = htab->plt;
|
|---|
| 4240 | dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
|
|---|
| 4241 | break;
|
|---|
| 4242 |
|
|---|
| 4243 | case DT_PLTRELSZ:
|
|---|
| 4244 | dyn.d_un.d_val = htab->relplt->_raw_size;
|
|---|
| 4245 | break;
|
|---|
| 4246 |
|
|---|
| 4247 | case DT_JMPREL:
|
|---|
| 4248 | s = htab->relplt;
|
|---|
| 4249 | dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
|
|---|
| 4250 | break;
|
|---|
| 4251 |
|
|---|
| 4252 | default:
|
|---|
| 4253 | continue;
|
|---|
| 4254 | }
|
|---|
| 4255 |
|
|---|
| 4256 | bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
|
|---|
| 4257 | }
|
|---|
| 4258 | }
|
|---|
| 4259 |
|
|---|
| 4260 | /* Add a blrl instruction at _GLOBAL_OFFSET_TABLE_-4 so that a function can
|
|---|
| 4261 | easily find the address of the _GLOBAL_OFFSET_TABLE_. */
|
|---|
| 4262 | if (htab->got)
|
|---|
| 4263 | {
|
|---|
| 4264 | unsigned char *contents = htab->got->contents;
|
|---|
| 4265 | bfd_put_32 (output_bfd, (bfd_vma) 0x4e800021 /* blrl */, contents);
|
|---|
| 4266 |
|
|---|
| 4267 | if (sdyn == NULL)
|
|---|
| 4268 | bfd_put_32 (output_bfd, (bfd_vma) 0, contents + 4);
|
|---|
| 4269 | else
|
|---|
| 4270 | bfd_put_32 (output_bfd,
|
|---|
| 4271 | sdyn->output_section->vma + sdyn->output_offset,
|
|---|
| 4272 | contents + 4);
|
|---|
| 4273 |
|
|---|
| 4274 | elf_section_data (htab->got->output_section)->this_hdr.sh_entsize = 4;
|
|---|
| 4275 | }
|
|---|
| 4276 |
|
|---|
| 4277 | return TRUE;
|
|---|
| 4278 | }
|
|---|
| 4279 | |
|---|
| 4280 |
|
|---|
| 4281 | /* The RELOCATE_SECTION function is called by the ELF backend linker
|
|---|
| 4282 | to handle the relocations for a section.
|
|---|
| 4283 |
|
|---|
| 4284 | The relocs are always passed as Rela structures; if the section
|
|---|
| 4285 | actually uses Rel structures, the r_addend field will always be
|
|---|
| 4286 | zero.
|
|---|
| 4287 |
|
|---|
| 4288 | This function is responsible for adjust the section contents as
|
|---|
| 4289 | necessary, and (if using Rela relocs and generating a
|
|---|
| 4290 | relocateable output file) adjusting the reloc addend as
|
|---|
| 4291 | necessary.
|
|---|
| 4292 |
|
|---|
| 4293 | This function does not have to worry about setting the reloc
|
|---|
| 4294 | address or the reloc symbol index.
|
|---|
| 4295 |
|
|---|
| 4296 | LOCAL_SYMS is a pointer to the swapped in local symbols.
|
|---|
| 4297 |
|
|---|
| 4298 | LOCAL_SECTIONS is an array giving the section in the input file
|
|---|
| 4299 | corresponding to the st_shndx field of each local symbol.
|
|---|
| 4300 |
|
|---|
| 4301 | The global hash table entry for the global symbols can be found
|
|---|
| 4302 | via elf_sym_hashes (input_bfd).
|
|---|
| 4303 |
|
|---|
| 4304 | When generating relocateable output, this function must handle
|
|---|
| 4305 | STB_LOCAL/STT_SECTION symbols specially. The output symbol is
|
|---|
| 4306 | going to be the section symbol corresponding to the output
|
|---|
| 4307 | section, which means that the addend must be adjusted
|
|---|
| 4308 | accordingly. */
|
|---|
| 4309 |
|
|---|
| 4310 | static bfd_boolean
|
|---|
| 4311 | ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
|
|---|
| 4312 | contents, relocs, local_syms, local_sections)
|
|---|
| 4313 | bfd *output_bfd;
|
|---|
| 4314 | struct bfd_link_info *info;
|
|---|
| 4315 | bfd *input_bfd;
|
|---|
| 4316 | asection *input_section;
|
|---|
| 4317 | bfd_byte *contents;
|
|---|
| 4318 | Elf_Internal_Rela *relocs;
|
|---|
| 4319 | Elf_Internal_Sym *local_syms;
|
|---|
| 4320 | asection **local_sections;
|
|---|
| 4321 | {
|
|---|
| 4322 | Elf_Internal_Shdr *symtab_hdr;
|
|---|
| 4323 | struct elf_link_hash_entry **sym_hashes;
|
|---|
| 4324 | struct ppc_elf_link_hash_table *htab;
|
|---|
| 4325 | Elf_Internal_Rela *rel;
|
|---|
| 4326 | Elf_Internal_Rela *relend;
|
|---|
| 4327 | Elf_Internal_Rela outrel;
|
|---|
| 4328 | bfd_byte *loc;
|
|---|
| 4329 | asection *sreloc = NULL;
|
|---|
| 4330 | bfd_vma *local_got_offsets;
|
|---|
| 4331 | bfd_boolean ret = TRUE;
|
|---|
| 4332 |
|
|---|
| 4333 | #ifdef DEBUG
|
|---|
| 4334 | fprintf (stderr, "ppc_elf_relocate_section called for %s section %s, %ld relocations%s\n",
|
|---|
| 4335 | bfd_archive_filename (input_bfd),
|
|---|
| 4336 | bfd_section_name(input_bfd, input_section),
|
|---|
| 4337 | (long) input_section->reloc_count,
|
|---|
| 4338 | (info->relocateable) ? " (relocatable)" : "");
|
|---|
| 4339 | #endif
|
|---|
| 4340 |
|
|---|
| 4341 | if (info->relocateable)
|
|---|
| 4342 | return TRUE;
|
|---|
| 4343 |
|
|---|
| 4344 | if (!ppc_elf_howto_table[R_PPC_ADDR32])
|
|---|
| 4345 | /* Initialize howto table if needed. */
|
|---|
| 4346 | ppc_elf_howto_init ();
|
|---|
| 4347 |
|
|---|
| 4348 | htab = ppc_elf_hash_table (info);
|
|---|
| 4349 | local_got_offsets = elf_local_got_offsets (input_bfd);
|
|---|
| 4350 | symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
|
|---|
| 4351 | sym_hashes = elf_sym_hashes (input_bfd);
|
|---|
| 4352 | rel = relocs;
|
|---|
| 4353 | relend = relocs + input_section->reloc_count;
|
|---|
| 4354 | for (; rel < relend; rel++)
|
|---|
| 4355 | {
|
|---|
| 4356 | enum elf_ppc_reloc_type r_type;
|
|---|
| 4357 | bfd_vma addend;
|
|---|
| 4358 | bfd_reloc_status_type r;
|
|---|
| 4359 | Elf_Internal_Sym *sym;
|
|---|
| 4360 | asection *sec;
|
|---|
| 4361 | struct elf_link_hash_entry *h;
|
|---|
| 4362 | const char *sym_name;
|
|---|
| 4363 | reloc_howto_type *howto;
|
|---|
| 4364 | unsigned long r_symndx;
|
|---|
| 4365 | bfd_vma relocation;
|
|---|
| 4366 | bfd_vma branch_bit, insn, from;
|
|---|
| 4367 | bfd_boolean unresolved_reloc;
|
|---|
| 4368 | bfd_boolean warned;
|
|---|
| 4369 | unsigned int tls_type, tls_mask, tls_gd;
|
|---|
| 4370 |
|
|---|
| 4371 | r_type = (enum elf_ppc_reloc_type)ELF32_R_TYPE (rel->r_info);
|
|---|
| 4372 | sym = (Elf_Internal_Sym *) 0;
|
|---|
| 4373 | sec = (asection *) 0;
|
|---|
| 4374 | h = (struct elf_link_hash_entry *) 0;
|
|---|
| 4375 | unresolved_reloc = FALSE;
|
|---|
| 4376 | warned = FALSE;
|
|---|
| 4377 | r_symndx = ELF32_R_SYM (rel->r_info);
|
|---|
| 4378 | if (r_symndx < symtab_hdr->sh_info)
|
|---|
| 4379 | {
|
|---|
| 4380 | sym = local_syms + r_symndx;
|
|---|
| 4381 | sec = local_sections[r_symndx];
|
|---|
| 4382 | sym_name = bfd_elf_local_sym_name (input_bfd, sym);
|
|---|
| 4383 |
|
|---|
| 4384 | relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
|
|---|
| 4385 | }
|
|---|
| 4386 | else
|
|---|
| 4387 | {
|
|---|
| 4388 | h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
|---|
| 4389 | while (h->root.type == bfd_link_hash_indirect
|
|---|
| 4390 | || h->root.type == bfd_link_hash_warning)
|
|---|
| 4391 | h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|---|
| 4392 | sym_name = h->root.root.string;
|
|---|
| 4393 |
|
|---|
| 4394 | relocation = 0;
|
|---|
| 4395 | if (h->root.type == bfd_link_hash_defined
|
|---|
| 4396 | || h->root.type == bfd_link_hash_defweak)
|
|---|
| 4397 | {
|
|---|
| 4398 | sec = h->root.u.def.section;
|
|---|
| 4399 | /* Set a flag that will be cleared later if we find a
|
|---|
| 4400 | relocation value for this symbol. output_section
|
|---|
| 4401 | is typically NULL for symbols satisfied by a shared
|
|---|
| 4402 | library. */
|
|---|
| 4403 | if (sec->output_section == NULL)
|
|---|
| 4404 | unresolved_reloc = TRUE;
|
|---|
| 4405 | else
|
|---|
| 4406 | relocation = (h->root.u.def.value
|
|---|
| 4407 | + sec->output_section->vma
|
|---|
| 4408 | + sec->output_offset);
|
|---|
| 4409 | }
|
|---|
| 4410 | else if (h->root.type == bfd_link_hash_undefweak)
|
|---|
| 4411 | ;
|
|---|
| 4412 | else if (info->shared
|
|---|
| 4413 | && !info->no_undefined
|
|---|
| 4414 | && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
|
|---|
| 4415 | ;
|
|---|
| 4416 | else
|
|---|
| 4417 | {
|
|---|
| 4418 | if (! ((*info->callbacks->undefined_symbol)
|
|---|
| 4419 | (info, h->root.root.string, input_bfd, input_section,
|
|---|
| 4420 | rel->r_offset, (!info->shared
|
|---|
| 4421 | || info->no_undefined
|
|---|
| 4422 | || ELF_ST_VISIBILITY (h->other)))))
|
|---|
| 4423 | return FALSE;
|
|---|
| 4424 | warned = TRUE;
|
|---|
| 4425 | }
|
|---|
| 4426 | }
|
|---|
| 4427 |
|
|---|
| 4428 | /* TLS optimizations. Replace instruction sequences and relocs
|
|---|
| 4429 | based on information we collected in tls_optimize. We edit
|
|---|
| 4430 | RELOCS so that --emit-relocs will output something sensible
|
|---|
| 4431 | for the final instruction stream. */
|
|---|
| 4432 | tls_mask = 0;
|
|---|
| 4433 | tls_gd = 0;
|
|---|
| 4434 | if (IS_PPC_TLS_RELOC (r_type))
|
|---|
| 4435 | {
|
|---|
| 4436 | if (h != NULL)
|
|---|
| 4437 | tls_mask = ((struct ppc_elf_link_hash_entry *) h)->tls_mask;
|
|---|
| 4438 | else if (local_got_offsets != NULL)
|
|---|
| 4439 | {
|
|---|
| 4440 | char *lgot_masks;
|
|---|
| 4441 | lgot_masks = (char *) (local_got_offsets + symtab_hdr->sh_info);
|
|---|
| 4442 | tls_mask = lgot_masks[r_symndx];
|
|---|
| 4443 | }
|
|---|
| 4444 | }
|
|---|
| 4445 |
|
|---|
| 4446 | /* Ensure reloc mapping code below stays sane. */
|
|---|
| 4447 | if ((R_PPC_GOT_TLSLD16 & 3) != (R_PPC_GOT_TLSGD16 & 3)
|
|---|
| 4448 | || (R_PPC_GOT_TLSLD16_LO & 3) != (R_PPC_GOT_TLSGD16_LO & 3)
|
|---|
| 4449 | || (R_PPC_GOT_TLSLD16_HI & 3) != (R_PPC_GOT_TLSGD16_HI & 3)
|
|---|
| 4450 | || (R_PPC_GOT_TLSLD16_HA & 3) != (R_PPC_GOT_TLSGD16_HA & 3)
|
|---|
| 4451 | || (R_PPC_GOT_TLSLD16 & 3) != (R_PPC_GOT_TPREL16 & 3)
|
|---|
| 4452 | || (R_PPC_GOT_TLSLD16_LO & 3) != (R_PPC_GOT_TPREL16_LO & 3)
|
|---|
| 4453 | || (R_PPC_GOT_TLSLD16_HI & 3) != (R_PPC_GOT_TPREL16_HI & 3)
|
|---|
| 4454 | || (R_PPC_GOT_TLSLD16_HA & 3) != (R_PPC_GOT_TPREL16_HA & 3))
|
|---|
| 4455 | abort ();
|
|---|
| 4456 | switch (r_type)
|
|---|
| 4457 | {
|
|---|
| 4458 | default:
|
|---|
| 4459 | break;
|
|---|
| 4460 |
|
|---|
| 4461 | case R_PPC_GOT_TPREL16:
|
|---|
| 4462 | case R_PPC_GOT_TPREL16_LO:
|
|---|
| 4463 | if (tls_mask != 0
|
|---|
| 4464 | && (tls_mask & TLS_TPREL) == 0)
|
|---|
| 4465 | {
|
|---|
| 4466 | bfd_vma insn;
|
|---|
| 4467 | insn = bfd_get_32 (output_bfd, contents + rel->r_offset - 2);
|
|---|
| 4468 | insn &= 31 << 21;
|
|---|
| 4469 | insn |= 0x3c020000; /* addis 0,2,0 */
|
|---|
| 4470 | bfd_put_32 (output_bfd, insn, contents + rel->r_offset - 2);
|
|---|
| 4471 | r_type = R_PPC_TPREL16_HA;
|
|---|
| 4472 | rel->r_info = ELF32_R_INFO (r_symndx, r_type);
|
|---|
| 4473 | }
|
|---|
| 4474 | break;
|
|---|
| 4475 |
|
|---|
| 4476 | case R_PPC_TLS:
|
|---|
| 4477 | if (tls_mask != 0
|
|---|
| 4478 | && (tls_mask & TLS_TPREL) == 0)
|
|---|
| 4479 | {
|
|---|
| 4480 | bfd_vma insn, rtra;
|
|---|
| 4481 | insn = bfd_get_32 (output_bfd, contents + rel->r_offset);
|
|---|
| 4482 | if ((insn & ((31 << 26) | (31 << 11)))
|
|---|
| 4483 | == ((31 << 26) | (2 << 11)))
|
|---|
| 4484 | rtra = insn & ((1 << 26) - (1 << 16));
|
|---|
| 4485 | else if ((insn & ((31 << 26) | (31 << 16)))
|
|---|
| 4486 | == ((31 << 26) | (2 << 16)))
|
|---|
| 4487 | rtra = (insn & (31 << 21)) | ((insn & (31 << 11)) << 5);
|
|---|
| 4488 | else
|
|---|
| 4489 | abort ();
|
|---|
| 4490 | if ((insn & ((1 << 11) - (1 << 1))) == 266 << 1)
|
|---|
| 4491 | /* add -> addi. */
|
|---|
| 4492 | insn = 14 << 26;
|
|---|
| 4493 | else if ((insn & (31 << 1)) == 23 << 1
|
|---|
| 4494 | && ((insn & (31 << 6)) < 14 << 6
|
|---|
| 4495 | || ((insn & (31 << 6)) >= 16 << 6
|
|---|
| 4496 | && (insn & (31 << 6)) < 24 << 6)))
|
|---|
| 4497 | /* load and store indexed -> dform. */
|
|---|
| 4498 | insn = (32 | ((insn >> 6) & 31)) << 26;
|
|---|
| 4499 | else if ((insn & (31 << 1)) == 21 << 1
|
|---|
| 4500 | && (insn & (0x1a << 6)) == 0)
|
|---|
| 4501 | /* ldx, ldux, stdx, stdux -> ld, ldu, std, stdu. */
|
|---|
| 4502 | insn = (((58 | ((insn >> 6) & 4)) << 26)
|
|---|
| 4503 | | ((insn >> 6) & 1));
|
|---|
| 4504 | else if ((insn & (31 << 1)) == 21 << 1
|
|---|
| 4505 | && (insn & ((1 << 11) - (1 << 1))) == 341 << 1)
|
|---|
| 4506 | /* lwax -> lwa. */
|
|---|
| 4507 | insn = (58 << 26) | 2;
|
|---|
| 4508 | else
|
|---|
| 4509 | abort ();
|
|---|
| 4510 | insn |= rtra;
|
|---|
| 4511 | bfd_put_32 (output_bfd, insn, contents + rel->r_offset);
|
|---|
| 4512 | r_type = R_PPC_TPREL16_LO;
|
|---|
| 4513 | rel->r_info = ELF32_R_INFO (r_symndx, r_type);
|
|---|
| 4514 | /* Was PPC_TLS which sits on insn boundary, now
|
|---|
| 4515 | PPC_TPREL16_LO which is at insn+2. */
|
|---|
| 4516 | rel->r_offset += 2;
|
|---|
| 4517 | }
|
|---|
| 4518 | break;
|
|---|
| 4519 |
|
|---|
| 4520 | case R_PPC_GOT_TLSGD16_HI:
|
|---|
| 4521 | case R_PPC_GOT_TLSGD16_HA:
|
|---|
| 4522 | tls_gd = TLS_TPRELGD;
|
|---|
| 4523 | if (tls_mask != 0 && (tls_mask & TLS_GD) == 0)
|
|---|
| 4524 | goto tls_gdld_hi;
|
|---|
| 4525 | break;
|
|---|
| 4526 |
|
|---|
| 4527 | case R_PPC_GOT_TLSLD16_HI:
|
|---|
| 4528 | case R_PPC_GOT_TLSLD16_HA:
|
|---|
| 4529 | if (tls_mask != 0 && (tls_mask & TLS_LD) == 0)
|
|---|
| 4530 | {
|
|---|
| 4531 | tls_gdld_hi:
|
|---|
| 4532 | if ((tls_mask & tls_gd) != 0)
|
|---|
| 4533 | r_type = (((r_type - (R_PPC_GOT_TLSGD16 & 3)) & 3)
|
|---|
| 4534 | + R_PPC_GOT_TPREL16);
|
|---|
| 4535 | else
|
|---|
| 4536 | {
|
|---|
| 4537 | bfd_put_32 (output_bfd, NOP, contents + rel->r_offset);
|
|---|
| 4538 | rel->r_offset -= 2;
|
|---|
| 4539 | r_type = R_PPC_NONE;
|
|---|
| 4540 | }
|
|---|
| 4541 | rel->r_info = ELF32_R_INFO (r_symndx, r_type);
|
|---|
| 4542 | }
|
|---|
| 4543 | break;
|
|---|
| 4544 |
|
|---|
| 4545 | case R_PPC_GOT_TLSGD16:
|
|---|
| 4546 | case R_PPC_GOT_TLSGD16_LO:
|
|---|
| 4547 | tls_gd = TLS_TPRELGD;
|
|---|
| 4548 | if (tls_mask != 0 && (tls_mask & TLS_GD) == 0)
|
|---|
| 4549 | goto tls_get_addr_check;
|
|---|
| 4550 | break;
|
|---|
| 4551 |
|
|---|
| 4552 | case R_PPC_GOT_TLSLD16:
|
|---|
| 4553 | case R_PPC_GOT_TLSLD16_LO:
|
|---|
| 4554 | if (tls_mask != 0 && (tls_mask & TLS_LD) == 0)
|
|---|
| 4555 | {
|
|---|
| 4556 | tls_get_addr_check:
|
|---|
| 4557 | if (rel + 1 < relend)
|
|---|
| 4558 | {
|
|---|
| 4559 | enum elf_ppc_reloc_type r_type2;
|
|---|
| 4560 | unsigned long r_symndx2;
|
|---|
| 4561 | struct elf_link_hash_entry *h2;
|
|---|
| 4562 | bfd_vma insn1, insn2;
|
|---|
| 4563 | bfd_vma offset;
|
|---|
| 4564 |
|
|---|
| 4565 | /* The next instruction should be a call to
|
|---|
| 4566 | __tls_get_addr. Peek at the reloc to be sure. */
|
|---|
| 4567 | r_type2
|
|---|
| 4568 | = (enum elf_ppc_reloc_type) ELF32_R_TYPE (rel[1].r_info);
|
|---|
| 4569 | r_symndx2 = ELF32_R_SYM (rel[1].r_info);
|
|---|
| 4570 | if (r_symndx2 < symtab_hdr->sh_info
|
|---|
| 4571 | || (r_type2 != R_PPC_REL14
|
|---|
| 4572 | && r_type2 != R_PPC_REL14_BRTAKEN
|
|---|
| 4573 | && r_type2 != R_PPC_REL14_BRNTAKEN
|
|---|
| 4574 | && r_type2 != R_PPC_REL24
|
|---|
| 4575 | && r_type2 != R_PPC_PLTREL24))
|
|---|
| 4576 | break;
|
|---|
| 4577 |
|
|---|
| 4578 | h2 = sym_hashes[r_symndx2 - symtab_hdr->sh_info];
|
|---|
| 4579 | while (h2->root.type == bfd_link_hash_indirect
|
|---|
| 4580 | || h2->root.type == bfd_link_hash_warning)
|
|---|
| 4581 | h2 = (struct elf_link_hash_entry *) h2->root.u.i.link;
|
|---|
| 4582 | if (h2 == NULL || h2 != htab->tls_get_addr)
|
|---|
| 4583 | break;
|
|---|
| 4584 |
|
|---|
| 4585 | /* OK, it checks out. Replace the call. */
|
|---|
| 4586 | offset = rel[1].r_offset;
|
|---|
| 4587 | insn1 = bfd_get_32 (output_bfd,
|
|---|
| 4588 | contents + rel->r_offset - 2);
|
|---|
| 4589 | if ((tls_mask & tls_gd) != 0)
|
|---|
| 4590 | {
|
|---|
| 4591 | /* IE */
|
|---|
| 4592 | insn1 &= (1 << 26) - 1;
|
|---|
| 4593 | insn1 |= 32 << 26; /* lwz */
|
|---|
| 4594 | insn2 = 0x7c631214; /* add 3,3,2 */
|
|---|
| 4595 | rel[1].r_info = ELF32_R_INFO (r_symndx2, R_PPC_NONE);
|
|---|
| 4596 | r_type = (((r_type - (R_PPC_GOT_TLSGD16 & 3)) & 3)
|
|---|
| 4597 | + R_PPC_GOT_TPREL16);
|
|---|
| 4598 | rel->r_info = ELF32_R_INFO (r_symndx, r_type);
|
|---|
| 4599 | }
|
|---|
| 4600 | else
|
|---|
| 4601 | {
|
|---|
| 4602 | /* LE */
|
|---|
| 4603 | insn1 = 0x3c620000; /* addis 3,2,0 */
|
|---|
| 4604 | insn2 = 0x38630000; /* addi 3,3,0 */
|
|---|
| 4605 | if (tls_gd == 0)
|
|---|
| 4606 | {
|
|---|
| 4607 | /* Was an LD reloc. */
|
|---|
| 4608 | r_symndx = 0;
|
|---|
| 4609 | rel->r_addend = htab->tls_sec->vma + DTP_OFFSET;
|
|---|
| 4610 | rel[1].r_addend = htab->tls_sec->vma + DTP_OFFSET;
|
|---|
| 4611 | }
|
|---|
| 4612 | r_type = R_PPC_TPREL16_HA;
|
|---|
| 4613 | rel->r_info = ELF32_R_INFO (r_symndx, r_type);
|
|---|
| 4614 | rel[1].r_info = ELF32_R_INFO (r_symndx,
|
|---|
| 4615 | R_PPC_TPREL16_LO);
|
|---|
| 4616 | rel[1].r_offset += 2;
|
|---|
| 4617 | }
|
|---|
| 4618 | bfd_put_32 (output_bfd, insn1, contents + rel->r_offset - 2);
|
|---|
| 4619 | bfd_put_32 (output_bfd, insn2, contents + offset);
|
|---|
| 4620 | if (tls_gd == 0)
|
|---|
| 4621 | {
|
|---|
| 4622 | /* We changed the symbol on an LD reloc. Start over
|
|---|
| 4623 | in order to get h, sym, sec etc. right. */
|
|---|
| 4624 | rel--;
|
|---|
| 4625 | continue;
|
|---|
| 4626 | }
|
|---|
| 4627 | }
|
|---|
| 4628 | }
|
|---|
| 4629 | break;
|
|---|
| 4630 | }
|
|---|
| 4631 |
|
|---|
| 4632 | /* Handle other relocations that tweak non-addend part of insn. */
|
|---|
| 4633 | branch_bit = 0;
|
|---|
| 4634 | switch (r_type)
|
|---|
| 4635 | {
|
|---|
| 4636 | default:
|
|---|
| 4637 | break;
|
|---|
| 4638 |
|
|---|
| 4639 | /* Branch taken prediction relocations. */
|
|---|
| 4640 | case R_PPC_ADDR14_BRTAKEN:
|
|---|
| 4641 | case R_PPC_REL14_BRTAKEN:
|
|---|
| 4642 | branch_bit = BRANCH_PREDICT_BIT;
|
|---|
| 4643 | /* Fall thru */
|
|---|
| 4644 |
|
|---|
| 4645 | /* Branch not taken predicition relocations. */
|
|---|
| 4646 | case R_PPC_ADDR14_BRNTAKEN:
|
|---|
| 4647 | case R_PPC_REL14_BRNTAKEN:
|
|---|
| 4648 | insn = bfd_get_32 (output_bfd, contents + rel->r_offset);
|
|---|
| 4649 | insn &= ~BRANCH_PREDICT_BIT;
|
|---|
| 4650 | insn |= branch_bit;
|
|---|
| 4651 |
|
|---|
| 4652 | from = (rel->r_offset
|
|---|
| 4653 | + input_section->output_offset
|
|---|
| 4654 | + input_section->output_section->vma);
|
|---|
| 4655 |
|
|---|
| 4656 | /* Invert 'y' bit if not the default. */
|
|---|
| 4657 | if ((bfd_signed_vma) (relocation + rel->r_addend - from) < 0)
|
|---|
| 4658 | insn ^= BRANCH_PREDICT_BIT;
|
|---|
| 4659 |
|
|---|
| 4660 | bfd_put_32 (output_bfd, insn, contents + rel->r_offset);
|
|---|
| 4661 | break;
|
|---|
| 4662 | }
|
|---|
| 4663 |
|
|---|
| 4664 | addend = rel->r_addend;
|
|---|
| 4665 | tls_type = 0;
|
|---|
| 4666 | howto = NULL;
|
|---|
| 4667 | if ((unsigned) r_type < (unsigned) R_PPC_max)
|
|---|
| 4668 | howto = ppc_elf_howto_table[(int) r_type];
|
|---|
| 4669 | switch (r_type)
|
|---|
| 4670 | {
|
|---|
| 4671 | default:
|
|---|
| 4672 | (*_bfd_error_handler)
|
|---|
| 4673 | (_("%s: unknown relocation type %d for symbol %s"),
|
|---|
| 4674 | bfd_archive_filename (input_bfd), (int) r_type, sym_name);
|
|---|
| 4675 |
|
|---|
| 4676 | bfd_set_error (bfd_error_bad_value);
|
|---|
| 4677 | ret = FALSE;
|
|---|
| 4678 | continue;
|
|---|
| 4679 |
|
|---|
| 4680 | case R_PPC_NONE:
|
|---|
| 4681 | case R_PPC_TLS:
|
|---|
| 4682 | case R_PPC_EMB_MRKREF:
|
|---|
| 4683 | case R_PPC_GNU_VTINHERIT:
|
|---|
| 4684 | case R_PPC_GNU_VTENTRY:
|
|---|
| 4685 | continue;
|
|---|
| 4686 |
|
|---|
| 4687 | /* GOT16 relocations. Like an ADDR16 using the symbol's
|
|---|
| 4688 | address in the GOT as relocation value instead of the
|
|---|
| 4689 | symbol's value itself. Also, create a GOT entry for the
|
|---|
| 4690 | symbol and put the symbol value there. */
|
|---|
| 4691 | case R_PPC_GOT_TLSGD16:
|
|---|
| 4692 | case R_PPC_GOT_TLSGD16_LO:
|
|---|
| 4693 | case R_PPC_GOT_TLSGD16_HI:
|
|---|
| 4694 | case R_PPC_GOT_TLSGD16_HA:
|
|---|
| 4695 | tls_type = TLS_TLS | TLS_GD;
|
|---|
| 4696 | goto dogot;
|
|---|
| 4697 |
|
|---|
| 4698 | case R_PPC_GOT_TLSLD16:
|
|---|
| 4699 | case R_PPC_GOT_TLSLD16_LO:
|
|---|
| 4700 | case R_PPC_GOT_TLSLD16_HI:
|
|---|
| 4701 | case R_PPC_GOT_TLSLD16_HA:
|
|---|
| 4702 | tls_type = TLS_TLS | TLS_LD;
|
|---|
| 4703 | goto dogot;
|
|---|
| 4704 |
|
|---|
| 4705 | case R_PPC_GOT_TPREL16:
|
|---|
| 4706 | case R_PPC_GOT_TPREL16_LO:
|
|---|
| 4707 | case R_PPC_GOT_TPREL16_HI:
|
|---|
| 4708 | case R_PPC_GOT_TPREL16_HA:
|
|---|
| 4709 | tls_type = TLS_TLS | TLS_TPREL;
|
|---|
| 4710 | goto dogot;
|
|---|
| 4711 |
|
|---|
| 4712 | case R_PPC_GOT_DTPREL16:
|
|---|
| 4713 | case R_PPC_GOT_DTPREL16_LO:
|
|---|
| 4714 | case R_PPC_GOT_DTPREL16_HI:
|
|---|
| 4715 | case R_PPC_GOT_DTPREL16_HA:
|
|---|
| 4716 | tls_type = TLS_TLS | TLS_DTPREL;
|
|---|
| 4717 | goto dogot;
|
|---|
| 4718 |
|
|---|
| 4719 | case R_PPC_GOT16:
|
|---|
| 4720 | case R_PPC_GOT16_LO:
|
|---|
| 4721 | case R_PPC_GOT16_HI:
|
|---|
| 4722 | case R_PPC_GOT16_HA:
|
|---|
| 4723 | dogot:
|
|---|
| 4724 | {
|
|---|
| 4725 | /* Relocation is to the entry for this symbol in the global
|
|---|
| 4726 | offset table. */
|
|---|
| 4727 | bfd_vma off;
|
|---|
| 4728 | bfd_vma *offp;
|
|---|
| 4729 | unsigned long indx;
|
|---|
| 4730 |
|
|---|
| 4731 | if (htab->got == NULL)
|
|---|
| 4732 | abort ();
|
|---|
| 4733 |
|
|---|
| 4734 | indx = 0;
|
|---|
| 4735 | if (tls_type == (TLS_TLS | TLS_LD)
|
|---|
| 4736 | && (h == NULL
|
|---|
| 4737 | || !(h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC)))
|
|---|
| 4738 | offp = &htab->tlsld_got.offset;
|
|---|
| 4739 | else if (h != NULL)
|
|---|
| 4740 | {
|
|---|
| 4741 | bfd_boolean dyn;
|
|---|
| 4742 | dyn = htab->elf.dynamic_sections_created;
|
|---|
| 4743 | if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
|
|---|
| 4744 | || (info->shared
|
|---|
| 4745 | && SYMBOL_REFERENCES_LOCAL (info, h)))
|
|---|
| 4746 | /* This is actually a static link, or it is a
|
|---|
| 4747 | -Bsymbolic link and the symbol is defined
|
|---|
| 4748 | locally, or the symbol was forced to be local
|
|---|
| 4749 | because of a version file. */
|
|---|
| 4750 | ;
|
|---|
| 4751 | else
|
|---|
| 4752 | {
|
|---|
| 4753 | indx = h->dynindx;
|
|---|
| 4754 | unresolved_reloc = FALSE;
|
|---|
| 4755 | }
|
|---|
| 4756 | offp = &h->got.offset;
|
|---|
| 4757 | }
|
|---|
| 4758 | else
|
|---|
| 4759 | {
|
|---|
| 4760 | if (local_got_offsets == NULL)
|
|---|
| 4761 | abort ();
|
|---|
| 4762 | offp = &local_got_offsets[r_symndx];
|
|---|
| 4763 | }
|
|---|
| 4764 |
|
|---|
| 4765 | /* The offset must always be a multiple of 4. We use the
|
|---|
| 4766 | least significant bit to record whether we have already
|
|---|
| 4767 | processed this entry. */
|
|---|
| 4768 | off = *offp;
|
|---|
| 4769 | if ((off & 1) != 0)
|
|---|
| 4770 | off &= ~1;
|
|---|
| 4771 | else
|
|---|
| 4772 | {
|
|---|
| 4773 | unsigned int tls_m = (tls_mask
|
|---|
| 4774 | & (TLS_LD | TLS_GD | TLS_DTPREL
|
|---|
| 4775 | | TLS_TPREL | TLS_TPRELGD));
|
|---|
| 4776 |
|
|---|
| 4777 | if (offp == &htab->tlsld_got.offset)
|
|---|
| 4778 | tls_m = TLS_LD;
|
|---|
| 4779 | else if (h == NULL
|
|---|
| 4780 | || !(h->elf_link_hash_flags
|
|---|
| 4781 | & ELF_LINK_HASH_DEF_DYNAMIC))
|
|---|
| 4782 | tls_m &= ~TLS_LD;
|
|---|
| 4783 |
|
|---|
| 4784 | /* We might have multiple got entries for this sym.
|
|---|
| 4785 | Initialize them all. */
|
|---|
| 4786 | do
|
|---|
| 4787 | {
|
|---|
| 4788 | int tls_ty = 0;
|
|---|
| 4789 |
|
|---|
| 4790 | if ((tls_m & TLS_LD) != 0)
|
|---|
| 4791 | {
|
|---|
| 4792 | tls_ty = TLS_TLS | TLS_LD;
|
|---|
| 4793 | tls_m &= ~TLS_LD;
|
|---|
| 4794 | }
|
|---|
| 4795 | else if ((tls_m & TLS_GD) != 0)
|
|---|
| 4796 | {
|
|---|
| 4797 | tls_ty = TLS_TLS | TLS_GD;
|
|---|
| 4798 | tls_m &= ~TLS_GD;
|
|---|
| 4799 | }
|
|---|
| 4800 | else if ((tls_m & TLS_DTPREL) != 0)
|
|---|
| 4801 | {
|
|---|
| 4802 | tls_ty = TLS_TLS | TLS_DTPREL;
|
|---|
| 4803 | tls_m &= ~TLS_DTPREL;
|
|---|
| 4804 | }
|
|---|
| 4805 | else if ((tls_m & (TLS_TPREL | TLS_TPRELGD)) != 0)
|
|---|
| 4806 | {
|
|---|
| 4807 | tls_ty = TLS_TLS | TLS_TPREL;
|
|---|
| 4808 | tls_m = 0;
|
|---|
| 4809 | }
|
|---|
| 4810 |
|
|---|
| 4811 | /* Generate relocs for the dynamic linker. */
|
|---|
| 4812 | if (info->shared || indx != 0)
|
|---|
| 4813 | {
|
|---|
| 4814 | outrel.r_offset = (htab->got->output_section->vma
|
|---|
| 4815 | + htab->got->output_offset
|
|---|
| 4816 | + off);
|
|---|
| 4817 | outrel.r_addend = 0;
|
|---|
| 4818 | if (tls_ty & (TLS_LD | TLS_GD))
|
|---|
| 4819 | {
|
|---|
| 4820 | outrel.r_info = ELF32_R_INFO (indx, R_PPC_DTPMOD32);
|
|---|
| 4821 | if (tls_ty == (TLS_TLS | TLS_GD))
|
|---|
| 4822 | {
|
|---|
| 4823 | loc = htab->relgot->contents;
|
|---|
| 4824 | loc += (htab->relgot->reloc_count++
|
|---|
| 4825 | * sizeof (Elf32_External_Rela));
|
|---|
| 4826 | bfd_elf32_swap_reloca_out (output_bfd,
|
|---|
| 4827 | &outrel, loc);
|
|---|
| 4828 | outrel.r_offset += 4;
|
|---|
| 4829 | outrel.r_info
|
|---|
| 4830 | = ELF32_R_INFO (indx, R_PPC_DTPREL32);
|
|---|
| 4831 | }
|
|---|
| 4832 | }
|
|---|
| 4833 | else if (tls_ty == (TLS_TLS | TLS_DTPREL))
|
|---|
| 4834 | outrel.r_info = ELF32_R_INFO (indx, R_PPC_DTPREL32);
|
|---|
| 4835 | else if (tls_ty == (TLS_TLS | TLS_TPREL))
|
|---|
| 4836 | outrel.r_info = ELF32_R_INFO (indx, R_PPC_TPREL32);
|
|---|
| 4837 | else if (indx == 0)
|
|---|
| 4838 | outrel.r_info = ELF32_R_INFO (indx, R_PPC_RELATIVE);
|
|---|
| 4839 | else
|
|---|
| 4840 | outrel.r_info = ELF32_R_INFO (indx, R_PPC_GLOB_DAT);
|
|---|
| 4841 | if (indx == 0)
|
|---|
| 4842 | {
|
|---|
| 4843 | outrel.r_addend += relocation;
|
|---|
| 4844 | if (tls_ty & (TLS_GD | TLS_DTPREL | TLS_TPREL))
|
|---|
| 4845 | outrel.r_addend -= htab->tls_sec->vma;
|
|---|
| 4846 | }
|
|---|
| 4847 | loc = htab->relgot->contents;
|
|---|
| 4848 | loc += (htab->relgot->reloc_count++
|
|---|
| 4849 | * sizeof (Elf32_External_Rela));
|
|---|
| 4850 | bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
|
|---|
| 4851 | }
|
|---|
| 4852 |
|
|---|
| 4853 | /* Init the .got section contents if we're not
|
|---|
| 4854 | emitting a reloc. */
|
|---|
| 4855 | else
|
|---|
| 4856 | {
|
|---|
| 4857 | bfd_vma value = relocation;
|
|---|
| 4858 |
|
|---|
| 4859 | if (tls_ty == (TLS_TLS | TLS_LD))
|
|---|
| 4860 | value = 1;
|
|---|
| 4861 | else if (tls_ty != 0)
|
|---|
| 4862 | {
|
|---|
| 4863 | value -= htab->tls_sec->vma + DTP_OFFSET;
|
|---|
| 4864 | if (tls_ty == (TLS_TLS | TLS_TPREL))
|
|---|
| 4865 | value += DTP_OFFSET - TP_OFFSET;
|
|---|
| 4866 |
|
|---|
| 4867 | if (tls_ty == (TLS_TLS | TLS_GD))
|
|---|
| 4868 | {
|
|---|
| 4869 | bfd_put_32 (output_bfd, value,
|
|---|
| 4870 | htab->got->contents + off + 4);
|
|---|
| 4871 | value = 1;
|
|---|
| 4872 | }
|
|---|
| 4873 | }
|
|---|
| 4874 | bfd_put_32 (output_bfd, value,
|
|---|
| 4875 | htab->got->contents + off);
|
|---|
| 4876 | }
|
|---|
| 4877 |
|
|---|
| 4878 | off += 4;
|
|---|
| 4879 | if (tls_ty & (TLS_LD | TLS_GD))
|
|---|
| 4880 | off += 4;
|
|---|
| 4881 | }
|
|---|
| 4882 | while (tls_m != 0);
|
|---|
| 4883 |
|
|---|
| 4884 | off = *offp;
|
|---|
| 4885 | *offp = off | 1;
|
|---|
| 4886 | }
|
|---|
| 4887 |
|
|---|
| 4888 | if (off >= (bfd_vma) -2)
|
|---|
| 4889 | abort ();
|
|---|
| 4890 |
|
|---|
| 4891 | if ((tls_type & TLS_TLS) != 0)
|
|---|
| 4892 | {
|
|---|
| 4893 | if (tls_type != (TLS_TLS | TLS_LD))
|
|---|
| 4894 | {
|
|---|
| 4895 | if ((tls_mask & TLS_LD) != 0
|
|---|
| 4896 | && !(h == NULL
|
|---|
| 4897 | || !(h->elf_link_hash_flags
|
|---|
| 4898 | & ELF_LINK_HASH_DEF_DYNAMIC)))
|
|---|
| 4899 | off += 8;
|
|---|
| 4900 | if (tls_type != (TLS_TLS | TLS_GD))
|
|---|
| 4901 | {
|
|---|
| 4902 | if ((tls_mask & TLS_GD) != 0)
|
|---|
| 4903 | off += 8;
|
|---|
| 4904 | if (tls_type != (TLS_TLS | TLS_DTPREL))
|
|---|
| 4905 | {
|
|---|
| 4906 | if ((tls_mask & TLS_DTPREL) != 0)
|
|---|
| 4907 | off += 4;
|
|---|
| 4908 | }
|
|---|
| 4909 | }
|
|---|
| 4910 | }
|
|---|
| 4911 | }
|
|---|
| 4912 |
|
|---|
| 4913 | relocation = htab->got->output_offset + off - 4;
|
|---|
| 4914 |
|
|---|
| 4915 | /* Addends on got relocations don't make much sense.
|
|---|
| 4916 | x+off@got is actually x@got+off, and since the got is
|
|---|
| 4917 | generated by a hash table traversal, the value in the
|
|---|
| 4918 | got at entry m+n bears little relation to the entry m. */
|
|---|
| 4919 | if (addend != 0)
|
|---|
| 4920 | (*_bfd_error_handler)
|
|---|
| 4921 | (_("%s(%s+0x%lx): non-zero addend on %s reloc against `%s'"),
|
|---|
| 4922 | bfd_archive_filename (input_bfd),
|
|---|
| 4923 | bfd_get_section_name (input_bfd, input_section),
|
|---|
| 4924 | (long) rel->r_offset,
|
|---|
| 4925 | howto->name,
|
|---|
| 4926 | sym_name);
|
|---|
| 4927 | }
|
|---|
| 4928 | break;
|
|---|
| 4929 |
|
|---|
| 4930 | /* Relocations that need no special processing. */
|
|---|
| 4931 | case R_PPC_LOCAL24PC:
|
|---|
| 4932 | /* It makes no sense to point a local relocation
|
|---|
| 4933 | at a symbol not in this object. */
|
|---|
| 4934 | if (unresolved_reloc)
|
|---|
| 4935 | {
|
|---|
| 4936 | if (! (*info->callbacks->undefined_symbol) (info,
|
|---|
| 4937 | h->root.root.string,
|
|---|
| 4938 | input_bfd,
|
|---|
| 4939 | input_section,
|
|---|
| 4940 | rel->r_offset,
|
|---|
| 4941 | TRUE))
|
|---|
| 4942 | return FALSE;
|
|---|
| 4943 | continue;
|
|---|
| 4944 | }
|
|---|
| 4945 | break;
|
|---|
| 4946 |
|
|---|
| 4947 | case R_PPC_DTPREL16:
|
|---|
| 4948 | case R_PPC_DTPREL16_LO:
|
|---|
| 4949 | case R_PPC_DTPREL16_HI:
|
|---|
| 4950 | case R_PPC_DTPREL16_HA:
|
|---|
| 4951 | addend -= htab->tls_sec->vma + DTP_OFFSET;
|
|---|
| 4952 | break;
|
|---|
| 4953 |
|
|---|
| 4954 | /* Relocations that may need to be propagated if this is a shared
|
|---|
| 4955 | object. */
|
|---|
| 4956 | case R_PPC_TPREL16:
|
|---|
| 4957 | case R_PPC_TPREL16_LO:
|
|---|
| 4958 | case R_PPC_TPREL16_HI:
|
|---|
| 4959 | case R_PPC_TPREL16_HA:
|
|---|
| 4960 | addend -= htab->tls_sec->vma + TP_OFFSET;
|
|---|
| 4961 | /* The TPREL16 relocs shouldn't really be used in shared
|
|---|
| 4962 | libs as they will result in DT_TEXTREL being set, but
|
|---|
| 4963 | support them anyway. */
|
|---|
| 4964 | goto dodyn;
|
|---|
| 4965 |
|
|---|
| 4966 | case R_PPC_TPREL32:
|
|---|
| 4967 | addend -= htab->tls_sec->vma + TP_OFFSET;
|
|---|
| 4968 | goto dodyn;
|
|---|
| 4969 |
|
|---|
| 4970 | case R_PPC_DTPREL32:
|
|---|
| 4971 | addend -= htab->tls_sec->vma + DTP_OFFSET;
|
|---|
| 4972 | goto dodyn;
|
|---|
| 4973 |
|
|---|
| 4974 | case R_PPC_DTPMOD32:
|
|---|
| 4975 | relocation = 1;
|
|---|
| 4976 | addend = 0;
|
|---|
| 4977 | goto dodyn;
|
|---|
| 4978 |
|
|---|
| 4979 | case R_PPC_REL24:
|
|---|
| 4980 | case R_PPC_REL32:
|
|---|
| 4981 | case R_PPC_REL14:
|
|---|
| 4982 | case R_PPC_REL14_BRTAKEN:
|
|---|
| 4983 | case R_PPC_REL14_BRNTAKEN:
|
|---|
| 4984 | /* If these relocations are not to a named symbol, they can be
|
|---|
| 4985 | handled right here, no need to bother the dynamic linker. */
|
|---|
| 4986 | if (h == NULL
|
|---|
| 4987 | || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0
|
|---|
| 4988 | || SYMBOL_REFERENCES_LOCAL (info, h))
|
|---|
| 4989 | break;
|
|---|
| 4990 | /* fall through */
|
|---|
| 4991 |
|
|---|
| 4992 | /* Relocations that always need to be propagated if this is a shared
|
|---|
| 4993 | object. */
|
|---|
| 4994 | case R_PPC_ADDR32:
|
|---|
| 4995 | case R_PPC_ADDR24:
|
|---|
| 4996 | case R_PPC_ADDR16:
|
|---|
| 4997 | case R_PPC_ADDR16_LO:
|
|---|
| 4998 | case R_PPC_ADDR16_HI:
|
|---|
| 4999 | case R_PPC_ADDR16_HA:
|
|---|
| 5000 | case R_PPC_ADDR14:
|
|---|
| 5001 | case R_PPC_ADDR14_BRTAKEN:
|
|---|
| 5002 | case R_PPC_ADDR14_BRNTAKEN:
|
|---|
| 5003 | case R_PPC_UADDR32:
|
|---|
| 5004 | case R_PPC_UADDR16:
|
|---|
| 5005 | /* r_symndx will be zero only for relocs against symbols
|
|---|
| 5006 | from removed linkonce sections, or sections discarded by
|
|---|
| 5007 | a linker script. */
|
|---|
| 5008 | dodyn:
|
|---|
| 5009 | if (r_symndx == 0)
|
|---|
| 5010 | break;
|
|---|
| 5011 | /* Fall thru. */
|
|---|
| 5012 |
|
|---|
| 5013 | if ((info->shared
|
|---|
| 5014 | && (MUST_BE_DYN_RELOC (r_type)
|
|---|
| 5015 | || (h != NULL
|
|---|
| 5016 | && h->dynindx != -1
|
|---|
| 5017 | && (!info->symbolic
|
|---|
| 5018 | || (h->elf_link_hash_flags
|
|---|
| 5019 | & ELF_LINK_HASH_DEF_REGULAR) == 0))))
|
|---|
| 5020 | || (ELIMINATE_COPY_RELOCS
|
|---|
| 5021 | && !info->shared
|
|---|
| 5022 | && (input_section->flags & SEC_ALLOC) != 0
|
|---|
| 5023 | && h != NULL
|
|---|
| 5024 | && h->dynindx != -1
|
|---|
| 5025 | && (h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0
|
|---|
| 5026 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0
|
|---|
| 5027 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0))
|
|---|
| 5028 | {
|
|---|
| 5029 | int skip;
|
|---|
| 5030 |
|
|---|
| 5031 | #ifdef DEBUG
|
|---|
| 5032 | fprintf (stderr, "ppc_elf_relocate_section need to create relocation for %s\n",
|
|---|
| 5033 | (h && h->root.root.string
|
|---|
| 5034 | ? h->root.root.string : "<unknown>"));
|
|---|
| 5035 | #endif
|
|---|
| 5036 |
|
|---|
| 5037 | /* When generating a shared object, these relocations
|
|---|
| 5038 | are copied into the output file to be resolved at run
|
|---|
| 5039 | time. */
|
|---|
| 5040 | if (sreloc == NULL)
|
|---|
| 5041 | {
|
|---|
| 5042 | const char *name;
|
|---|
| 5043 |
|
|---|
| 5044 | name = (bfd_elf_string_from_elf_section
|
|---|
| 5045 | (input_bfd,
|
|---|
| 5046 | elf_elfheader (input_bfd)->e_shstrndx,
|
|---|
| 5047 | elf_section_data (input_section)->rel_hdr.sh_name));
|
|---|
| 5048 | if (name == NULL)
|
|---|
| 5049 | return FALSE;
|
|---|
| 5050 |
|
|---|
| 5051 | BFD_ASSERT (strncmp (name, ".rela", 5) == 0
|
|---|
| 5052 | && strcmp (bfd_get_section_name (input_bfd,
|
|---|
| 5053 | input_section),
|
|---|
| 5054 | name + 5) == 0);
|
|---|
| 5055 |
|
|---|
| 5056 | sreloc = bfd_get_section_by_name (htab->elf.dynobj, name);
|
|---|
| 5057 | BFD_ASSERT (sreloc != NULL);
|
|---|
| 5058 | }
|
|---|
| 5059 |
|
|---|
| 5060 | skip = 0;
|
|---|
| 5061 |
|
|---|
| 5062 | outrel.r_offset =
|
|---|
| 5063 | _bfd_elf_section_offset (output_bfd, info, input_section,
|
|---|
| 5064 | rel->r_offset);
|
|---|
| 5065 | if (outrel.r_offset == (bfd_vma) -1
|
|---|
| 5066 | || outrel.r_offset == (bfd_vma) -2)
|
|---|
| 5067 | skip = (int) outrel.r_offset;
|
|---|
| 5068 | outrel.r_offset += (input_section->output_section->vma
|
|---|
| 5069 | + input_section->output_offset);
|
|---|
| 5070 |
|
|---|
| 5071 | if (skip)
|
|---|
| 5072 | memset (&outrel, 0, sizeof outrel);
|
|---|
| 5073 | else if (h != NULL
|
|---|
| 5074 | && !SYMBOL_REFERENCES_LOCAL (info, h))
|
|---|
| 5075 | {
|
|---|
| 5076 | unresolved_reloc = FALSE;
|
|---|
| 5077 | outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
|
|---|
| 5078 | outrel.r_addend = rel->r_addend;
|
|---|
| 5079 | }
|
|---|
| 5080 | else
|
|---|
| 5081 | {
|
|---|
| 5082 | outrel.r_addend = relocation + rel->r_addend;
|
|---|
| 5083 |
|
|---|
| 5084 | if (r_type == R_PPC_ADDR32)
|
|---|
| 5085 | outrel.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE);
|
|---|
| 5086 | else
|
|---|
| 5087 | {
|
|---|
| 5088 | long indx;
|
|---|
| 5089 |
|
|---|
| 5090 | if (bfd_is_abs_section (sec))
|
|---|
| 5091 | indx = 0;
|
|---|
| 5092 | else if (sec == NULL || sec->owner == NULL)
|
|---|
| 5093 | {
|
|---|
| 5094 | bfd_set_error (bfd_error_bad_value);
|
|---|
| 5095 | return FALSE;
|
|---|
| 5096 | }
|
|---|
| 5097 | else
|
|---|
| 5098 | {
|
|---|
| 5099 | asection *osec;
|
|---|
| 5100 |
|
|---|
| 5101 | /* We are turning this relocation into one
|
|---|
| 5102 | against a section symbol. It would be
|
|---|
| 5103 | proper to subtract the symbol's value,
|
|---|
| 5104 | osec->vma, from the emitted reloc addend,
|
|---|
| 5105 | but ld.so expects buggy relocs. */
|
|---|
| 5106 | osec = sec->output_section;
|
|---|
| 5107 | indx = elf_section_data (osec)->dynindx;
|
|---|
| 5108 | BFD_ASSERT (indx > 0);
|
|---|
| 5109 | #ifdef DEBUG
|
|---|
| 5110 | if (indx <= 0)
|
|---|
| 5111 | {
|
|---|
| 5112 | printf ("indx=%d section=%s flags=%08x name=%s\n",
|
|---|
| 5113 | indx, osec->name, osec->flags,
|
|---|
| 5114 | h->root.root.string);
|
|---|
| 5115 | }
|
|---|
| 5116 | #endif
|
|---|
| 5117 | }
|
|---|
| 5118 |
|
|---|
| 5119 | outrel.r_info = ELF32_R_INFO (indx, r_type);
|
|---|
| 5120 | }
|
|---|
| 5121 | }
|
|---|
| 5122 |
|
|---|
| 5123 | loc = sreloc->contents;
|
|---|
| 5124 | loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
|
|---|
| 5125 | bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
|
|---|
| 5126 |
|
|---|
| 5127 | if (skip == -1)
|
|---|
| 5128 | continue;
|
|---|
| 5129 |
|
|---|
| 5130 | /* This reloc will be computed at runtime. We clear the memory
|
|---|
| 5131 | so that it contains predictable value. */
|
|---|
| 5132 | if (! skip
|
|---|
| 5133 | && ((input_section->flags & SEC_ALLOC) != 0
|
|---|
| 5134 | || ELF32_R_TYPE (outrel.r_info) != R_PPC_RELATIVE))
|
|---|
| 5135 | {
|
|---|
| 5136 | relocation = howto->pc_relative ? outrel.r_offset : 0;
|
|---|
| 5137 | addend = 0;
|
|---|
| 5138 | break;
|
|---|
| 5139 | }
|
|---|
| 5140 | }
|
|---|
| 5141 | break;
|
|---|
| 5142 |
|
|---|
| 5143 | /* Indirect .sdata relocation. */
|
|---|
| 5144 | case R_PPC_EMB_SDAI16:
|
|---|
| 5145 | BFD_ASSERT (htab->sdata != NULL);
|
|---|
| 5146 | relocation
|
|---|
| 5147 | = bfd_elf32_finish_pointer_linker_section (output_bfd, input_bfd,
|
|---|
| 5148 | info, htab->sdata, h,
|
|---|
| 5149 | relocation, rel,
|
|---|
| 5150 | R_PPC_RELATIVE);
|
|---|
| 5151 | break;
|
|---|
| 5152 |
|
|---|
| 5153 | /* Indirect .sdata2 relocation. */
|
|---|
| 5154 | case R_PPC_EMB_SDA2I16:
|
|---|
| 5155 | BFD_ASSERT (htab->sdata2 != NULL);
|
|---|
| 5156 | relocation
|
|---|
| 5157 | = bfd_elf32_finish_pointer_linker_section (output_bfd, input_bfd,
|
|---|
| 5158 | info, htab->sdata2, h,
|
|---|
| 5159 | relocation, rel,
|
|---|
| 5160 | R_PPC_RELATIVE);
|
|---|
| 5161 | break;
|
|---|
| 5162 |
|
|---|
| 5163 | /* Handle the TOC16 reloc. We want to use the offset within the .got
|
|---|
| 5164 | section, not the actual VMA. This is appropriate when generating
|
|---|
| 5165 | an embedded ELF object, for which the .got section acts like the
|
|---|
| 5166 | AIX .toc section. */
|
|---|
| 5167 | case R_PPC_TOC16: /* phony GOT16 relocations */
|
|---|
| 5168 | BFD_ASSERT (sec != (asection *) 0);
|
|---|
| 5169 | BFD_ASSERT (bfd_is_und_section (sec)
|
|---|
| 5170 | || strcmp (bfd_get_section_name (abfd, sec), ".got") == 0
|
|---|
| 5171 | || strcmp (bfd_get_section_name (abfd, sec), ".cgot") == 0)
|
|---|
| 5172 |
|
|---|
| 5173 | addend -= sec->output_section->vma + sec->output_offset + 0x8000;
|
|---|
| 5174 | break;
|
|---|
| 5175 |
|
|---|
| 5176 | case R_PPC_PLTREL24:
|
|---|
| 5177 | /* Relocation is to the entry for this symbol in the
|
|---|
| 5178 | procedure linkage table. */
|
|---|
| 5179 | BFD_ASSERT (h != NULL);
|
|---|
| 5180 |
|
|---|
| 5181 | if (h->plt.offset == (bfd_vma) -1
|
|---|
| 5182 | || htab->plt == NULL)
|
|---|
| 5183 | {
|
|---|
| 5184 | /* We didn't make a PLT entry for this symbol. This
|
|---|
| 5185 | happens when statically linking PIC code, or when
|
|---|
| 5186 | using -Bsymbolic. */
|
|---|
| 5187 | break;
|
|---|
| 5188 | }
|
|---|
| 5189 |
|
|---|
| 5190 | unresolved_reloc = FALSE;
|
|---|
| 5191 | relocation = (htab->plt->output_section->vma
|
|---|
| 5192 | + htab->plt->output_offset
|
|---|
| 5193 | + h->plt.offset);
|
|---|
| 5194 | break;
|
|---|
| 5195 |
|
|---|
| 5196 | /* Relocate against _SDA_BASE_. */
|
|---|
| 5197 | case R_PPC_SDAREL16:
|
|---|
| 5198 | {
|
|---|
| 5199 | const char *name;
|
|---|
| 5200 | const struct elf_link_hash_entry *sh;
|
|---|
| 5201 |
|
|---|
| 5202 | BFD_ASSERT (sec != (asection *) 0);
|
|---|
| 5203 | name = bfd_get_section_name (abfd, sec->output_section);
|
|---|
| 5204 | if (! ((strncmp (name, ".sdata", 6) == 0
|
|---|
| 5205 | && (name[6] == 0 || name[6] == '.'))
|
|---|
| 5206 | || (strncmp (name, ".sbss", 5) == 0
|
|---|
| 5207 | && (name[5] == 0 || name[5] == '.'))))
|
|---|
| 5208 | {
|
|---|
| 5209 | (*_bfd_error_handler) (_("%s: the target (%s) of a %s relocation is in the wrong output section (%s)"),
|
|---|
| 5210 | bfd_archive_filename (input_bfd),
|
|---|
| 5211 | sym_name,
|
|---|
| 5212 | howto->name,
|
|---|
| 5213 | name);
|
|---|
| 5214 | }
|
|---|
| 5215 | sh = htab->sdata->sym_hash;
|
|---|
| 5216 | addend -= (sh->root.u.def.value
|
|---|
| 5217 | + sh->root.u.def.section->output_section->vma
|
|---|
| 5218 | + sh->root.u.def.section->output_offset);
|
|---|
| 5219 | }
|
|---|
| 5220 | break;
|
|---|
| 5221 |
|
|---|
| 5222 | /* Relocate against _SDA2_BASE_. */
|
|---|
| 5223 | case R_PPC_EMB_SDA2REL:
|
|---|
| 5224 | {
|
|---|
| 5225 | const char *name;
|
|---|
| 5226 | const struct elf_link_hash_entry *sh;
|
|---|
| 5227 |
|
|---|
| 5228 | BFD_ASSERT (sec != (asection *) 0);
|
|---|
| 5229 | name = bfd_get_section_name (abfd, sec->output_section);
|
|---|
| 5230 | if (! (strncmp (name, ".sdata2", 7) == 0
|
|---|
| 5231 | || strncmp (name, ".sbss2", 6) == 0))
|
|---|
| 5232 | {
|
|---|
| 5233 | (*_bfd_error_handler) (_("%s: the target (%s) of a %s relocation is in the wrong output section (%s)"),
|
|---|
| 5234 | bfd_archive_filename (input_bfd),
|
|---|
| 5235 | sym_name,
|
|---|
| 5236 | howto->name,
|
|---|
| 5237 | name);
|
|---|
| 5238 |
|
|---|
| 5239 | bfd_set_error (bfd_error_bad_value);
|
|---|
| 5240 | ret = FALSE;
|
|---|
| 5241 | continue;
|
|---|
| 5242 | }
|
|---|
| 5243 | sh = htab->sdata2->sym_hash;
|
|---|
| 5244 | addend -= (sh->root.u.def.value
|
|---|
| 5245 | + sh->root.u.def.section->output_section->vma
|
|---|
| 5246 | + sh->root.u.def.section->output_offset);
|
|---|
| 5247 | }
|
|---|
| 5248 | break;
|
|---|
| 5249 |
|
|---|
| 5250 | /* Relocate against either _SDA_BASE_, _SDA2_BASE_, or 0. */
|
|---|
| 5251 | case R_PPC_EMB_SDA21:
|
|---|
| 5252 | case R_PPC_EMB_RELSDA:
|
|---|
| 5253 | {
|
|---|
| 5254 | const char *name;
|
|---|
| 5255 | const struct elf_link_hash_entry *sh;
|
|---|
| 5256 | int reg;
|
|---|
| 5257 |
|
|---|
| 5258 | BFD_ASSERT (sec != (asection *) 0);
|
|---|
| 5259 | name = bfd_get_section_name (abfd, sec->output_section);
|
|---|
| 5260 | if (((strncmp (name, ".sdata", 6) == 0
|
|---|
| 5261 | && (name[6] == 0 || name[6] == '.'))
|
|---|
| 5262 | || (strncmp (name, ".sbss", 5) == 0
|
|---|
| 5263 | && (name[5] == 0 || name[5] == '.'))))
|
|---|
| 5264 | {
|
|---|
| 5265 | reg = 13;
|
|---|
| 5266 | sh = htab->sdata->sym_hash;
|
|---|
| 5267 | addend -= (sh->root.u.def.value
|
|---|
| 5268 | + sh->root.u.def.section->output_section->vma
|
|---|
| 5269 | + sh->root.u.def.section->output_offset);
|
|---|
| 5270 | }
|
|---|
| 5271 |
|
|---|
| 5272 | else if (strncmp (name, ".sdata2", 7) == 0
|
|---|
| 5273 | || strncmp (name, ".sbss2", 6) == 0)
|
|---|
| 5274 | {
|
|---|
| 5275 | reg = 2;
|
|---|
| 5276 | sh = htab->sdata2->sym_hash;
|
|---|
| 5277 | addend -= (sh->root.u.def.value
|
|---|
| 5278 | + sh->root.u.def.section->output_section->vma
|
|---|
| 5279 | + sh->root.u.def.section->output_offset);
|
|---|
| 5280 | }
|
|---|
| 5281 |
|
|---|
| 5282 | else if (strcmp (name, ".PPC.EMB.sdata0") == 0
|
|---|
| 5283 | || strcmp (name, ".PPC.EMB.sbss0") == 0)
|
|---|
| 5284 | {
|
|---|
| 5285 | reg = 0;
|
|---|
| 5286 | }
|
|---|
| 5287 |
|
|---|
| 5288 | else
|
|---|
| 5289 | {
|
|---|
| 5290 | (*_bfd_error_handler) (_("%s: the target (%s) of a %s relocation is in the wrong output section (%s)"),
|
|---|
| 5291 | bfd_archive_filename (input_bfd),
|
|---|
| 5292 | sym_name,
|
|---|
| 5293 | howto->name,
|
|---|
| 5294 | name);
|
|---|
| 5295 |
|
|---|
| 5296 | bfd_set_error (bfd_error_bad_value);
|
|---|
| 5297 | ret = FALSE;
|
|---|
| 5298 | continue;
|
|---|
| 5299 | }
|
|---|
| 5300 |
|
|---|
| 5301 | if (r_type == R_PPC_EMB_SDA21)
|
|---|
| 5302 | { /* fill in register field */
|
|---|
| 5303 | insn = bfd_get_32 (output_bfd, contents + rel->r_offset);
|
|---|
| 5304 | insn = (insn & ~RA_REGISTER_MASK) | (reg << RA_REGISTER_SHIFT);
|
|---|
| 5305 | bfd_put_32 (output_bfd, insn, contents + rel->r_offset);
|
|---|
| 5306 | }
|
|---|
| 5307 | }
|
|---|
| 5308 | break;
|
|---|
| 5309 |
|
|---|
| 5310 | /* Relocate against the beginning of the section. */
|
|---|
| 5311 | case R_PPC_SECTOFF:
|
|---|
| 5312 | case R_PPC_SECTOFF_LO:
|
|---|
| 5313 | case R_PPC_SECTOFF_HI:
|
|---|
| 5314 | case R_PPC_SECTOFF_HA:
|
|---|
| 5315 | BFD_ASSERT (sec != (asection *) 0);
|
|---|
| 5316 | addend -= sec->output_section->vma;
|
|---|
| 5317 | break;
|
|---|
| 5318 |
|
|---|
| 5319 | /* Negative relocations. */
|
|---|
| 5320 | case R_PPC_EMB_NADDR32:
|
|---|
| 5321 | case R_PPC_EMB_NADDR16:
|
|---|
| 5322 | case R_PPC_EMB_NADDR16_LO:
|
|---|
| 5323 | case R_PPC_EMB_NADDR16_HI:
|
|---|
| 5324 | case R_PPC_EMB_NADDR16_HA:
|
|---|
| 5325 | addend -= 2 * relocation;
|
|---|
| 5326 | break;
|
|---|
| 5327 |
|
|---|
| 5328 | case R_PPC_COPY:
|
|---|
| 5329 | case R_PPC_GLOB_DAT:
|
|---|
| 5330 | case R_PPC_JMP_SLOT:
|
|---|
| 5331 | case R_PPC_RELATIVE:
|
|---|
| 5332 | case R_PPC_PLT32:
|
|---|
| 5333 | case R_PPC_PLTREL32:
|
|---|
| 5334 | case R_PPC_PLT16_LO:
|
|---|
| 5335 | case R_PPC_PLT16_HI:
|
|---|
| 5336 | case R_PPC_PLT16_HA:
|
|---|
| 5337 | case R_PPC_ADDR30:
|
|---|
| 5338 | case R_PPC_EMB_RELSEC16:
|
|---|
| 5339 | case R_PPC_EMB_RELST_LO:
|
|---|
| 5340 | case R_PPC_EMB_RELST_HI:
|
|---|
| 5341 | case R_PPC_EMB_RELST_HA:
|
|---|
| 5342 | case R_PPC_EMB_BIT_FLD:
|
|---|
| 5343 | (*_bfd_error_handler)
|
|---|
| 5344 | (_("%s: relocation %s is not yet supported for symbol %s."),
|
|---|
| 5345 | bfd_archive_filename (input_bfd),
|
|---|
| 5346 | howto->name,
|
|---|
| 5347 | sym_name);
|
|---|
| 5348 |
|
|---|
| 5349 | bfd_set_error (bfd_error_invalid_operation);
|
|---|
| 5350 | ret = FALSE;
|
|---|
| 5351 | continue;
|
|---|
| 5352 | }
|
|---|
| 5353 |
|
|---|
| 5354 | /* Do any further special processing. */
|
|---|
| 5355 | switch (r_type)
|
|---|
| 5356 | {
|
|---|
| 5357 | default:
|
|---|
| 5358 | break;
|
|---|
| 5359 |
|
|---|
| 5360 | case R_PPC_ADDR16_HA:
|
|---|
| 5361 | case R_PPC_GOT16_HA:
|
|---|
| 5362 | case R_PPC_PLT16_HA:
|
|---|
| 5363 | case R_PPC_SECTOFF_HA:
|
|---|
| 5364 | case R_PPC_TPREL16_HA:
|
|---|
| 5365 | case R_PPC_DTPREL16_HA:
|
|---|
| 5366 | case R_PPC_GOT_TLSGD16_HA:
|
|---|
| 5367 | case R_PPC_GOT_TLSLD16_HA:
|
|---|
| 5368 | case R_PPC_GOT_TPREL16_HA:
|
|---|
| 5369 | case R_PPC_GOT_DTPREL16_HA:
|
|---|
| 5370 | case R_PPC_EMB_NADDR16_HA:
|
|---|
| 5371 | case R_PPC_EMB_RELST_HA:
|
|---|
| 5372 | /* It's just possible that this symbol is a weak symbol
|
|---|
| 5373 | that's not actually defined anywhere. In that case,
|
|---|
| 5374 | 'sec' would be NULL, and we should leave the symbol
|
|---|
| 5375 | alone (it will be set to zero elsewhere in the link). */
|
|---|
| 5376 | if (sec != NULL)
|
|---|
| 5377 | /* Add 0x10000 if sign bit in 0:15 is set.
|
|---|
| 5378 | Bits 0:15 are not used. */
|
|---|
| 5379 | addend += 0x8000;
|
|---|
| 5380 | break;
|
|---|
| 5381 | }
|
|---|
| 5382 |
|
|---|
| 5383 | #ifdef DEBUG
|
|---|
| 5384 | fprintf (stderr, "\ttype = %s (%d), name = %s, symbol index = %ld, offset = %ld, addend = %ld\n",
|
|---|
| 5385 | howto->name,
|
|---|
| 5386 | (int) r_type,
|
|---|
| 5387 | sym_name,
|
|---|
| 5388 | r_symndx,
|
|---|
| 5389 | (long) rel->r_offset,
|
|---|
| 5390 | (long) addend);
|
|---|
| 5391 | #endif
|
|---|
| 5392 |
|
|---|
| 5393 | if (unresolved_reloc
|
|---|
| 5394 | && !((input_section->flags & SEC_DEBUGGING) != 0
|
|---|
| 5395 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
|
|---|
| 5396 | {
|
|---|
| 5397 | (*_bfd_error_handler)
|
|---|
| 5398 | (_("%s(%s+0x%lx): unresolvable %s relocation against symbol `%s'"),
|
|---|
| 5399 | bfd_archive_filename (input_bfd),
|
|---|
| 5400 | bfd_get_section_name (input_bfd, input_section),
|
|---|
| 5401 | (long) rel->r_offset,
|
|---|
| 5402 | howto->name,
|
|---|
| 5403 | sym_name);
|
|---|
| 5404 | ret = FALSE;
|
|---|
| 5405 | }
|
|---|
| 5406 |
|
|---|
| 5407 | r = _bfd_final_link_relocate (howto,
|
|---|
| 5408 | input_bfd,
|
|---|
| 5409 | input_section,
|
|---|
| 5410 | contents,
|
|---|
| 5411 | rel->r_offset,
|
|---|
| 5412 | relocation,
|
|---|
| 5413 | addend);
|
|---|
| 5414 |
|
|---|
| 5415 | if (r != bfd_reloc_ok)
|
|---|
| 5416 | {
|
|---|
| 5417 | if (sym_name == NULL)
|
|---|
| 5418 | sym_name = "(null)";
|
|---|
| 5419 | if (r == bfd_reloc_overflow)
|
|---|
| 5420 | {
|
|---|
| 5421 | if (warned)
|
|---|
| 5422 | continue;
|
|---|
| 5423 | if (h != NULL
|
|---|
| 5424 | && h->root.type == bfd_link_hash_undefweak
|
|---|
| 5425 | && howto->pc_relative)
|
|---|
| 5426 | {
|
|---|
| 5427 | /* Assume this is a call protected by other code that
|
|---|
| 5428 | detect the symbol is undefined. If this is the case,
|
|---|
| 5429 | we can safely ignore the overflow. If not, the
|
|---|
| 5430 | program is hosed anyway, and a little warning isn't
|
|---|
| 5431 | going to help. */
|
|---|
| 5432 |
|
|---|
| 5433 | continue;
|
|---|
| 5434 | }
|
|---|
| 5435 |
|
|---|
| 5436 | if (! (*info->callbacks->reloc_overflow) (info,
|
|---|
| 5437 | sym_name,
|
|---|
| 5438 | howto->name,
|
|---|
| 5439 | rel->r_addend,
|
|---|
| 5440 | input_bfd,
|
|---|
| 5441 | input_section,
|
|---|
| 5442 | rel->r_offset))
|
|---|
| 5443 | return FALSE;
|
|---|
| 5444 | }
|
|---|
| 5445 | else
|
|---|
| 5446 | {
|
|---|
| 5447 | (*_bfd_error_handler)
|
|---|
| 5448 | (_("%s(%s+0x%lx): %s reloc against `%s': error %d"),
|
|---|
| 5449 | bfd_archive_filename (input_bfd),
|
|---|
| 5450 | bfd_get_section_name (input_bfd, input_section),
|
|---|
| 5451 | (long) rel->r_offset, howto->name, sym_name, (int) r);
|
|---|
| 5452 | ret = FALSE;
|
|---|
| 5453 | }
|
|---|
| 5454 | }
|
|---|
| 5455 | }
|
|---|
| 5456 |
|
|---|
| 5457 | #ifdef DEBUG
|
|---|
| 5458 | fprintf (stderr, "\n");
|
|---|
| 5459 | #endif
|
|---|
| 5460 |
|
|---|
| 5461 | return ret;
|
|---|
| 5462 | }
|
|---|
| 5463 |
|
|---|
| 5464 | static enum elf_reloc_type_class
|
|---|
| 5465 | ppc_elf_reloc_type_class (rela)
|
|---|
| 5466 | const Elf_Internal_Rela *rela;
|
|---|
| 5467 | {
|
|---|
| 5468 | switch ((int) ELF32_R_TYPE (rela->r_info))
|
|---|
| 5469 | {
|
|---|
| 5470 | case R_PPC_RELATIVE:
|
|---|
| 5471 | return reloc_class_relative;
|
|---|
| 5472 | case R_PPC_REL24:
|
|---|
| 5473 | case R_PPC_ADDR24:
|
|---|
| 5474 | case R_PPC_JMP_SLOT:
|
|---|
| 5475 | return reloc_class_plt;
|
|---|
| 5476 | case R_PPC_COPY:
|
|---|
| 5477 | return reloc_class_copy;
|
|---|
| 5478 | default:
|
|---|
| 5479 | return reloc_class_normal;
|
|---|
| 5480 | }
|
|---|
| 5481 | }
|
|---|
| 5482 | |
|---|
| 5483 |
|
|---|
| 5484 | /* Support for core dump NOTE sections. */
|
|---|
| 5485 |
|
|---|
| 5486 | static bfd_boolean
|
|---|
| 5487 | ppc_elf_grok_prstatus (abfd, note)
|
|---|
| 5488 | bfd *abfd;
|
|---|
| 5489 | Elf_Internal_Note *note;
|
|---|
| 5490 | {
|
|---|
| 5491 | int offset;
|
|---|
| 5492 | unsigned int raw_size;
|
|---|
| 5493 |
|
|---|
| 5494 | switch (note->descsz)
|
|---|
| 5495 | {
|
|---|
| 5496 | default:
|
|---|
| 5497 | return FALSE;
|
|---|
| 5498 |
|
|---|
| 5499 | case 268: /* Linux/PPC. */
|
|---|
| 5500 | /* pr_cursig */
|
|---|
| 5501 | elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
|
|---|
| 5502 |
|
|---|
| 5503 | /* pr_pid */
|
|---|
| 5504 | elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
|
|---|
| 5505 |
|
|---|
| 5506 | /* pr_reg */
|
|---|
| 5507 | offset = 72;
|
|---|
| 5508 | raw_size = 192;
|
|---|
| 5509 |
|
|---|
| 5510 | break;
|
|---|
| 5511 | }
|
|---|
| 5512 |
|
|---|
| 5513 | /* Make a ".reg/999" section. */
|
|---|
| 5514 | return _bfd_elfcore_make_pseudosection (abfd, ".reg",
|
|---|
| 5515 | raw_size, note->descpos + offset);
|
|---|
| 5516 | }
|
|---|
| 5517 |
|
|---|
| 5518 | static bfd_boolean
|
|---|
| 5519 | ppc_elf_grok_psinfo (abfd, note)
|
|---|
| 5520 | bfd *abfd;
|
|---|
| 5521 | Elf_Internal_Note *note;
|
|---|
| 5522 | {
|
|---|
| 5523 | switch (note->descsz)
|
|---|
| 5524 | {
|
|---|
| 5525 | default:
|
|---|
| 5526 | return FALSE;
|
|---|
| 5527 |
|
|---|
| 5528 | case 128: /* Linux/PPC elf_prpsinfo. */
|
|---|
| 5529 | elf_tdata (abfd)->core_program
|
|---|
| 5530 | = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
|
|---|
| 5531 | elf_tdata (abfd)->core_command
|
|---|
| 5532 | = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
|
|---|
| 5533 | }
|
|---|
| 5534 |
|
|---|
| 5535 | /* Note that for some reason, a spurious space is tacked
|
|---|
| 5536 | onto the end of the args in some (at least one anyway)
|
|---|
| 5537 | implementations, so strip it off if it exists. */
|
|---|
| 5538 |
|
|---|
| 5539 | {
|
|---|
| 5540 | char *command = elf_tdata (abfd)->core_command;
|
|---|
| 5541 | int n = strlen (command);
|
|---|
| 5542 |
|
|---|
| 5543 | if (0 < n && command[n - 1] == ' ')
|
|---|
| 5544 | command[n - 1] = '\0';
|
|---|
| 5545 | }
|
|---|
| 5546 |
|
|---|
| 5547 | return TRUE;
|
|---|
| 5548 | }
|
|---|
| 5549 | |
|---|
| 5550 |
|
|---|
| 5551 | /* Very simple linked list structure for recording apuinfo values. */
|
|---|
| 5552 | typedef struct apuinfo_list
|
|---|
| 5553 | {
|
|---|
| 5554 | struct apuinfo_list *next;
|
|---|
| 5555 | unsigned long value;
|
|---|
| 5556 | }
|
|---|
| 5557 | apuinfo_list;
|
|---|
| 5558 |
|
|---|
| 5559 | static apuinfo_list * head;
|
|---|
| 5560 |
|
|---|
| 5561 | static void apuinfo_list_init PARAMS ((void));
|
|---|
| 5562 | static void apuinfo_list_add PARAMS ((unsigned long));
|
|---|
| 5563 | static unsigned apuinfo_list_length PARAMS ((void));
|
|---|
| 5564 | static unsigned long apuinfo_list_element PARAMS ((unsigned long));
|
|---|
| 5565 | static void apuinfo_list_finish PARAMS ((void));
|
|---|
| 5566 |
|
|---|
| 5567 | extern void ppc_elf_begin_write_processing
|
|---|
| 5568 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 5569 | extern void ppc_elf_final_write_processing
|
|---|
| 5570 | PARAMS ((bfd *, bfd_boolean));
|
|---|
| 5571 | extern bfd_boolean ppc_elf_write_section
|
|---|
| 5572 | PARAMS ((bfd *, asection *, bfd_byte *));
|
|---|
| 5573 |
|
|---|
| 5574 |
|
|---|
| 5575 | static void
|
|---|
| 5576 | apuinfo_list_init PARAMS ((void))
|
|---|
| 5577 | {
|
|---|
| 5578 | head = NULL;
|
|---|
| 5579 | }
|
|---|
| 5580 |
|
|---|
| 5581 | static void
|
|---|
| 5582 | apuinfo_list_add (value)
|
|---|
| 5583 | unsigned long value;
|
|---|
| 5584 | {
|
|---|
| 5585 | apuinfo_list *entry = head;
|
|---|
| 5586 |
|
|---|
| 5587 | while (entry != NULL)
|
|---|
| 5588 | {
|
|---|
| 5589 | if (entry->value == value)
|
|---|
| 5590 | return;
|
|---|
| 5591 | entry = entry->next;
|
|---|
| 5592 | }
|
|---|
| 5593 |
|
|---|
| 5594 | entry = bfd_malloc (sizeof (* entry));
|
|---|
| 5595 | if (entry == NULL)
|
|---|
| 5596 | return;
|
|---|
| 5597 |
|
|---|
| 5598 | entry->value = value;
|
|---|
| 5599 | entry->next = head;
|
|---|
| 5600 | head = entry;
|
|---|
| 5601 | }
|
|---|
| 5602 |
|
|---|
| 5603 | static unsigned
|
|---|
| 5604 | apuinfo_list_length PARAMS ((void))
|
|---|
| 5605 | {
|
|---|
| 5606 | apuinfo_list *entry;
|
|---|
| 5607 | unsigned long count;
|
|---|
| 5608 |
|
|---|
| 5609 | for (entry = head, count = 0;
|
|---|
| 5610 | entry;
|
|---|
| 5611 | entry = entry->next)
|
|---|
| 5612 | ++ count;
|
|---|
| 5613 |
|
|---|
| 5614 | return count;
|
|---|
| 5615 | }
|
|---|
| 5616 |
|
|---|
| 5617 | static inline unsigned long
|
|---|
| 5618 | apuinfo_list_element (number)
|
|---|
| 5619 | unsigned long number;
|
|---|
| 5620 | {
|
|---|
| 5621 | apuinfo_list * entry;
|
|---|
| 5622 |
|
|---|
| 5623 | for (entry = head;
|
|---|
| 5624 | entry && number --;
|
|---|
| 5625 | entry = entry->next)
|
|---|
| 5626 | ;
|
|---|
| 5627 |
|
|---|
| 5628 | return entry ? entry->value : 0;
|
|---|
| 5629 | }
|
|---|
| 5630 |
|
|---|
| 5631 | static void
|
|---|
| 5632 | apuinfo_list_finish PARAMS ((void))
|
|---|
| 5633 | {
|
|---|
| 5634 | apuinfo_list *entry;
|
|---|
| 5635 |
|
|---|
| 5636 | for (entry = head; entry;)
|
|---|
| 5637 | {
|
|---|
| 5638 | apuinfo_list *next = entry->next;
|
|---|
| 5639 | free (entry);
|
|---|
| 5640 | entry = next;
|
|---|
| 5641 | }
|
|---|
| 5642 |
|
|---|
| 5643 | head = NULL;
|
|---|
| 5644 | }
|
|---|
| 5645 |
|
|---|
| 5646 | #define APUINFO_SECTION_NAME ".PPC.EMB.apuinfo"
|
|---|
| 5647 | #define APUINFO_LABEL "APUinfo"
|
|---|
| 5648 |
|
|---|
| 5649 | /* Scan the input BFDs and create a linked list of
|
|---|
| 5650 | the APUinfo values that will need to be emitted. */
|
|---|
| 5651 |
|
|---|
| 5652 | void
|
|---|
| 5653 | ppc_elf_begin_write_processing (abfd, link_info)
|
|---|
| 5654 | bfd *abfd;
|
|---|
| 5655 | struct bfd_link_info *link_info;
|
|---|
| 5656 | {
|
|---|
| 5657 | bfd *ibfd;
|
|---|
| 5658 | asection *asec;
|
|---|
| 5659 | char *buffer;
|
|---|
| 5660 | unsigned num_input_sections;
|
|---|
| 5661 | bfd_size_type output_section_size;
|
|---|
| 5662 | unsigned i;
|
|---|
| 5663 | unsigned num_entries;
|
|---|
| 5664 | unsigned long offset;
|
|---|
| 5665 | unsigned long length;
|
|---|
| 5666 | const char *error_message = NULL;
|
|---|
| 5667 |
|
|---|
| 5668 | if (link_info == NULL)
|
|---|
| 5669 | return;
|
|---|
| 5670 |
|
|---|
| 5671 | /* Scan the input bfds, looking for apuinfo sections. */
|
|---|
| 5672 | num_input_sections = 0;
|
|---|
| 5673 | output_section_size = 0;
|
|---|
| 5674 |
|
|---|
| 5675 | for (ibfd = link_info->input_bfds; ibfd; ibfd = ibfd->link_next)
|
|---|
| 5676 | {
|
|---|
| 5677 | asec = bfd_get_section_by_name (ibfd, APUINFO_SECTION_NAME);
|
|---|
| 5678 | if (asec)
|
|---|
| 5679 | {
|
|---|
| 5680 | ++ num_input_sections;
|
|---|
| 5681 | output_section_size += asec->_raw_size;
|
|---|
| 5682 | }
|
|---|
| 5683 | }
|
|---|
| 5684 |
|
|---|
| 5685 | /* We need at least one input sections
|
|---|
| 5686 | in order to make merging worthwhile. */
|
|---|
| 5687 | if (num_input_sections < 1)
|
|---|
| 5688 | return;
|
|---|
| 5689 |
|
|---|
| 5690 | /* Just make sure that the output section exists as well. */
|
|---|
| 5691 | asec = bfd_get_section_by_name (abfd, APUINFO_SECTION_NAME);
|
|---|
| 5692 | if (asec == NULL)
|
|---|
| 5693 | return;
|
|---|
| 5694 |
|
|---|
| 5695 | /* Allocate a buffer for the contents of the input sections. */
|
|---|
| 5696 | buffer = bfd_malloc (output_section_size);
|
|---|
| 5697 | if (buffer == NULL)
|
|---|
| 5698 | return;
|
|---|
| 5699 |
|
|---|
| 5700 | offset = 0;
|
|---|
| 5701 | apuinfo_list_init ();
|
|---|
| 5702 |
|
|---|
| 5703 | /* Read in the input sections contents. */
|
|---|
| 5704 | for (ibfd = link_info->input_bfds; ibfd; ibfd = ibfd->link_next)
|
|---|
| 5705 | {
|
|---|
| 5706 | unsigned long datum;
|
|---|
| 5707 | char *ptr;
|
|---|
| 5708 |
|
|---|
| 5709 | asec = bfd_get_section_by_name (ibfd, APUINFO_SECTION_NAME);
|
|---|
| 5710 | if (asec == NULL)
|
|---|
| 5711 | continue;
|
|---|
| 5712 |
|
|---|
| 5713 | length = asec->_raw_size;
|
|---|
| 5714 | if (length < 24)
|
|---|
| 5715 | {
|
|---|
| 5716 | error_message = _("corrupt or empty %s section in %s");
|
|---|
| 5717 | goto fail;
|
|---|
| 5718 | }
|
|---|
| 5719 |
|
|---|
| 5720 | if (bfd_seek (ibfd, asec->filepos, SEEK_SET) != 0
|
|---|
| 5721 | || (bfd_bread (buffer + offset, length, ibfd) != length))
|
|---|
| 5722 | {
|
|---|
| 5723 | error_message = _("unable to read in %s section from %s");
|
|---|
| 5724 | goto fail;
|
|---|
| 5725 | }
|
|---|
| 5726 |
|
|---|
| 5727 | /* Process the contents of the section. */
|
|---|
| 5728 | ptr = buffer + offset;
|
|---|
| 5729 | error_message = _("corrupt %s section in %s");
|
|---|
| 5730 |
|
|---|
| 5731 | /* Verify the contents of the header. Note - we have to
|
|---|
| 5732 | extract the values this way in order to allow for a
|
|---|
| 5733 | host whose endian-ness is different from the target. */
|
|---|
| 5734 | datum = bfd_get_32 (ibfd, ptr);
|
|---|
| 5735 | if (datum != sizeof APUINFO_LABEL)
|
|---|
| 5736 | goto fail;
|
|---|
| 5737 |
|
|---|
| 5738 | datum = bfd_get_32 (ibfd, ptr + 8);
|
|---|
| 5739 | if (datum != 0x2)
|
|---|
| 5740 | goto fail;
|
|---|
| 5741 |
|
|---|
| 5742 | if (strcmp (ptr + 12, APUINFO_LABEL) != 0)
|
|---|
| 5743 | goto fail;
|
|---|
| 5744 |
|
|---|
| 5745 | /* Get the number of apuinfo entries. */
|
|---|
| 5746 | datum = bfd_get_32 (ibfd, ptr + 4);
|
|---|
| 5747 | if ((datum * 4 + 20) != length)
|
|---|
| 5748 | goto fail;
|
|---|
| 5749 |
|
|---|
| 5750 | /* Make sure that we do not run off the end of the section. */
|
|---|
| 5751 | if (offset + length > output_section_size)
|
|---|
| 5752 | goto fail;
|
|---|
| 5753 |
|
|---|
| 5754 | /* Scan the apuinfo section, building a list of apuinfo numbers. */
|
|---|
| 5755 | for (i = 0; i < datum; i++)
|
|---|
| 5756 | apuinfo_list_add (bfd_get_32 (ibfd, ptr + 20 + (i * 4)));
|
|---|
| 5757 |
|
|---|
| 5758 | /* Update the offset. */
|
|---|
| 5759 | offset += length;
|
|---|
| 5760 | }
|
|---|
| 5761 |
|
|---|
| 5762 | error_message = NULL;
|
|---|
| 5763 |
|
|---|
| 5764 | /* Compute the size of the output section. */
|
|---|
| 5765 | num_entries = apuinfo_list_length ();
|
|---|
| 5766 | output_section_size = 20 + num_entries * 4;
|
|---|
| 5767 |
|
|---|
| 5768 | asec = bfd_get_section_by_name (abfd, APUINFO_SECTION_NAME);
|
|---|
| 5769 |
|
|---|
| 5770 | if (! bfd_set_section_size (abfd, asec, output_section_size))
|
|---|
| 5771 | ibfd = abfd,
|
|---|
| 5772 | error_message = _("warning: unable to set size of %s section in %s");
|
|---|
| 5773 |
|
|---|
| 5774 | fail:
|
|---|
| 5775 | free (buffer);
|
|---|
| 5776 |
|
|---|
| 5777 | if (error_message)
|
|---|
| 5778 | (*_bfd_error_handler) (error_message, APUINFO_SECTION_NAME,
|
|---|
| 5779 | bfd_archive_filename (ibfd));
|
|---|
| 5780 | }
|
|---|
| 5781 |
|
|---|
| 5782 |
|
|---|
| 5783 | /* Prevent the output section from accumulating the input sections'
|
|---|
| 5784 | contents. We have already stored this in our linked list structure. */
|
|---|
| 5785 |
|
|---|
| 5786 | bfd_boolean
|
|---|
| 5787 | ppc_elf_write_section (abfd, asec, contents)
|
|---|
| 5788 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 5789 | asection *asec;
|
|---|
| 5790 | bfd_byte *contents ATTRIBUTE_UNUSED;
|
|---|
| 5791 | {
|
|---|
| 5792 | return (apuinfo_list_length ()
|
|---|
| 5793 | && strcmp (asec->name, APUINFO_SECTION_NAME) == 0);
|
|---|
| 5794 | }
|
|---|
| 5795 |
|
|---|
| 5796 |
|
|---|
| 5797 | /* Finally we can generate the output section. */
|
|---|
| 5798 |
|
|---|
| 5799 | void
|
|---|
| 5800 | ppc_elf_final_write_processing (abfd, linker)
|
|---|
| 5801 | bfd *abfd;
|
|---|
| 5802 | bfd_boolean linker ATTRIBUTE_UNUSED;
|
|---|
| 5803 | {
|
|---|
| 5804 | bfd_byte *buffer;
|
|---|
| 5805 | asection *asec;
|
|---|
| 5806 | unsigned i;
|
|---|
| 5807 | unsigned num_entries;
|
|---|
| 5808 | bfd_size_type length;
|
|---|
| 5809 |
|
|---|
| 5810 | asec = bfd_get_section_by_name (abfd, APUINFO_SECTION_NAME);
|
|---|
| 5811 | if (asec == NULL)
|
|---|
| 5812 | return;
|
|---|
| 5813 |
|
|---|
| 5814 | if (apuinfo_list_length () == 0)
|
|---|
| 5815 | return;
|
|---|
| 5816 |
|
|---|
| 5817 | length = asec->_raw_size;
|
|---|
| 5818 | if (length < 20)
|
|---|
| 5819 | return;
|
|---|
| 5820 |
|
|---|
| 5821 | buffer = bfd_malloc (length);
|
|---|
| 5822 | if (buffer == NULL)
|
|---|
| 5823 | {
|
|---|
| 5824 | (*_bfd_error_handler)
|
|---|
| 5825 | (_("failed to allocate space for new APUinfo section."));
|
|---|
| 5826 | return;
|
|---|
| 5827 | }
|
|---|
| 5828 |
|
|---|
| 5829 | /* Create the apuinfo header. */
|
|---|
| 5830 | num_entries = apuinfo_list_length ();
|
|---|
| 5831 | bfd_put_32 (abfd, sizeof APUINFO_LABEL, buffer);
|
|---|
| 5832 | bfd_put_32 (abfd, num_entries, buffer + 4);
|
|---|
| 5833 | bfd_put_32 (abfd, 0x2, buffer + 8);
|
|---|
| 5834 | strcpy (buffer + 12, APUINFO_LABEL);
|
|---|
| 5835 |
|
|---|
| 5836 | length = 20;
|
|---|
| 5837 | for (i = 0; i < num_entries; i++)
|
|---|
| 5838 | {
|
|---|
| 5839 | bfd_put_32 (abfd, apuinfo_list_element (i), buffer + length);
|
|---|
| 5840 | length += 4;
|
|---|
| 5841 | }
|
|---|
| 5842 |
|
|---|
| 5843 | if (length != asec->_raw_size)
|
|---|
| 5844 | (*_bfd_error_handler) (_("failed to compute new APUinfo section."));
|
|---|
| 5845 |
|
|---|
| 5846 | if (! bfd_set_section_contents (abfd, asec, buffer, (file_ptr) 0, length))
|
|---|
| 5847 | (*_bfd_error_handler) (_("failed to install new APUinfo section."));
|
|---|
| 5848 |
|
|---|
| 5849 | free (buffer);
|
|---|
| 5850 |
|
|---|
| 5851 | apuinfo_list_finish ();
|
|---|
| 5852 | }
|
|---|
| 5853 | |
|---|
| 5854 |
|
|---|
| 5855 | #define TARGET_LITTLE_SYM bfd_elf32_powerpcle_vec
|
|---|
| 5856 | #define TARGET_LITTLE_NAME "elf32-powerpcle"
|
|---|
| 5857 | #define TARGET_BIG_SYM bfd_elf32_powerpc_vec
|
|---|
| 5858 | #define TARGET_BIG_NAME "elf32-powerpc"
|
|---|
| 5859 | #define ELF_ARCH bfd_arch_powerpc
|
|---|
| 5860 | #define ELF_MACHINE_CODE EM_PPC
|
|---|
| 5861 | #define ELF_MAXPAGESIZE 0x10000
|
|---|
| 5862 | #define elf_info_to_howto ppc_elf_info_to_howto
|
|---|
| 5863 |
|
|---|
| 5864 | #ifdef EM_CYGNUS_POWERPC
|
|---|
| 5865 | #define ELF_MACHINE_ALT1 EM_CYGNUS_POWERPC
|
|---|
| 5866 | #endif
|
|---|
| 5867 |
|
|---|
| 5868 | #ifdef EM_PPC_OLD
|
|---|
| 5869 | #define ELF_MACHINE_ALT2 EM_PPC_OLD
|
|---|
| 5870 | #endif
|
|---|
| 5871 |
|
|---|
| 5872 | #define elf_backend_plt_not_loaded 1
|
|---|
| 5873 | #define elf_backend_got_symbol_offset 4
|
|---|
| 5874 | #define elf_backend_can_gc_sections 1
|
|---|
| 5875 | #define elf_backend_can_refcount 1
|
|---|
| 5876 | #define elf_backend_got_header_size 12
|
|---|
| 5877 | #define elf_backend_plt_header_size PLT_INITIAL_ENTRY_SIZE
|
|---|
| 5878 | #define elf_backend_rela_normal 1
|
|---|
| 5879 |
|
|---|
| 5880 | #define bfd_elf32_bfd_merge_private_bfd_data ppc_elf_merge_private_bfd_data
|
|---|
| 5881 | #define bfd_elf32_bfd_relax_section ppc_elf_relax_section
|
|---|
| 5882 | #define bfd_elf32_bfd_reloc_type_lookup ppc_elf_reloc_type_lookup
|
|---|
| 5883 | #define bfd_elf32_bfd_set_private_flags ppc_elf_set_private_flags
|
|---|
| 5884 | #define bfd_elf32_bfd_link_hash_table_create ppc_elf_link_hash_table_create
|
|---|
| 5885 |
|
|---|
| 5886 | #define elf_backend_object_p ppc_elf_object_p
|
|---|
| 5887 | #define elf_backend_gc_mark_hook ppc_elf_gc_mark_hook
|
|---|
| 5888 | #define elf_backend_gc_sweep_hook ppc_elf_gc_sweep_hook
|
|---|
| 5889 | #define elf_backend_section_from_shdr ppc_elf_section_from_shdr
|
|---|
| 5890 | #define elf_backend_relocate_section ppc_elf_relocate_section
|
|---|
| 5891 | #define elf_backend_create_dynamic_sections ppc_elf_create_dynamic_sections
|
|---|
| 5892 | #define elf_backend_check_relocs ppc_elf_check_relocs
|
|---|
| 5893 | #define elf_backend_copy_indirect_symbol ppc_elf_copy_indirect_symbol
|
|---|
| 5894 | #define elf_backend_adjust_dynamic_symbol ppc_elf_adjust_dynamic_symbol
|
|---|
| 5895 | #define elf_backend_add_symbol_hook ppc_elf_add_symbol_hook
|
|---|
| 5896 | #define elf_backend_size_dynamic_sections ppc_elf_size_dynamic_sections
|
|---|
| 5897 | #define elf_backend_finish_dynamic_symbol ppc_elf_finish_dynamic_symbol
|
|---|
| 5898 | #define elf_backend_finish_dynamic_sections ppc_elf_finish_dynamic_sections
|
|---|
| 5899 | #define elf_backend_fake_sections ppc_elf_fake_sections
|
|---|
| 5900 | #define elf_backend_additional_program_headers ppc_elf_additional_program_headers
|
|---|
| 5901 | #define elf_backend_modify_segment_map ppc_elf_modify_segment_map
|
|---|
| 5902 | #define elf_backend_grok_prstatus ppc_elf_grok_prstatus
|
|---|
| 5903 | #define elf_backend_grok_psinfo ppc_elf_grok_psinfo
|
|---|
| 5904 | #define elf_backend_reloc_type_class ppc_elf_reloc_type_class
|
|---|
| 5905 | #define elf_backend_begin_write_processing ppc_elf_begin_write_processing
|
|---|
| 5906 | #define elf_backend_final_write_processing ppc_elf_final_write_processing
|
|---|
| 5907 | #define elf_backend_write_section ppc_elf_write_section
|
|---|
| 5908 |
|
|---|
| 5909 | #include "elf32-target.h"
|
|---|