| 1 |
/* PowerPC-specific support for 32-bit ELF |
| 2 |
Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, |
| 3 |
2004, 2005, 2006, 2007, 2008, 2009 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 3 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., 51 Franklin Street - Fifth Floor, |
| 21 |
Boston, MA 02110-1301, USA. */ |
| 22 |
|
| 23 |
|
| 24 |
/* This file is based on a preliminary PowerPC ELF ABI. The |
| 25 |
information may not match the final PowerPC ELF ABI. It includes |
| 26 |
suggestions from the in-progress Embedded PowerPC ABI, and that |
| 27 |
information may also not match. */ |
| 28 |
|
| 29 |
#include "sysdep.h" |
| 30 |
#include <stdarg.h> |
| 31 |
#include "bfd.h" |
| 32 |
#include "bfdlink.h" |
| 33 |
#include "libbfd.h" |
| 34 |
#include "elf-bfd.h" |
| 35 |
#include "elf/ppc.h" |
| 36 |
#include "elf32-ppc.h" |
| 37 |
#include "elf-vxworks.h" |
| 38 |
|
| 39 |
/* RELA relocations are used here. */ |
| 40 |
|
| 41 |
static bfd_reloc_status_type ppc_elf_addr16_ha_reloc |
| 42 |
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); |
| 43 |
static bfd_reloc_status_type ppc_elf_unhandled_reloc |
| 44 |
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); |
| 45 |
|
| 46 |
/* Branch prediction bit for branch taken relocs. */ |
| 47 |
#define BRANCH_PREDICT_BIT 0x200000 |
| 48 |
/* Mask to set RA in memory instructions. */ |
| 49 |
#define RA_REGISTER_MASK 0x001f0000 |
| 50 |
/* Value to shift register by to insert RA. */ |
| 51 |
#define RA_REGISTER_SHIFT 16 |
| 52 |
|
| 53 |
/* The name of the dynamic interpreter. This is put in the .interp |
| 54 |
section. */ |
| 55 |
#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" |
| 56 |
|
| 57 |
/* For old-style PLT. */ |
| 58 |
/* The number of single-slot PLT entries (the rest use two slots). */ |
| 59 |
#define PLT_NUM_SINGLE_ENTRIES 8192 |
| 60 |
|
| 61 |
/* For new-style .glink and .plt. */ |
| 62 |
#define GLINK_PLTRESOLVE 16*4 |
| 63 |
#define GLINK_ENTRY_SIZE 4*4 |
| 64 |
|
| 65 |
/* VxWorks uses its own plt layout, filled in by the static linker. */ |
| 66 |
|
| 67 |
/* The standard VxWorks PLT entry. */ |
| 68 |
#define VXWORKS_PLT_ENTRY_SIZE 32 |
| 69 |
static const bfd_vma ppc_elf_vxworks_plt_entry |
| 70 |
[VXWORKS_PLT_ENTRY_SIZE / 4] = |
| 71 |
{ |
| 72 |
0x3d800000, /* lis r12,0 */ |
| 73 |
0x818c0000, /* lwz r12,0(r12) */ |
| 74 |
0x7d8903a6, /* mtctr r12 */ |
| 75 |
0x4e800420, /* bctr */ |
| 76 |
0x39600000, /* li r11,0 */ |
| 77 |
0x48000000, /* b 14 <.PLT0resolve+0x4> */ |
| 78 |
0x60000000, /* nop */ |
| 79 |
0x60000000, /* nop */ |
| 80 |
}; |
| 81 |
static const bfd_vma ppc_elf_vxworks_pic_plt_entry |
| 82 |
[VXWORKS_PLT_ENTRY_SIZE / 4] = |
| 83 |
{ |
| 84 |
0x3d9e0000, /* addis r12,r30,0 */ |
| 85 |
0x818c0000, /* lwz r12,0(r12) */ |
| 86 |
0x7d8903a6, /* mtctr r12 */ |
| 87 |
0x4e800420, /* bctr */ |
| 88 |
0x39600000, /* li r11,0 */ |
| 89 |
0x48000000, /* b 14 <.PLT0resolve+0x4> 14: R_PPC_REL24 .PLTresolve */ |
| 90 |
0x60000000, /* nop */ |
| 91 |
0x60000000, /* nop */ |
| 92 |
}; |
| 93 |
|
| 94 |
/* The initial VxWorks PLT entry. */ |
| 95 |
#define VXWORKS_PLT_INITIAL_ENTRY_SIZE 32 |
| 96 |
static const bfd_vma ppc_elf_vxworks_plt0_entry |
| 97 |
[VXWORKS_PLT_INITIAL_ENTRY_SIZE / 4] = |
| 98 |
{ |
| 99 |
0x3d800000, /* lis r12,0 */ |
| 100 |
0x398c0000, /* addi r12,r12,0 */ |
| 101 |
0x800c0008, /* lwz r0,8(r12) */ |
| 102 |
0x7c0903a6, /* mtctr r0 */ |
| 103 |
0x818c0004, /* lwz r12,4(r12) */ |
| 104 |
0x4e800420, /* bctr */ |
| 105 |
0x60000000, /* nop */ |
| 106 |
0x60000000, /* nop */ |
| 107 |
}; |
| 108 |
static const bfd_vma ppc_elf_vxworks_pic_plt0_entry |
| 109 |
[VXWORKS_PLT_INITIAL_ENTRY_SIZE / 4] = |
| 110 |
{ |
| 111 |
0x819e0008, /* lwz r12,8(r30) */ |
| 112 |
0x7d8903a6, /* mtctr r12 */ |
| 113 |
0x819e0004, /* lwz r12,4(r30) */ |
| 114 |
0x4e800420, /* bctr */ |
| 115 |
0x60000000, /* nop */ |
| 116 |
0x60000000, /* nop */ |
| 117 |
0x60000000, /* nop */ |
| 118 |
0x60000000, /* nop */ |
| 119 |
}; |
| 120 |
|
| 121 |
/* For executables, we have some additional relocations in |
| 122 |
.rela.plt.unloaded, for the kernel loader. */ |
| 123 |
|
| 124 |
/* The number of non-JMP_SLOT relocations per PLT0 slot. */ |
| 125 |
#define VXWORKS_PLT_NON_JMP_SLOT_RELOCS 3 |
| 126 |
/* The number of relocations in the PLTResolve slot. */ |
| 127 |
#define VXWORKS_PLTRESOLVE_RELOCS 2 |
| 128 |
/* The number of relocations in the PLTResolve slot when when creating |
| 129 |
a shared library. */ |
| 130 |
#define VXWORKS_PLTRESOLVE_RELOCS_SHLIB 0 |
| 131 |
|
| 132 |
/* Some instructions. */ |
| 133 |
#define ADDIS_11_11 0x3d6b0000 |
| 134 |
#define ADDIS_11_30 0x3d7e0000 |
| 135 |
#define ADDIS_12_12 0x3d8c0000 |
| 136 |
#define ADDI_11_11 0x396b0000 |
| 137 |
#define ADD_0_11_11 0x7c0b5a14 |
| 138 |
#define ADD_11_0_11 0x7d605a14 |
| 139 |
#define B 0x48000000 |
| 140 |
#define BCL_20_31 0x429f0005 |
| 141 |
#define BCTR 0x4e800420 |
| 142 |
#define LIS_11 0x3d600000 |
| 143 |
#define LIS_12 0x3d800000 |
| 144 |
#define LWZU_0_12 0x840c0000 |
| 145 |
#define LWZ_0_12 0x800c0000 |
| 146 |
#define LWZ_11_11 0x816b0000 |
| 147 |
#define LWZ_11_30 0x817e0000 |
| 148 |
#define LWZ_12_12 0x818c0000 |
| 149 |
#define MFLR_0 0x7c0802a6 |
| 150 |
#define MFLR_12 0x7d8802a6 |
| 151 |
#define MTCTR_0 0x7c0903a6 |
| 152 |
#define MTCTR_11 0x7d6903a6 |
| 153 |
#define MTLR_0 0x7c0803a6 |
| 154 |
#define NOP 0x60000000 |
| 155 |
#define SUB_11_11_12 0x7d6c5850 |
| 156 |
|
| 157 |
/* Offset of tp and dtp pointers from start of TLS block. */ |
| 158 |
#define TP_OFFSET 0x7000 |
| 159 |
#define DTP_OFFSET 0x8000 |
| 160 |
|
| 161 |
/* The value of a defined global symbol. */ |
| 162 |
#define SYM_VAL(SYM) \ |
| 163 |
((SYM)->root.u.def.section->output_section->vma \ |
| 164 |
+ (SYM)->root.u.def.section->output_offset \ |
| 165 |
+ (SYM)->root.u.def.value) |
| 166 |
|
| 167 |
static reloc_howto_type *ppc_elf_howto_table[R_PPC_max]; |
| 168 |
|
| 169 |
static reloc_howto_type ppc_elf_howto_raw[] = { |
| 170 |
/* This reloc does nothing. */ |
| 171 |
HOWTO (R_PPC_NONE, /* type */ |
| 172 |
0, /* rightshift */ |
| 173 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 174 |
32, /* bitsize */ |
| 175 |
FALSE, /* pc_relative */ |
| 176 |
0, /* bitpos */ |
| 177 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 178 |
bfd_elf_generic_reloc, /* special_function */ |
| 179 |
"R_PPC_NONE", /* name */ |
| 180 |
FALSE, /* partial_inplace */ |
| 181 |
0, /* src_mask */ |
| 182 |
0, /* dst_mask */ |
| 183 |
FALSE), /* pcrel_offset */ |
| 184 |
|
| 185 |
/* A standard 32 bit relocation. */ |
| 186 |
HOWTO (R_PPC_ADDR32, /* type */ |
| 187 |
0, /* rightshift */ |
| 188 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 189 |
32, /* bitsize */ |
| 190 |
FALSE, /* pc_relative */ |
| 191 |
0, /* bitpos */ |
| 192 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 193 |
bfd_elf_generic_reloc, /* special_function */ |
| 194 |
"R_PPC_ADDR32", /* name */ |
| 195 |
FALSE, /* partial_inplace */ |
| 196 |
0, /* src_mask */ |
| 197 |
0xffffffff, /* dst_mask */ |
| 198 |
FALSE), /* pcrel_offset */ |
| 199 |
|
| 200 |
/* An absolute 26 bit branch; the lower two bits must be zero. |
| 201 |
FIXME: we don't check that, we just clear them. */ |
| 202 |
HOWTO (R_PPC_ADDR24, /* type */ |
| 203 |
0, /* rightshift */ |
| 204 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 205 |
26, /* bitsize */ |
| 206 |
FALSE, /* pc_relative */ |
| 207 |
0, /* bitpos */ |
| 208 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 209 |
bfd_elf_generic_reloc, /* special_function */ |
| 210 |
"R_PPC_ADDR24", /* name */ |
| 211 |
FALSE, /* partial_inplace */ |
| 212 |
0, /* src_mask */ |
| 213 |
0x3fffffc, /* dst_mask */ |
| 214 |
FALSE), /* pcrel_offset */ |
| 215 |
|
| 216 |
/* A standard 16 bit relocation. */ |
| 217 |
HOWTO (R_PPC_ADDR16, /* type */ |
| 218 |
0, /* rightshift */ |
| 219 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 220 |
16, /* bitsize */ |
| 221 |
FALSE, /* pc_relative */ |
| 222 |
0, /* bitpos */ |
| 223 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 224 |
bfd_elf_generic_reloc, /* special_function */ |
| 225 |
"R_PPC_ADDR16", /* name */ |
| 226 |
FALSE, /* partial_inplace */ |
| 227 |
0, /* src_mask */ |
| 228 |
0xffff, /* dst_mask */ |
| 229 |
FALSE), /* pcrel_offset */ |
| 230 |
|
| 231 |
/* A 16 bit relocation without overflow. */ |
| 232 |
HOWTO (R_PPC_ADDR16_LO, /* type */ |
| 233 |
0, /* rightshift */ |
| 234 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 235 |
16, /* bitsize */ |
| 236 |
FALSE, /* pc_relative */ |
| 237 |
0, /* bitpos */ |
| 238 |
complain_overflow_dont,/* complain_on_overflow */ |
| 239 |
bfd_elf_generic_reloc, /* special_function */ |
| 240 |
"R_PPC_ADDR16_LO", /* name */ |
| 241 |
FALSE, /* partial_inplace */ |
| 242 |
0, /* src_mask */ |
| 243 |
0xffff, /* dst_mask */ |
| 244 |
FALSE), /* pcrel_offset */ |
| 245 |
|
| 246 |
/* The high order 16 bits of an address. */ |
| 247 |
HOWTO (R_PPC_ADDR16_HI, /* type */ |
| 248 |
16, /* rightshift */ |
| 249 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 250 |
16, /* bitsize */ |
| 251 |
FALSE, /* pc_relative */ |
| 252 |
0, /* bitpos */ |
| 253 |
complain_overflow_dont, /* complain_on_overflow */ |
| 254 |
bfd_elf_generic_reloc, /* special_function */ |
| 255 |
"R_PPC_ADDR16_HI", /* name */ |
| 256 |
FALSE, /* partial_inplace */ |
| 257 |
0, /* src_mask */ |
| 258 |
0xffff, /* dst_mask */ |
| 259 |
FALSE), /* pcrel_offset */ |
| 260 |
|
| 261 |
/* The high order 16 bits of an address, plus 1 if the contents of |
| 262 |
the low 16 bits, treated as a signed number, is negative. */ |
| 263 |
HOWTO (R_PPC_ADDR16_HA, /* type */ |
| 264 |
16, /* rightshift */ |
| 265 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 266 |
16, /* bitsize */ |
| 267 |
FALSE, /* pc_relative */ |
| 268 |
0, /* bitpos */ |
| 269 |
complain_overflow_dont, /* complain_on_overflow */ |
| 270 |
ppc_elf_addr16_ha_reloc, /* special_function */ |
| 271 |
"R_PPC_ADDR16_HA", /* name */ |
| 272 |
FALSE, /* partial_inplace */ |
| 273 |
0, /* src_mask */ |
| 274 |
0xffff, /* dst_mask */ |
| 275 |
FALSE), /* pcrel_offset */ |
| 276 |
|
| 277 |
/* An absolute 16 bit branch; the lower two bits must be zero. |
| 278 |
FIXME: we don't check that, we just clear them. */ |
| 279 |
HOWTO (R_PPC_ADDR14, /* type */ |
| 280 |
0, /* rightshift */ |
| 281 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 282 |
16, /* bitsize */ |
| 283 |
FALSE, /* pc_relative */ |
| 284 |
0, /* bitpos */ |
| 285 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 286 |
bfd_elf_generic_reloc, /* special_function */ |
| 287 |
"R_PPC_ADDR14", /* name */ |
| 288 |
FALSE, /* partial_inplace */ |
| 289 |
0, /* src_mask */ |
| 290 |
0xfffc, /* dst_mask */ |
| 291 |
FALSE), /* pcrel_offset */ |
| 292 |
|
| 293 |
/* An absolute 16 bit branch, for which bit 10 should be set to |
| 294 |
indicate that the branch is expected to be taken. The lower two |
| 295 |
bits must be zero. */ |
| 296 |
HOWTO (R_PPC_ADDR14_BRTAKEN, /* type */ |
| 297 |
0, /* rightshift */ |
| 298 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 299 |
16, /* bitsize */ |
| 300 |
FALSE, /* pc_relative */ |
| 301 |
0, /* bitpos */ |
| 302 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 303 |
bfd_elf_generic_reloc, /* special_function */ |
| 304 |
"R_PPC_ADDR14_BRTAKEN",/* name */ |
| 305 |
FALSE, /* partial_inplace */ |
| 306 |
0, /* src_mask */ |
| 307 |
0xfffc, /* dst_mask */ |
| 308 |
FALSE), /* pcrel_offset */ |
| 309 |
|
| 310 |
/* An absolute 16 bit branch, for which bit 10 should be set to |
| 311 |
indicate that the branch is not expected to be taken. The lower |
| 312 |
two bits must be zero. */ |
| 313 |
HOWTO (R_PPC_ADDR14_BRNTAKEN, /* type */ |
| 314 |
0, /* rightshift */ |
| 315 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 316 |
16, /* bitsize */ |
| 317 |
FALSE, /* pc_relative */ |
| 318 |
0, /* bitpos */ |
| 319 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 320 |
bfd_elf_generic_reloc, /* special_function */ |
| 321 |
"R_PPC_ADDR14_BRNTAKEN",/* name */ |
| 322 |
FALSE, /* partial_inplace */ |
| 323 |
0, /* src_mask */ |
| 324 |
0xfffc, /* dst_mask */ |
| 325 |
FALSE), /* pcrel_offset */ |
| 326 |
|
| 327 |
/* A relative 26 bit branch; the lower two bits must be zero. */ |
| 328 |
HOWTO (R_PPC_REL24, /* type */ |
| 329 |
0, /* rightshift */ |
| 330 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 331 |
26, /* bitsize */ |
| 332 |
TRUE, /* pc_relative */ |
| 333 |
0, /* bitpos */ |
| 334 |
complain_overflow_signed, /* complain_on_overflow */ |
| 335 |
bfd_elf_generic_reloc, /* special_function */ |
| 336 |
"R_PPC_REL24", /* name */ |
| 337 |
FALSE, /* partial_inplace */ |
| 338 |
0, /* src_mask */ |
| 339 |
0x3fffffc, /* dst_mask */ |
| 340 |
TRUE), /* pcrel_offset */ |
| 341 |
|
| 342 |
/* A relative 16 bit branch; the lower two bits must be zero. */ |
| 343 |
HOWTO (R_PPC_REL14, /* type */ |
| 344 |
0, /* rightshift */ |
| 345 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 346 |
16, /* bitsize */ |
| 347 |
TRUE, /* pc_relative */ |
| 348 |
0, /* bitpos */ |
| 349 |
complain_overflow_signed, /* complain_on_overflow */ |
| 350 |
bfd_elf_generic_reloc, /* special_function */ |
| 351 |
"R_PPC_REL14", /* name */ |
| 352 |
FALSE, /* partial_inplace */ |
| 353 |
0, /* src_mask */ |
| 354 |
0xfffc, /* dst_mask */ |
| 355 |
TRUE), /* pcrel_offset */ |
| 356 |
|
| 357 |
/* A relative 16 bit branch. Bit 10 should be set to indicate that |
| 358 |
the branch is expected to be taken. The lower two bits must be |
| 359 |
zero. */ |
| 360 |
HOWTO (R_PPC_REL14_BRTAKEN, /* type */ |
| 361 |
0, /* rightshift */ |
| 362 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 363 |
16, /* bitsize */ |
| 364 |
TRUE, /* pc_relative */ |
| 365 |
0, /* bitpos */ |
| 366 |
complain_overflow_signed, /* complain_on_overflow */ |
| 367 |
bfd_elf_generic_reloc, /* special_function */ |
| 368 |
"R_PPC_REL14_BRTAKEN", /* name */ |
| 369 |
FALSE, /* partial_inplace */ |
| 370 |
0, /* src_mask */ |
| 371 |
0xfffc, /* dst_mask */ |
| 372 |
TRUE), /* pcrel_offset */ |
| 373 |
|
| 374 |
/* A relative 16 bit branch. Bit 10 should be set to indicate that |
| 375 |
the branch is not expected to be taken. The lower two bits must |
| 376 |
be zero. */ |
| 377 |
HOWTO (R_PPC_REL14_BRNTAKEN, /* type */ |
| 378 |
0, /* rightshift */ |
| 379 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 380 |
16, /* bitsize */ |
| 381 |
TRUE, /* pc_relative */ |
| 382 |
0, /* bitpos */ |
| 383 |
complain_overflow_signed, /* complain_on_overflow */ |
| 384 |
bfd_elf_generic_reloc, /* special_function */ |
| 385 |
"R_PPC_REL14_BRNTAKEN",/* name */ |
| 386 |
FALSE, /* partial_inplace */ |
| 387 |
0, /* src_mask */ |
| 388 |
0xfffc, /* dst_mask */ |
| 389 |
TRUE), /* pcrel_offset */ |
| 390 |
|
| 391 |
/* Like R_PPC_ADDR16, but referring to the GOT table entry for the |
| 392 |
symbol. */ |
| 393 |
HOWTO (R_PPC_GOT16, /* type */ |
| 394 |
0, /* rightshift */ |
| 395 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 396 |
16, /* bitsize */ |
| 397 |
FALSE, /* pc_relative */ |
| 398 |
0, /* bitpos */ |
| 399 |
complain_overflow_signed, /* complain_on_overflow */ |
| 400 |
bfd_elf_generic_reloc, /* special_function */ |
| 401 |
"R_PPC_GOT16", /* name */ |
| 402 |
FALSE, /* partial_inplace */ |
| 403 |
0, /* src_mask */ |
| 404 |
0xffff, /* dst_mask */ |
| 405 |
FALSE), /* pcrel_offset */ |
| 406 |
|
| 407 |
/* Like R_PPC_ADDR16_LO, but referring to the GOT table entry for |
| 408 |
the symbol. */ |
| 409 |
HOWTO (R_PPC_GOT16_LO, /* type */ |
| 410 |
0, /* rightshift */ |
| 411 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 412 |
16, /* bitsize */ |
| 413 |
FALSE, /* pc_relative */ |
| 414 |
0, /* bitpos */ |
| 415 |
complain_overflow_dont, /* complain_on_overflow */ |
| 416 |
bfd_elf_generic_reloc, /* special_function */ |
| 417 |
"R_PPC_GOT16_LO", /* name */ |
| 418 |
FALSE, /* partial_inplace */ |
| 419 |
0, /* src_mask */ |
| 420 |
0xffff, /* dst_mask */ |
| 421 |
FALSE), /* pcrel_offset */ |
| 422 |
|
| 423 |
/* Like R_PPC_ADDR16_HI, but referring to the GOT table entry for |
| 424 |
the symbol. */ |
| 425 |
HOWTO (R_PPC_GOT16_HI, /* type */ |
| 426 |
16, /* rightshift */ |
| 427 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 428 |
16, /* bitsize */ |
| 429 |
FALSE, /* pc_relative */ |
| 430 |
0, /* bitpos */ |
| 431 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 432 |
bfd_elf_generic_reloc, /* special_function */ |
| 433 |
"R_PPC_GOT16_HI", /* name */ |
| 434 |
FALSE, /* partial_inplace */ |
| 435 |
0, /* src_mask */ |
| 436 |
0xffff, /* dst_mask */ |
| 437 |
FALSE), /* pcrel_offset */ |
| 438 |
|
| 439 |
/* Like R_PPC_ADDR16_HA, but referring to the GOT table entry for |
| 440 |
the symbol. */ |
| 441 |
HOWTO (R_PPC_GOT16_HA, /* type */ |
| 442 |
16, /* rightshift */ |
| 443 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 444 |
16, /* bitsize */ |
| 445 |
FALSE, /* pc_relative */ |
| 446 |
0, /* bitpos */ |
| 447 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 448 |
ppc_elf_addr16_ha_reloc, /* special_function */ |
| 449 |
"R_PPC_GOT16_HA", /* name */ |
| 450 |
FALSE, /* partial_inplace */ |
| 451 |
0, /* src_mask */ |
| 452 |
0xffff, /* dst_mask */ |
| 453 |
FALSE), /* pcrel_offset */ |
| 454 |
|
| 455 |
/* Like R_PPC_REL24, but referring to the procedure linkage table |
| 456 |
entry for the symbol. */ |
| 457 |
HOWTO (R_PPC_PLTREL24, /* type */ |
| 458 |
0, /* rightshift */ |
| 459 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 460 |
26, /* bitsize */ |
| 461 |
TRUE, /* pc_relative */ |
| 462 |
0, /* bitpos */ |
| 463 |
complain_overflow_signed, /* complain_on_overflow */ |
| 464 |
bfd_elf_generic_reloc, /* special_function */ |
| 465 |
"R_PPC_PLTREL24", /* name */ |
| 466 |
FALSE, /* partial_inplace */ |
| 467 |
0, /* src_mask */ |
| 468 |
0x3fffffc, /* dst_mask */ |
| 469 |
TRUE), /* pcrel_offset */ |
| 470 |
|
| 471 |
/* This is used only by the dynamic linker. The symbol should exist |
| 472 |
both in the object being run and in some shared library. The |
| 473 |
dynamic linker copies the data addressed by the symbol from the |
| 474 |
shared library into the object, because the object being |
| 475 |
run has to have the data at some particular address. */ |
| 476 |
HOWTO (R_PPC_COPY, /* type */ |
| 477 |
0, /* rightshift */ |
| 478 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 479 |
32, /* bitsize */ |
| 480 |
FALSE, /* pc_relative */ |
| 481 |
0, /* bitpos */ |
| 482 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 483 |
bfd_elf_generic_reloc, /* special_function */ |
| 484 |
"R_PPC_COPY", /* name */ |
| 485 |
FALSE, /* partial_inplace */ |
| 486 |
0, /* src_mask */ |
| 487 |
0, /* dst_mask */ |
| 488 |
FALSE), /* pcrel_offset */ |
| 489 |
|
| 490 |
/* Like R_PPC_ADDR32, but used when setting global offset table |
| 491 |
entries. */ |
| 492 |
HOWTO (R_PPC_GLOB_DAT, /* type */ |
| 493 |
0, /* rightshift */ |
| 494 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 495 |
32, /* bitsize */ |
| 496 |
FALSE, /* pc_relative */ |
| 497 |
0, /* bitpos */ |
| 498 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 499 |
bfd_elf_generic_reloc, /* special_function */ |
| 500 |
"R_PPC_GLOB_DAT", /* name */ |
| 501 |
FALSE, /* partial_inplace */ |
| 502 |
0, /* src_mask */ |
| 503 |
0xffffffff, /* dst_mask */ |
| 504 |
FALSE), /* pcrel_offset */ |
| 505 |
|
| 506 |
/* Marks a procedure linkage table entry for a symbol. */ |
| 507 |
HOWTO (R_PPC_JMP_SLOT, /* type */ |
| 508 |
0, /* rightshift */ |
| 509 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 510 |
32, /* bitsize */ |
| 511 |
FALSE, /* pc_relative */ |
| 512 |
0, /* bitpos */ |
| 513 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 514 |
bfd_elf_generic_reloc, /* special_function */ |
| 515 |
"R_PPC_JMP_SLOT", /* name */ |
| 516 |
FALSE, /* partial_inplace */ |
| 517 |
0, /* src_mask */ |
| 518 |
0, /* dst_mask */ |
| 519 |
FALSE), /* pcrel_offset */ |
| 520 |
|
| 521 |
/* Used only by the dynamic linker. When the object is run, this |
| 522 |
longword is set to the load address of the object, plus the |
| 523 |
addend. */ |
| 524 |
HOWTO (R_PPC_RELATIVE, /* type */ |
| 525 |
0, /* rightshift */ |
| 526 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 527 |
32, /* bitsize */ |
| 528 |
FALSE, /* pc_relative */ |
| 529 |
0, /* bitpos */ |
| 530 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 531 |
bfd_elf_generic_reloc, /* special_function */ |
| 532 |
"R_PPC_RELATIVE", /* name */ |
| 533 |
FALSE, /* partial_inplace */ |
| 534 |
0, /* src_mask */ |
| 535 |
0xffffffff, /* dst_mask */ |
| 536 |
FALSE), /* pcrel_offset */ |
| 537 |
|
| 538 |
/* Like R_PPC_REL24, but uses the value of the symbol within the |
| 539 |
object rather than the final value. Normally used for |
| 540 |
_GLOBAL_OFFSET_TABLE_. */ |
| 541 |
HOWTO (R_PPC_LOCAL24PC, /* type */ |
| 542 |
0, /* rightshift */ |
| 543 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 544 |
26, /* bitsize */ |
| 545 |
TRUE, /* pc_relative */ |
| 546 |
0, /* bitpos */ |
| 547 |
complain_overflow_signed, /* complain_on_overflow */ |
| 548 |
bfd_elf_generic_reloc, /* special_function */ |
| 549 |
"R_PPC_LOCAL24PC", /* name */ |
| 550 |
FALSE, /* partial_inplace */ |
| 551 |
0, /* src_mask */ |
| 552 |
0x3fffffc, /* dst_mask */ |
| 553 |
TRUE), /* pcrel_offset */ |
| 554 |
|
| 555 |
/* Like R_PPC_ADDR32, but may be unaligned. */ |
| 556 |
HOWTO (R_PPC_UADDR32, /* type */ |
| 557 |
0, /* rightshift */ |
| 558 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 559 |
32, /* bitsize */ |
| 560 |
FALSE, /* pc_relative */ |
| 561 |
0, /* bitpos */ |
| 562 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 563 |
bfd_elf_generic_reloc, /* special_function */ |
| 564 |
"R_PPC_UADDR32", /* name */ |
| 565 |
FALSE, /* partial_inplace */ |
| 566 |
0, /* src_mask */ |
| 567 |
0xffffffff, /* dst_mask */ |
| 568 |
FALSE), /* pcrel_offset */ |
| 569 |
|
| 570 |
/* Like R_PPC_ADDR16, but may be unaligned. */ |
| 571 |
HOWTO (R_PPC_UADDR16, /* type */ |
| 572 |
0, /* rightshift */ |
| 573 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 574 |
16, /* bitsize */ |
| 575 |
FALSE, /* pc_relative */ |
| 576 |
0, /* bitpos */ |
| 577 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 578 |
bfd_elf_generic_reloc, /* special_function */ |
| 579 |
"R_PPC_UADDR16", /* name */ |
| 580 |
FALSE, /* partial_inplace */ |
| 581 |
0, /* src_mask */ |
| 582 |
0xffff, /* dst_mask */ |
| 583 |
FALSE), /* pcrel_offset */ |
| 584 |
|
| 585 |
/* 32-bit PC relative */ |
| 586 |
HOWTO (R_PPC_REL32, /* type */ |
| 587 |
0, /* rightshift */ |
| 588 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 589 |
32, /* bitsize */ |
| 590 |
TRUE, /* pc_relative */ |
| 591 |
0, /* bitpos */ |
| 592 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 593 |
bfd_elf_generic_reloc, /* special_function */ |
| 594 |
"R_PPC_REL32", /* name */ |
| 595 |
FALSE, /* partial_inplace */ |
| 596 |
0, /* src_mask */ |
| 597 |
0xffffffff, /* dst_mask */ |
| 598 |
TRUE), /* pcrel_offset */ |
| 599 |
|
| 600 |
/* 32-bit relocation to the symbol's procedure linkage table. |
| 601 |
FIXME: not supported. */ |
| 602 |
HOWTO (R_PPC_PLT32, /* type */ |
| 603 |
0, /* rightshift */ |
| 604 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 605 |
32, /* bitsize */ |
| 606 |
FALSE, /* pc_relative */ |
| 607 |
0, /* bitpos */ |
| 608 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 609 |
bfd_elf_generic_reloc, /* special_function */ |
| 610 |
"R_PPC_PLT32", /* name */ |
| 611 |
FALSE, /* partial_inplace */ |
| 612 |
0, /* src_mask */ |
| 613 |
0, /* dst_mask */ |
| 614 |
FALSE), /* pcrel_offset */ |
| 615 |
|
| 616 |
/* 32-bit PC relative relocation to the symbol's procedure linkage table. |
| 617 |
FIXME: not supported. */ |
| 618 |
HOWTO (R_PPC_PLTREL32, /* type */ |
| 619 |
0, /* rightshift */ |
| 620 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 621 |
32, /* bitsize */ |
| 622 |
TRUE, /* pc_relative */ |
| 623 |
0, /* bitpos */ |
| 624 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 625 |
bfd_elf_generic_reloc, /* special_function */ |
| 626 |
"R_PPC_PLTREL32", /* name */ |
| 627 |
FALSE, /* partial_inplace */ |
| 628 |
0, /* src_mask */ |
| 629 |
0, /* dst_mask */ |
| 630 |
TRUE), /* pcrel_offset */ |
| 631 |
|
| 632 |
/* Like R_PPC_ADDR16_LO, but referring to the PLT table entry for |
| 633 |
the symbol. */ |
| 634 |
HOWTO (R_PPC_PLT16_LO, /* type */ |
| 635 |
0, /* rightshift */ |
| 636 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 637 |
16, /* bitsize */ |
| 638 |
FALSE, /* pc_relative */ |
| 639 |
0, /* bitpos */ |
| 640 |
complain_overflow_dont, /* complain_on_overflow */ |
| 641 |
bfd_elf_generic_reloc, /* special_function */ |
| 642 |
"R_PPC_PLT16_LO", /* name */ |
| 643 |
FALSE, /* partial_inplace */ |
| 644 |
0, /* src_mask */ |
| 645 |
0xffff, /* dst_mask */ |
| 646 |
FALSE), /* pcrel_offset */ |
| 647 |
|
| 648 |
/* Like R_PPC_ADDR16_HI, but referring to the PLT table entry for |
| 649 |
the symbol. */ |
| 650 |
HOWTO (R_PPC_PLT16_HI, /* type */ |
| 651 |
16, /* rightshift */ |
| 652 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 653 |
16, /* bitsize */ |
| 654 |
FALSE, /* pc_relative */ |
| 655 |
0, /* bitpos */ |
| 656 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 657 |
bfd_elf_generic_reloc, /* special_function */ |
| 658 |
"R_PPC_PLT16_HI", /* name */ |
| 659 |
FALSE, /* partial_inplace */ |
| 660 |
0, /* src_mask */ |
| 661 |
0xffff, /* dst_mask */ |
| 662 |
FALSE), /* pcrel_offset */ |
| 663 |
|
| 664 |
/* Like R_PPC_ADDR16_HA, but referring to the PLT table entry for |
| 665 |
the symbol. */ |
| 666 |
HOWTO (R_PPC_PLT16_HA, /* type */ |
| 667 |
16, /* rightshift */ |
| 668 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 669 |
16, /* bitsize */ |
| 670 |
FALSE, /* pc_relative */ |
| 671 |
0, /* bitpos */ |
| 672 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 673 |
ppc_elf_addr16_ha_reloc, /* special_function */ |
| 674 |
"R_PPC_PLT16_HA", /* name */ |
| 675 |
FALSE, /* partial_inplace */ |
| 676 |
0, /* src_mask */ |
| 677 |
0xffff, /* dst_mask */ |
| 678 |
FALSE), /* pcrel_offset */ |
| 679 |
|
| 680 |
/* A sign-extended 16 bit value relative to _SDA_BASE_, for use with |
| 681 |
small data items. */ |
| 682 |
HOWTO (R_PPC_SDAREL16, /* type */ |
| 683 |
0, /* rightshift */ |
| 684 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 685 |
16, /* bitsize */ |
| 686 |
FALSE, /* pc_relative */ |
| 687 |
0, /* bitpos */ |
| 688 |
complain_overflow_signed, /* complain_on_overflow */ |
| 689 |
bfd_elf_generic_reloc, /* special_function */ |
| 690 |
"R_PPC_SDAREL16", /* name */ |
| 691 |
FALSE, /* partial_inplace */ |
| 692 |
0, /* src_mask */ |
| 693 |
0xffff, /* dst_mask */ |
| 694 |
FALSE), /* pcrel_offset */ |
| 695 |
|
| 696 |
/* 16-bit section relative relocation. */ |
| 697 |
HOWTO (R_PPC_SECTOFF, /* type */ |
| 698 |
0, /* rightshift */ |
| 699 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 700 |
16, /* bitsize */ |
| 701 |
FALSE, /* pc_relative */ |
| 702 |
0, /* bitpos */ |
| 703 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 704 |
bfd_elf_generic_reloc, /* special_function */ |
| 705 |
"R_PPC_SECTOFF", /* name */ |
| 706 |
FALSE, /* partial_inplace */ |
| 707 |
0, /* src_mask */ |
| 708 |
0xffff, /* dst_mask */ |
| 709 |
FALSE), /* pcrel_offset */ |
| 710 |
|
| 711 |
/* 16-bit lower half section relative relocation. */ |
| 712 |
HOWTO (R_PPC_SECTOFF_LO, /* type */ |
| 713 |
0, /* rightshift */ |
| 714 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 715 |
16, /* bitsize */ |
| 716 |
FALSE, /* pc_relative */ |
| 717 |
0, /* bitpos */ |
| 718 |
complain_overflow_dont, /* complain_on_overflow */ |
| 719 |
bfd_elf_generic_reloc, /* special_function */ |
| 720 |
"R_PPC_SECTOFF_LO", /* name */ |
| 721 |
FALSE, /* partial_inplace */ |
| 722 |
0, /* src_mask */ |
| 723 |
0xffff, /* dst_mask */ |
| 724 |
FALSE), /* pcrel_offset */ |
| 725 |
|
| 726 |
/* 16-bit upper half section relative relocation. */ |
| 727 |
HOWTO (R_PPC_SECTOFF_HI, /* type */ |
| 728 |
16, /* rightshift */ |
| 729 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 730 |
16, /* bitsize */ |
| 731 |
FALSE, /* pc_relative */ |
| 732 |
0, /* bitpos */ |
| 733 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 734 |
bfd_elf_generic_reloc, /* special_function */ |
| 735 |
"R_PPC_SECTOFF_HI", /* name */ |
| 736 |
FALSE, /* partial_inplace */ |
| 737 |
0, /* src_mask */ |
| 738 |
0xffff, /* dst_mask */ |
| 739 |
FALSE), /* pcrel_offset */ |
| 740 |
|
| 741 |
/* 16-bit upper half adjusted section relative relocation. */ |
| 742 |
HOWTO (R_PPC_SECTOFF_HA, /* type */ |
| 743 |
16, /* rightshift */ |
| 744 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 745 |
16, /* bitsize */ |
| 746 |
FALSE, /* pc_relative */ |
| 747 |
0, /* bitpos */ |
| 748 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 749 |
ppc_elf_addr16_ha_reloc, /* special_function */ |
| 750 |
"R_PPC_SECTOFF_HA", /* name */ |
| 751 |
FALSE, /* partial_inplace */ |
| 752 |
0, /* src_mask */ |
| 753 |
0xffff, /* dst_mask */ |
| 754 |
FALSE), /* pcrel_offset */ |
| 755 |
|
| 756 |
/* Marker relocs for TLS. */ |
| 757 |
HOWTO (R_PPC_TLS, |
| 758 |
0, /* rightshift */ |
| 759 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 760 |
32, /* bitsize */ |
| 761 |
FALSE, /* pc_relative */ |
| 762 |
0, /* bitpos */ |
| 763 |
complain_overflow_dont, /* complain_on_overflow */ |
| 764 |
bfd_elf_generic_reloc, /* special_function */ |
| 765 |
"R_PPC_TLS", /* name */ |
| 766 |
FALSE, /* partial_inplace */ |
| 767 |
0, /* src_mask */ |
| 768 |
0, /* dst_mask */ |
| 769 |
FALSE), /* pcrel_offset */ |
| 770 |
|
| 771 |
HOWTO (R_PPC_TLSGD, |
| 772 |
0, /* rightshift */ |
| 773 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 774 |
32, /* bitsize */ |
| 775 |
FALSE, /* pc_relative */ |
| 776 |
0, /* bitpos */ |
| 777 |
complain_overflow_dont, /* complain_on_overflow */ |
| 778 |
bfd_elf_generic_reloc, /* special_function */ |
| 779 |
"R_PPC_TLSGD", /* name */ |
| 780 |
FALSE, /* partial_inplace */ |
| 781 |
0, /* src_mask */ |
| 782 |
0, /* dst_mask */ |
| 783 |
FALSE), /* pcrel_offset */ |
| 784 |
|
| 785 |
HOWTO (R_PPC_TLSLD, |
| 786 |
0, /* rightshift */ |
| 787 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 788 |
32, /* bitsize */ |
| 789 |
FALSE, /* pc_relative */ |
| 790 |
0, /* bitpos */ |
| 791 |
complain_overflow_dont, /* complain_on_overflow */ |
| 792 |
bfd_elf_generic_reloc, /* special_function */ |
| 793 |
"R_PPC_TLSLD", /* name */ |
| 794 |
FALSE, /* partial_inplace */ |
| 795 |
0, /* src_mask */ |
| 796 |
0, /* dst_mask */ |
| 797 |
FALSE), /* pcrel_offset */ |
| 798 |
|
| 799 |
/* Computes the load module index of the load module that contains the |
| 800 |
definition of its TLS sym. */ |
| 801 |
HOWTO (R_PPC_DTPMOD32, |
| 802 |
0, /* rightshift */ |
| 803 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 804 |
32, /* bitsize */ |
| 805 |
FALSE, /* pc_relative */ |
| 806 |
0, /* bitpos */ |
| 807 |
complain_overflow_dont, /* complain_on_overflow */ |
| 808 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 809 |
"R_PPC_DTPMOD32", /* name */ |
| 810 |
FALSE, /* partial_inplace */ |
| 811 |
0, /* src_mask */ |
| 812 |
0xffffffff, /* dst_mask */ |
| 813 |
FALSE), /* pcrel_offset */ |
| 814 |
|
| 815 |
/* Computes a dtv-relative displacement, the difference between the value |
| 816 |
of sym+add and the base address of the thread-local storage block that |
| 817 |
contains the definition of sym, minus 0x8000. */ |
| 818 |
HOWTO (R_PPC_DTPREL32, |
| 819 |
0, /* rightshift */ |
| 820 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 821 |
32, /* bitsize */ |
| 822 |
FALSE, /* pc_relative */ |
| 823 |
0, /* bitpos */ |
| 824 |
complain_overflow_dont, /* complain_on_overflow */ |
| 825 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 826 |
"R_PPC_DTPREL32", /* name */ |
| 827 |
FALSE, /* partial_inplace */ |
| 828 |
0, /* src_mask */ |
| 829 |
0xffffffff, /* dst_mask */ |
| 830 |
FALSE), /* pcrel_offset */ |
| 831 |
|
| 832 |
/* A 16 bit dtprel reloc. */ |
| 833 |
HOWTO (R_PPC_DTPREL16, |
| 834 |
0, /* rightshift */ |
| 835 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 836 |
16, /* bitsize */ |
| 837 |
FALSE, /* pc_relative */ |
| 838 |
0, /* bitpos */ |
| 839 |
complain_overflow_signed, /* complain_on_overflow */ |
| 840 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 841 |
"R_PPC_DTPREL16", /* name */ |
| 842 |
FALSE, /* partial_inplace */ |
| 843 |
0, /* src_mask */ |
| 844 |
0xffff, /* dst_mask */ |
| 845 |
FALSE), /* pcrel_offset */ |
| 846 |
|
| 847 |
/* Like DTPREL16, but no overflow. */ |
| 848 |
HOWTO (R_PPC_DTPREL16_LO, |
| 849 |
0, /* rightshift */ |
| 850 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 851 |
16, /* bitsize */ |
| 852 |
FALSE, /* pc_relative */ |
| 853 |
0, /* bitpos */ |
| 854 |
complain_overflow_dont, /* complain_on_overflow */ |
| 855 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 856 |
"R_PPC_DTPREL16_LO", /* name */ |
| 857 |
FALSE, /* partial_inplace */ |
| 858 |
0, /* src_mask */ |
| 859 |
0xffff, /* dst_mask */ |
| 860 |
FALSE), /* pcrel_offset */ |
| 861 |
|
| 862 |
/* Like DTPREL16_LO, but next higher group of 16 bits. */ |
| 863 |
HOWTO (R_PPC_DTPREL16_HI, |
| 864 |
16, /* rightshift */ |
| 865 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 866 |
16, /* bitsize */ |
| 867 |
FALSE, /* pc_relative */ |
| 868 |
0, /* bitpos */ |
| 869 |
complain_overflow_dont, /* complain_on_overflow */ |
| 870 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 871 |
"R_PPC_DTPREL16_HI", /* name */ |
| 872 |
FALSE, /* partial_inplace */ |
| 873 |
0, /* src_mask */ |
| 874 |
0xffff, /* dst_mask */ |
| 875 |
FALSE), /* pcrel_offset */ |
| 876 |
|
| 877 |
/* Like DTPREL16_HI, but adjust for low 16 bits. */ |
| 878 |
HOWTO (R_PPC_DTPREL16_HA, |
| 879 |
16, /* rightshift */ |
| 880 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 881 |
16, /* bitsize */ |
| 882 |
FALSE, /* pc_relative */ |
| 883 |
0, /* bitpos */ |
| 884 |
complain_overflow_dont, /* complain_on_overflow */ |
| 885 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 886 |
"R_PPC_DTPREL16_HA", /* name */ |
| 887 |
FALSE, /* partial_inplace */ |
| 888 |
0, /* src_mask */ |
| 889 |
0xffff, /* dst_mask */ |
| 890 |
FALSE), /* pcrel_offset */ |
| 891 |
|
| 892 |
/* Computes a tp-relative displacement, the difference between the value of |
| 893 |
sym+add and the value of the thread pointer (r13). */ |
| 894 |
HOWTO (R_PPC_TPREL32, |
| 895 |
0, /* rightshift */ |
| 896 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 897 |
32, /* bitsize */ |
| 898 |
FALSE, /* pc_relative */ |
| 899 |
0, /* bitpos */ |
| 900 |
complain_overflow_dont, /* complain_on_overflow */ |
| 901 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 902 |
"R_PPC_TPREL32", /* name */ |
| 903 |
FALSE, /* partial_inplace */ |
| 904 |
0, /* src_mask */ |
| 905 |
0xffffffff, /* dst_mask */ |
| 906 |
FALSE), /* pcrel_offset */ |
| 907 |
|
| 908 |
/* A 16 bit tprel reloc. */ |
| 909 |
HOWTO (R_PPC_TPREL16, |
| 910 |
0, /* rightshift */ |
| 911 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 912 |
16, /* bitsize */ |
| 913 |
FALSE, /* pc_relative */ |
| 914 |
0, /* bitpos */ |
| 915 |
complain_overflow_signed, /* complain_on_overflow */ |
| 916 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 917 |
"R_PPC_TPREL16", /* name */ |
| 918 |
FALSE, /* partial_inplace */ |
| 919 |
0, /* src_mask */ |
| 920 |
0xffff, /* dst_mask */ |
| 921 |
FALSE), /* pcrel_offset */ |
| 922 |
|
| 923 |
/* Like TPREL16, but no overflow. */ |
| 924 |
HOWTO (R_PPC_TPREL16_LO, |
| 925 |
0, /* rightshift */ |
| 926 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 927 |
16, /* bitsize */ |
| 928 |
FALSE, /* pc_relative */ |
| 929 |
0, /* bitpos */ |
| 930 |
complain_overflow_dont, /* complain_on_overflow */ |
| 931 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 932 |
"R_PPC_TPREL16_LO", /* name */ |
| 933 |
FALSE, /* partial_inplace */ |
| 934 |
0, /* src_mask */ |
| 935 |
0xffff, /* dst_mask */ |
| 936 |
FALSE), /* pcrel_offset */ |
| 937 |
|
| 938 |
/* Like TPREL16_LO, but next higher group of 16 bits. */ |
| 939 |
HOWTO (R_PPC_TPREL16_HI, |
| 940 |
16, /* rightshift */ |
| 941 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 942 |
16, /* bitsize */ |
| 943 |
FALSE, /* pc_relative */ |
| 944 |
0, /* bitpos */ |
| 945 |
complain_overflow_dont, /* complain_on_overflow */ |
| 946 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 947 |
"R_PPC_TPREL16_HI", /* name */ |
| 948 |
FALSE, /* partial_inplace */ |
| 949 |
0, /* src_mask */ |
| 950 |
0xffff, /* dst_mask */ |
| 951 |
FALSE), /* pcrel_offset */ |
| 952 |
|
| 953 |
/* Like TPREL16_HI, but adjust for low 16 bits. */ |
| 954 |
HOWTO (R_PPC_TPREL16_HA, |
| 955 |
16, /* rightshift */ |
| 956 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 957 |
16, /* bitsize */ |
| 958 |
FALSE, /* pc_relative */ |
| 959 |
0, /* bitpos */ |
| 960 |
complain_overflow_dont, /* complain_on_overflow */ |
| 961 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 962 |
"R_PPC_TPREL16_HA", /* name */ |
| 963 |
FALSE, /* partial_inplace */ |
| 964 |
0, /* src_mask */ |
| 965 |
0xffff, /* dst_mask */ |
| 966 |
FALSE), /* pcrel_offset */ |
| 967 |
|
| 968 |
/* Allocates two contiguous entries in the GOT to hold a tls_index structure, |
| 969 |
with values (sym+add)@dtpmod and (sym+add)@dtprel, and computes the offset |
| 970 |
to the first entry. */ |
| 971 |
HOWTO (R_PPC_GOT_TLSGD16, |
| 972 |
0, /* rightshift */ |
| 973 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 974 |
16, /* bitsize */ |
| 975 |
FALSE, /* pc_relative */ |
| 976 |
0, /* bitpos */ |
| 977 |
complain_overflow_signed, /* complain_on_overflow */ |
| 978 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 979 |
"R_PPC_GOT_TLSGD16", /* name */ |
| 980 |
FALSE, /* partial_inplace */ |
| 981 |
0, /* src_mask */ |
| 982 |
0xffff, /* dst_mask */ |
| 983 |
FALSE), /* pcrel_offset */ |
| 984 |
|
| 985 |
/* Like GOT_TLSGD16, but no overflow. */ |
| 986 |
HOWTO (R_PPC_GOT_TLSGD16_LO, |
| 987 |
0, /* rightshift */ |
| 988 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 989 |
16, /* bitsize */ |
| 990 |
FALSE, /* pc_relative */ |
| 991 |
0, /* bitpos */ |
| 992 |
complain_overflow_dont, /* complain_on_overflow */ |
| 993 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 994 |
"R_PPC_GOT_TLSGD16_LO", /* name */ |
| 995 |
FALSE, /* partial_inplace */ |
| 996 |
0, /* src_mask */ |
| 997 |
0xffff, /* dst_mask */ |
| 998 |
FALSE), /* pcrel_offset */ |
| 999 |
|
| 1000 |
/* Like GOT_TLSGD16_LO, but next higher group of 16 bits. */ |
| 1001 |
HOWTO (R_PPC_GOT_TLSGD16_HI, |
| 1002 |
16, /* rightshift */ |
| 1003 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1004 |
16, /* bitsize */ |
| 1005 |
FALSE, /* pc_relative */ |
| 1006 |
0, /* bitpos */ |
| 1007 |
complain_overflow_dont, /* complain_on_overflow */ |
| 1008 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 1009 |
"R_PPC_GOT_TLSGD16_HI", /* name */ |
| 1010 |
FALSE, /* partial_inplace */ |
| 1011 |
0, /* src_mask */ |
| 1012 |
0xffff, /* dst_mask */ |
| 1013 |
FALSE), /* pcrel_offset */ |
| 1014 |
|
| 1015 |
/* Like GOT_TLSGD16_HI, but adjust for low 16 bits. */ |
| 1016 |
HOWTO (R_PPC_GOT_TLSGD16_HA, |
| 1017 |
16, /* rightshift */ |
| 1018 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1019 |
16, /* 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_GOT_TLSGD16_HA", /* name */ |
| 1025 |
FALSE, /* partial_inplace */ |
| 1026 |
0, /* src_mask */ |
| 1027 |
0xffff, /* dst_mask */ |
| 1028 |
FALSE), /* pcrel_offset */ |
| 1029 |
|
| 1030 |
/* Allocates two contiguous entries in the GOT to hold a tls_index structure, |
| 1031 |
with values (sym+add)@dtpmod and zero, and computes the offset to the |
| 1032 |
first entry. */ |
| 1033 |
HOWTO (R_PPC_GOT_TLSLD16, |
| 1034 |
0, /* rightshift */ |
| 1035 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1036 |
16, /* bitsize */ |
| 1037 |
FALSE, /* pc_relative */ |
| 1038 |
0, /* bitpos */ |
| 1039 |
complain_overflow_signed, /* complain_on_overflow */ |
| 1040 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 1041 |
"R_PPC_GOT_TLSLD16", /* name */ |
| 1042 |
FALSE, /* partial_inplace */ |
| 1043 |
0, /* src_mask */ |
| 1044 |
0xffff, /* dst_mask */ |
| 1045 |
FALSE), /* pcrel_offset */ |
| 1046 |
|
| 1047 |
/* Like GOT_TLSLD16, but no overflow. */ |
| 1048 |
HOWTO (R_PPC_GOT_TLSLD16_LO, |
| 1049 |
0, /* rightshift */ |
| 1050 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1051 |
16, /* bitsize */ |
| 1052 |
FALSE, /* pc_relative */ |
| 1053 |
0, /* bitpos */ |
| 1054 |
complain_overflow_dont, /* complain_on_overflow */ |
| 1055 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 1056 |
"R_PPC_GOT_TLSLD16_LO", /* name */ |
| 1057 |
FALSE, /* partial_inplace */ |
| 1058 |
0, /* src_mask */ |
| 1059 |
0xffff, /* dst_mask */ |
| 1060 |
FALSE), /* pcrel_offset */ |
| 1061 |
|
| 1062 |
/* Like GOT_TLSLD16_LO, but next higher group of 16 bits. */ |
| 1063 |
HOWTO (R_PPC_GOT_TLSLD16_HI, |
| 1064 |
16, /* rightshift */ |
| 1065 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1066 |
16, /* bitsize */ |
| 1067 |
FALSE, /* pc_relative */ |
| 1068 |
0, /* bitpos */ |
| 1069 |
complain_overflow_dont, /* complain_on_overflow */ |
| 1070 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 1071 |
"R_PPC_GOT_TLSLD16_HI", /* name */ |
| 1072 |
FALSE, /* partial_inplace */ |
| 1073 |
0, /* src_mask */ |
| 1074 |
0xffff, /* dst_mask */ |
| 1075 |
FALSE), /* pcrel_offset */ |
| 1076 |
|
| 1077 |
/* Like GOT_TLSLD16_HI, but adjust for low 16 bits. */ |
| 1078 |
HOWTO (R_PPC_GOT_TLSLD16_HA, |
| 1079 |
16, /* rightshift */ |
| 1080 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1081 |
16, /* bitsize */ |
| 1082 |
FALSE, /* pc_relative */ |
| 1083 |
0, /* bitpos */ |
| 1084 |
complain_overflow_dont, /* complain_on_overflow */ |
| 1085 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 1086 |
"R_PPC_GOT_TLSLD16_HA", /* name */ |
| 1087 |
FALSE, /* partial_inplace */ |
| 1088 |
0, /* src_mask */ |
| 1089 |
0xffff, /* dst_mask */ |
| 1090 |
FALSE), /* pcrel_offset */ |
| 1091 |
|
| 1092 |
/* Allocates an entry in the GOT with value (sym+add)@dtprel, and computes |
| 1093 |
the offset to the entry. */ |
| 1094 |
HOWTO (R_PPC_GOT_DTPREL16, |
| 1095 |
0, /* rightshift */ |
| 1096 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1097 |
16, /* bitsize */ |
| 1098 |
FALSE, /* pc_relative */ |
| 1099 |
0, /* bitpos */ |
| 1100 |
complain_overflow_signed, /* complain_on_overflow */ |
| 1101 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 1102 |
"R_PPC_GOT_DTPREL16", /* name */ |
| 1103 |
FALSE, /* partial_inplace */ |
| 1104 |
0, /* src_mask */ |
| 1105 |
0xffff, /* dst_mask */ |
| 1106 |
FALSE), /* pcrel_offset */ |
| 1107 |
|
| 1108 |
/* Like GOT_DTPREL16, but no overflow. */ |
| 1109 |
HOWTO (R_PPC_GOT_DTPREL16_LO, |
| 1110 |
0, /* rightshift */ |
| 1111 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1112 |
16, /* bitsize */ |
| 1113 |
FALSE, /* pc_relative */ |
| 1114 |
0, /* bitpos */ |
| 1115 |
complain_overflow_dont, /* complain_on_overflow */ |
| 1116 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 1117 |
"R_PPC_GOT_DTPREL16_LO", /* name */ |
| 1118 |
FALSE, /* partial_inplace */ |
| 1119 |
0, /* src_mask */ |
| 1120 |
0xffff, /* dst_mask */ |
| 1121 |
FALSE), /* pcrel_offset */ |
| 1122 |
|
| 1123 |
/* Like GOT_DTPREL16_LO, but next higher group of 16 bits. */ |
| 1124 |
HOWTO (R_PPC_GOT_DTPREL16_HI, |
| 1125 |
16, /* rightshift */ |
| 1126 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1127 |
16, /* bitsize */ |
| 1128 |
FALSE, /* pc_relative */ |
| 1129 |
0, /* bitpos */ |
| 1130 |
complain_overflow_dont, /* complain_on_overflow */ |
| 1131 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 1132 |
"R_PPC_GOT_DTPREL16_HI", /* name */ |
| 1133 |
FALSE, /* partial_inplace */ |
| 1134 |
0, /* src_mask */ |
| 1135 |
0xffff, /* dst_mask */ |
| 1136 |
FALSE), /* pcrel_offset */ |
| 1137 |
|
| 1138 |
/* Like GOT_DTPREL16_HI, but adjust for low 16 bits. */ |
| 1139 |
HOWTO (R_PPC_GOT_DTPREL16_HA, |
| 1140 |
16, /* rightshift */ |
| 1141 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1142 |
16, /* bitsize */ |
| 1143 |
FALSE, /* pc_relative */ |
| 1144 |
0, /* bitpos */ |
| 1145 |
complain_overflow_dont, /* complain_on_overflow */ |
| 1146 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 1147 |
"R_PPC_GOT_DTPREL16_HA", /* name */ |
| 1148 |
FALSE, /* partial_inplace */ |
| 1149 |
0, /* src_mask */ |
| 1150 |
0xffff, /* dst_mask */ |
| 1151 |
FALSE), /* pcrel_offset */ |
| 1152 |
|
| 1153 |
/* Allocates an entry in the GOT with value (sym+add)@tprel, and computes the |
| 1154 |
offset to the entry. */ |
| 1155 |
HOWTO (R_PPC_GOT_TPREL16, |
| 1156 |
0, /* rightshift */ |
| 1157 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1158 |
16, /* bitsize */ |
| 1159 |
FALSE, /* pc_relative */ |
| 1160 |
0, /* bitpos */ |
| 1161 |
complain_overflow_signed, /* complain_on_overflow */ |
| 1162 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 1163 |
"R_PPC_GOT_TPREL16", /* name */ |
| 1164 |
FALSE, /* partial_inplace */ |
| 1165 |
0, /* src_mask */ |
| 1166 |
0xffff, /* dst_mask */ |
| 1167 |
FALSE), /* pcrel_offset */ |
| 1168 |
|
| 1169 |
/* Like GOT_TPREL16, but no overflow. */ |
| 1170 |
HOWTO (R_PPC_GOT_TPREL16_LO, |
| 1171 |
0, /* rightshift */ |
| 1172 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1173 |
16, /* bitsize */ |
| 1174 |
FALSE, /* pc_relative */ |
| 1175 |
0, /* bitpos */ |
| 1176 |
complain_overflow_dont, /* complain_on_overflow */ |
| 1177 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 1178 |
"R_PPC_GOT_TPREL16_LO", /* name */ |
| 1179 |
FALSE, /* partial_inplace */ |
| 1180 |
0, /* src_mask */ |
| 1181 |
0xffff, /* dst_mask */ |
| 1182 |
FALSE), /* pcrel_offset */ |
| 1183 |
|
| 1184 |
/* Like GOT_TPREL16_LO, but next higher group of 16 bits. */ |
| 1185 |
HOWTO (R_PPC_GOT_TPREL16_HI, |
| 1186 |
16, /* rightshift */ |
| 1187 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1188 |
16, /* bitsize */ |
| 1189 |
FALSE, /* pc_relative */ |
| 1190 |
0, /* bitpos */ |
| 1191 |
complain_overflow_dont, /* complain_on_overflow */ |
| 1192 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 1193 |
"R_PPC_GOT_TPREL16_HI", /* name */ |
| 1194 |
FALSE, /* partial_inplace */ |
| 1195 |
0, /* src_mask */ |
| 1196 |
0xffff, /* dst_mask */ |
| 1197 |
FALSE), /* pcrel_offset */ |
| 1198 |
|
| 1199 |
/* Like GOT_TPREL16_HI, but adjust for low 16 bits. */ |
| 1200 |
HOWTO (R_PPC_GOT_TPREL16_HA, |
| 1201 |
16, /* rightshift */ |
| 1202 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1203 |
16, /* bitsize */ |
| 1204 |
FALSE, /* pc_relative */ |
| 1205 |
0, /* bitpos */ |
| 1206 |
complain_overflow_dont, /* complain_on_overflow */ |
| 1207 |
ppc_elf_unhandled_reloc, /* special_function */ |
| 1208 |
"R_PPC_GOT_TPREL16_HA", /* name */ |
| 1209 |
FALSE, /* partial_inplace */ |
| 1210 |
0, /* src_mask */ |
| 1211 |
0xffff, /* dst_mask */ |
| 1212 |
FALSE), /* pcrel_offset */ |
| 1213 |
|
| 1214 |
/* The remaining relocs are from the Embedded ELF ABI, and are not |
| 1215 |
in the SVR4 ELF ABI. */ |
| 1216 |
|
| 1217 |
/* 32 bit value resulting from the addend minus the symbol. */ |
| 1218 |
HOWTO (R_PPC_EMB_NADDR32, /* type */ |
| 1219 |
0, /* rightshift */ |
| 1220 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1221 |
32, /* bitsize */ |
| 1222 |
FALSE, /* pc_relative */ |
| 1223 |
0, /* bitpos */ |
| 1224 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 1225 |
bfd_elf_generic_reloc, /* special_function */ |
| 1226 |
"R_PPC_EMB_NADDR32", /* name */ |
| 1227 |
FALSE, /* partial_inplace */ |
| 1228 |
0, /* src_mask */ |
| 1229 |
0xffffffff, /* dst_mask */ |
| 1230 |
FALSE), /* pcrel_offset */ |
| 1231 |
|
| 1232 |
/* 16 bit value resulting from the addend minus the symbol. */ |
| 1233 |
HOWTO (R_PPC_EMB_NADDR16, /* type */ |
| 1234 |
0, /* rightshift */ |
| 1235 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1236 |
16, /* bitsize */ |
| 1237 |
FALSE, /* pc_relative */ |
| 1238 |
0, /* bitpos */ |
| 1239 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 1240 |
bfd_elf_generic_reloc, /* special_function */ |
| 1241 |
"R_PPC_EMB_NADDR16", /* name */ |
| 1242 |
FALSE, /* partial_inplace */ |
| 1243 |
0, /* src_mask */ |
| 1244 |
0xffff, /* dst_mask */ |
| 1245 |
FALSE), /* pcrel_offset */ |
| 1246 |
|
| 1247 |
/* 16 bit value resulting from the addend minus the symbol. */ |
| 1248 |
HOWTO (R_PPC_EMB_NADDR16_LO, /* type */ |
| 1249 |
0, /* rightshift */ |
| 1250 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1251 |
16, /* bitsize */ |
| 1252 |
FALSE, /* pc_relative */ |
| 1253 |
0, /* bitpos */ |
| 1254 |
complain_overflow_dont,/* complain_on_overflow */ |
| 1255 |
bfd_elf_generic_reloc, /* special_function */ |
| 1256 |
"R_PPC_EMB_ADDR16_LO", /* name */ |
| 1257 |
FALSE, /* partial_inplace */ |
| 1258 |
0, /* src_mask */ |
| 1259 |
0xffff, /* dst_mask */ |
| 1260 |
FALSE), /* pcrel_offset */ |
| 1261 |
|
| 1262 |
/* The high order 16 bits of the addend minus the symbol. */ |
| 1263 |
HOWTO (R_PPC_EMB_NADDR16_HI, /* type */ |
| 1264 |
16, /* rightshift */ |
| 1265 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1266 |
16, /* bitsize */ |
| 1267 |
FALSE, /* pc_relative */ |
| 1268 |
0, /* bitpos */ |
| 1269 |
complain_overflow_dont, /* complain_on_overflow */ |
| 1270 |
bfd_elf_generic_reloc, /* special_function */ |
| 1271 |
"R_PPC_EMB_NADDR16_HI", /* name */ |
| 1272 |
FALSE, /* partial_inplace */ |
| 1273 |
0, /* src_mask */ |
| 1274 |
0xffff, /* dst_mask */ |
| 1275 |
FALSE), /* pcrel_offset */ |
| 1276 |
|
| 1277 |
/* The high order 16 bits of the result of the addend minus the address, |
| 1278 |
plus 1 if the contents of the low 16 bits, treated as a signed number, |
| 1279 |
is negative. */ |
| 1280 |
HOWTO (R_PPC_EMB_NADDR16_HA, /* type */ |
| 1281 |
16, /* rightshift */ |
| 1282 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1283 |
16, /* bitsize */ |
| 1284 |
FALSE, /* pc_relative */ |
| 1285 |
0, /* bitpos */ |
| 1286 |
complain_overflow_dont, /* complain_on_overflow */ |
| 1287 |
ppc_elf_addr16_ha_reloc, /* special_function */ |
| 1288 |
"R_PPC_EMB_NADDR16_HA", /* name */ |
| 1289 |
FALSE, /* partial_inplace */ |
| 1290 |
0, /* src_mask */ |
| 1291 |
0xffff, /* dst_mask */ |
| 1292 |
FALSE), /* pcrel_offset */ |
| 1293 |
|
| 1294 |
/* 16 bit value resulting from allocating a 4 byte word to hold an |
| 1295 |
address in the .sdata section, and returning the offset from |
| 1296 |
_SDA_BASE_ for that relocation. */ |
| 1297 |
HOWTO (R_PPC_EMB_SDAI16, /* type */ |
| 1298 |
0, /* rightshift */ |
| 1299 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1300 |
16, /* bitsize */ |
| 1301 |
FALSE, /* pc_relative */ |
| 1302 |
0, /* bitpos */ |
| 1303 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 1304 |
bfd_elf_generic_reloc, /* special_function */ |
| 1305 |
"R_PPC_EMB_SDAI16", /* name */ |
| 1306 |
FALSE, /* partial_inplace */ |
| 1307 |
0, /* src_mask */ |
| 1308 |
0xffff, /* dst_mask */ |
| 1309 |
FALSE), /* pcrel_offset */ |
| 1310 |
|
| 1311 |
/* 16 bit value resulting from allocating a 4 byte word to hold an |
| 1312 |
address in the .sdata2 section, and returning the offset from |
| 1313 |
_SDA2_BASE_ for that relocation. */ |
| 1314 |
HOWTO (R_PPC_EMB_SDA2I16, /* type */ |
| 1315 |
0, /* rightshift */ |
| 1316 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1317 |
16, /* bitsize */ |
| 1318 |
FALSE, /* pc_relative */ |
| 1319 |
0, /* bitpos */ |
| 1320 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 1321 |
bfd_elf_generic_reloc, /* special_function */ |
| 1322 |
"R_PPC_EMB_SDA2I16", /* name */ |
| 1323 |
FALSE, /* partial_inplace */ |
| 1324 |
0, /* src_mask */ |
| 1325 |
0xffff, /* dst_mask */ |
| 1326 |
FALSE), /* pcrel_offset */ |
| 1327 |
|
| 1328 |
/* A sign-extended 16 bit value relative to _SDA2_BASE_, for use with |
| 1329 |
small data items. */ |
| 1330 |
HOWTO (R_PPC_EMB_SDA2REL, /* type */ |
| 1331 |
0, /* rightshift */ |
| 1332 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1333 |
16, /* bitsize */ |
| 1334 |
FALSE, /* pc_relative */ |
| 1335 |
0, /* bitpos */ |
| 1336 |
complain_overflow_signed, /* complain_on_overflow */ |
| 1337 |
bfd_elf_generic_reloc, /* special_function */ |
| 1338 |
"R_PPC_EMB_SDA2REL", /* name */ |
| 1339 |
FALSE, /* partial_inplace */ |
| 1340 |
0, /* src_mask */ |
| 1341 |
0xffff, /* dst_mask */ |
| 1342 |
FALSE), /* pcrel_offset */ |
| 1343 |
|
| 1344 |
/* Relocate against either _SDA_BASE_ or _SDA2_BASE_, filling in the 16 bit |
| 1345 |
signed offset from the appropriate base, and filling in the register |
| 1346 |
field with the appropriate register (0, 2, or 13). */ |
| 1347 |
HOWTO (R_PPC_EMB_SDA21, /* type */ |
| 1348 |
0, /* rightshift */ |
| 1349 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1350 |
16, /* bitsize */ |
| 1351 |
FALSE, /* pc_relative */ |
| 1352 |
0, /* bitpos */ |
| 1353 |
complain_overflow_signed, /* complain_on_overflow */ |
| 1354 |
bfd_elf_generic_reloc, /* special_function */ |
| 1355 |
"R_PPC_EMB_SDA21", /* name */ |
| 1356 |
FALSE, /* partial_inplace */ |
| 1357 |
0, /* src_mask */ |
| 1358 |
0xffff, /* dst_mask */ |
| 1359 |
FALSE), /* pcrel_offset */ |
| 1360 |
|
| 1361 |
/* Relocation not handled: R_PPC_EMB_MRKREF */ |
| 1362 |
/* Relocation not handled: R_PPC_EMB_RELSEC16 */ |
| 1363 |
/* Relocation not handled: R_PPC_EMB_RELST_LO */ |
| 1364 |
/* Relocation not handled: R_PPC_EMB_RELST_HI */ |
| 1365 |
/* Relocation not handled: R_PPC_EMB_RELST_HA */ |
| 1366 |
/* Relocation not handled: R_PPC_EMB_BIT_FLD */ |
| 1367 |
|
| 1368 |
/* PC relative relocation against either _SDA_BASE_ or _SDA2_BASE_, filling |
| 1369 |
in the 16 bit signed offset from the appropriate base, and filling in the |
| 1370 |
register field with the appropriate register (0, 2, or 13). */ |
| 1371 |
HOWTO (R_PPC_EMB_RELSDA, /* type */ |
| 1372 |
0, /* rightshift */ |
| 1373 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1374 |
16, /* bitsize */ |
| 1375 |
TRUE, /* pc_relative */ |
| 1376 |
0, /* bitpos */ |
| 1377 |
complain_overflow_signed, /* complain_on_overflow */ |
| 1378 |
bfd_elf_generic_reloc, /* special_function */ |
| 1379 |
"R_PPC_EMB_RELSDA", /* name */ |
| 1380 |
FALSE, /* partial_inplace */ |
| 1381 |
0, /* src_mask */ |
| 1382 |
0xffff, /* dst_mask */ |
| 1383 |
FALSE), /* pcrel_offset */ |
| 1384 |
|
| 1385 |
HOWTO (R_PPC_IRELATIVE, /* type */ |
| 1386 |
0, /* rightshift */ |
| 1387 |
2, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1388 |
32, /* bitsize */ |
| 1389 |
FALSE, /* pc_relative */ |
| 1390 |
0, /* bitpos */ |
| 1391 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 1392 |
bfd_elf_generic_reloc, /* special_function */ |
| 1393 |
"R_PPC_IRELATIVE", /* name */ |
| 1394 |
FALSE, /* partial_inplace */ |
| 1395 |
0, /* src_mask */ |
| 1396 |
0xffffffff, /* dst_mask */ |
| 1397 |
FALSE), /* pcrel_offset */ |
| 1398 |
|
| 1399 |
/* A 16 bit relative relocation. */ |
| 1400 |
HOWTO (R_PPC_REL16, /* type */ |
| 1401 |
0, /* rightshift */ |
| 1402 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1403 |
16, /* bitsize */ |
| 1404 |
TRUE, /* pc_relative */ |
| 1405 |
0, /* bitpos */ |
| 1406 |
complain_overflow_bitfield, /* complain_on_overflow */ |
| 1407 |
bfd_elf_generic_reloc, /* special_function */ |
| 1408 |
"R_PPC_REL16", /* name */ |
| 1409 |
FALSE, /* partial_inplace */ |
| 1410 |
0, /* src_mask */ |
| 1411 |
0xffff, /* dst_mask */ |
| 1412 |
TRUE), /* pcrel_offset */ |
| 1413 |
|
| 1414 |
/* A 16 bit relative relocation without overflow. */ |
| 1415 |
HOWTO (R_PPC_REL16_LO, /* type */ |
| 1416 |
0, /* rightshift */ |
| 1417 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1418 |
16, /* bitsize */ |
| 1419 |
TRUE, /* pc_relative */ |
| 1420 |
0, /* bitpos */ |
| 1421 |
complain_overflow_dont,/* complain_on_overflow */ |
| 1422 |
bfd_elf_generic_reloc, /* special_function */ |
| 1423 |
"R_PPC_REL16_LO", /* name */ |
| 1424 |
FALSE, /* partial_inplace */ |
| 1425 |
0, /* src_mask */ |
| 1426 |
0xffff, /* dst_mask */ |
| 1427 |
TRUE), /* pcrel_offset */ |
| 1428 |
|
| 1429 |
/* The high order 16 bits of a relative address. */ |
| 1430 |
HOWTO (R_PPC_REL16_HI, /* type */ |
| 1431 |
16, /* rightshift */ |
| 1432 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1433 |
16, /* bitsize */ |
| 1434 |
TRUE, /* pc_relative */ |
| 1435 |
0, /* bitpos */ |
| 1436 |
complain_overflow_dont, /* complain_on_overflow */ |
| 1437 |
bfd_elf_generic_reloc, /* special_function */ |
| 1438 |
"R_PPC_REL16_HI", /* name */ |
| 1439 |
FALSE, /* partial_inplace */ |
| 1440 |
0, /* src_mask */ |
| 1441 |
0xffff, /* dst_mask */ |
| 1442 |
TRUE), /* pcrel_offset */ |
| 1443 |
|
| 1444 |
/* The high order 16 bits of a relative address, plus 1 if the contents of |
| 1445 |
the low 16 bits, treated as a signed number, is negative. */ |
| 1446 |
HOWTO (R_PPC_REL16_HA, /* type */ |
| 1447 |
16, /* rightshift */ |
| 1448 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1449 |
16, /* bitsize */ |
| 1450 |
TRUE, /* pc_relative */ |
| 1451 |
0, /* bitpos */ |
| 1452 |
complain_overflow_dont, /* complain_on_overflow */ |
| 1453 |
ppc_elf_addr16_ha_reloc, /* special_function */ |
| 1454 |
"R_PPC_REL16_HA", /* name */ |
| 1455 |
FALSE, /* partial_inplace */ |
| 1456 |
0, /* src_mask */ |
| 1457 |
0xffff, /* dst_mask */ |
| 1458 |
TRUE), /* pcrel_offset */ |
| 1459 |
|
| 1460 |
/* GNU extension to record C++ vtable hierarchy. */ |
| 1461 |
HOWTO (R_PPC_GNU_VTINHERIT, /* type */ |
| 1462 |
0, /* rightshift */ |
| 1463 |
0, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1464 |
0, /* bitsize */ |
| 1465 |
FALSE, /* pc_relative */ |
| 1466 |
0, /* bitpos */ |
| 1467 |
complain_overflow_dont, /* complain_on_overflow */ |
| 1468 |
NULL, /* special_function */ |
| 1469 |
"R_PPC_GNU_VTINHERIT", /* name */ |
| 1470 |
FALSE, /* partial_inplace */ |
| 1471 |
0, /* src_mask */ |
| 1472 |
0, /* dst_mask */ |
| 1473 |
FALSE), /* pcrel_offset */ |
| 1474 |
|
| 1475 |
/* GNU extension to record C++ vtable member usage. */ |
| 1476 |
HOWTO (R_PPC_GNU_VTENTRY, /* type */ |
| 1477 |
0, /* rightshift */ |
| 1478 |
0, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1479 |
0, /* bitsize */ |
| 1480 |
FALSE, /* pc_relative */ |
| 1481 |
0, /* bitpos */ |
| 1482 |
complain_overflow_dont, /* complain_on_overflow */ |
| 1483 |
NULL, /* special_function */ |
| 1484 |
"R_PPC_GNU_VTENTRY", /* name */ |
| 1485 |
FALSE, /* partial_inplace */ |
| 1486 |
0, /* src_mask */ |
| 1487 |
0, /* dst_mask */ |
| 1488 |
FALSE), /* pcrel_offset */ |
| 1489 |
|
| 1490 |
/* Phony reloc to handle AIX style TOC entries. */ |
| 1491 |
HOWTO (R_PPC_TOC16, /* type */ |
| 1492 |
0, /* rightshift */ |
| 1493 |
1, /* size (0 = byte, 1 = short, 2 = long) */ |
| 1494 |
16, /* bitsize */ |
| 1495 |
FALSE, /* pc_relative */ |
| 1496 |
0, /* bitpos */ |
| 1497 |
complain_overflow_signed, /* complain_on_overflow */ |
| 1498 |
bfd_elf_generic_reloc, /* special_function */ |
| 1499 |
"R_PPC_TOC16", /* name */ |
| 1500 |
FALSE, /* partial_inplace */ |
| 1501 |
0, /* src_mask */ |
| 1502 |
0xffff, /* dst_mask */ |
| 1503 |
FALSE), /* pcrel_offset */ |
| 1504 |
}; |
| 1505 |
|
| 1506 |
/* Initialize the ppc_elf_howto_table, so that linear accesses can be done. */ |
| 1507 |
|
| 1508 |
static void |
| 1509 |
ppc_elf_howto_init (void) |
| 1510 |
{ |
| 1511 |
unsigned int i, type; |
| 1512 |
|
| 1513 |
for (i = 0; |
| 1514 |
i < sizeof (ppc_elf_howto_raw) / sizeof (ppc_elf_howto_raw[0]); |
| 1515 |
i++) |
| 1516 |
{ |
| 1517 |
type = ppc_elf_howto_raw[i].type; |
| 1518 |
if (type >= (sizeof (ppc_elf_howto_table) |
| 1519 |
/ sizeof (ppc_elf_howto_table[0]))) |
| 1520 |
abort (); |
| 1521 |
ppc_elf_howto_table[type] = &ppc_elf_howto_raw[i]; |
| 1522 |
} |
| 1523 |
} |
| 1524 |
|
| 1525 |
static reloc_howto_type * |
| 1526 |
ppc_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, |
| 1527 |
bfd_reloc_code_real_type code) |
| 1528 |
{ |
| 1529 |
enum elf_ppc_reloc_type r; |
| 1530 |
|
| 1531 |
/* Initialize howto table if not already done. */ |
| 1532 |
if (!ppc_elf_howto_table[R_PPC_ADDR32]) |
| 1533 |
ppc_elf_howto_init (); |
| 1534 |
|
| 1535 |
switch (code) |
| 1536 |
{ |
| 1537 |
default: |
| 1538 |
return NULL; |
| 1539 |
|
| 1540 |
case BFD_RELOC_NONE: r = R_PPC_NONE; break; |
| 1541 |
case BFD_RELOC_32: r = R_PPC_ADDR32; break; |
| 1542 |
case BFD_RELOC_PPC_BA26: r = R_PPC_ADDR24; break; |
| 1543 |
case BFD_RELOC_16: r = R_PPC_ADDR16; break; |
| 1544 |
case BFD_RELOC_LO16: r = R_PPC_ADDR16_LO; break; |
| 1545 |
case BFD_RELOC_HI16: r = R_PPC_ADDR16_HI; break; |
| 1546 |
case BFD_RELOC_HI16_S: r = R_PPC_ADDR16_HA; break; |
| 1547 |
case BFD_RELOC_PPC_BA16: r = R_PPC_ADDR14; break; |
| 1548 |
case BFD_RELOC_PPC_BA16_BRTAKEN: r = R_PPC_ADDR14_BRTAKEN; break; |
| 1549 |
case BFD_RELOC_PPC_BA16_BRNTAKEN: r = R_PPC_ADDR14_BRNTAKEN; break; |
| 1550 |
case BFD_RELOC_PPC_B26: r = R_PPC_REL24; break; |
| 1551 |
case BFD_RELOC_PPC_B16: r = R_PPC_REL14; break; |
| 1552 |
case BFD_RELOC_PPC_B16_BRTAKEN: r = R_PPC_REL14_BRTAKEN; break; |
| 1553 |
case BFD_RELOC_PPC_B16_BRNTAKEN: r = R_PPC_REL14_BRNTAKEN; break; |
| 1554 |
case BFD_RELOC_16_GOTOFF: r = R_PPC_GOT16; break; |
| 1555 |
case BFD_RELOC_LO16_GOTOFF: r = R_PPC_GOT16_LO; break; |
| 1556 |
case BFD_RELOC_HI16_GOTOFF: r = R_PPC_GOT16_HI; break; |
| 1557 |
case BFD_RELOC_HI16_S_GOTOFF: r = R_PPC_GOT16_HA; break; |
| 1558 |
case BFD_RELOC_24_PLT_PCREL: r = R_PPC_PLTREL24; break; |
| 1559 |
case BFD_RELOC_PPC_COPY: r = R_PPC_COPY; break; |
| 1560 |
case BFD_RELOC_PPC_GLOB_DAT: r = R_PPC_GLOB_DAT; break; |
| 1561 |
case BFD_RELOC_PPC_LOCAL24PC: r = R_PPC_LOCAL24PC; break; |
| 1562 |
case BFD_RELOC_32_PCREL: r = R_PPC_REL32; break; |
| 1563 |
case BFD_RELOC_32_PLTOFF: r = R_PPC_PLT32; break; |
| 1564 |
case BFD_RELOC_32_PLT_PCREL: r = R_PPC_PLTREL32; break; |
| 1565 |
case BFD_RELOC_LO16_PLTOFF: r = R_PPC_PLT16_LO; break; |
| 1566 |
case BFD_RELOC_HI16_PLTOFF: r = R_PPC_PLT16_HI; break; |
| 1567 |
case BFD_RELOC_HI16_S_PLTOFF: r = R_PPC_PLT16_HA; break; |
| 1568 |
case BFD_RELOC_GPREL16: r = R_PPC_SDAREL16; break; |
| 1569 |
case BFD_RELOC_16_BASEREL: r = R_PPC_SECTOFF; break; |
| 1570 |
case BFD_RELOC_LO16_BASEREL: r = R_PPC_SECTOFF_LO; break; |
| 1571 |
case BFD_RELOC_HI16_BASEREL: r = R_PPC_SECTOFF_HI; break; |
| 1572 |
case BFD_RELOC_HI16_S_BASEREL: r = R_PPC_SECTOFF_HA; break; |
| 1573 |
case BFD_RELOC_CTOR: r = R_PPC_ADDR32; break; |
| 1574 |
case BFD_RELOC_PPC_TOC16: r = R_PPC_TOC16; break; |
| 1575 |
case BFD_RELOC_PPC_TLS: r = R_PPC_TLS; break; |
| 1576 |
case BFD_RELOC_PPC_TLSGD: r = R_PPC_TLSGD; break; |
| 1577 |
case BFD_RELOC_PPC_TLSLD: r = R_PPC_TLSLD; break; |
| 1578 |
case BFD_RELOC_PPC_DTPMOD: r = R_PPC_DTPMOD32; break; |
| 1579 |
case BFD_RELOC_PPC_TPREL16: r = R_PPC_TPREL16; break; |
| 1580 |
case BFD_RELOC_PPC_TPREL16_LO: r = R_PPC_TPREL16_LO; break; |
| 1581 |
case BFD_RELOC_PPC_TPREL16_HI: r = R_PPC_TPREL16_HI; break; |
| 1582 |
case BFD_RELOC_PPC_TPREL16_HA: r = R_PPC_TPREL16_HA; break; |
| 1583 |
case BFD_RELOC_PPC_TPREL: r = R_PPC_TPREL32; break; |
| 1584 |
case BFD_RELOC_PPC_DTPREL16: r = R_PPC_DTPREL16; break; |
| 1585 |
case BFD_RELOC_PPC_DTPREL16_LO: r = R_PPC_DTPREL16_LO; break; |
| 1586 |
case BFD_RELOC_PPC_DTPREL16_HI: r = R_PPC_DTPREL16_HI; break; |
| 1587 |
case BFD_RELOC_PPC_DTPREL16_HA: r = R_PPC_DTPREL16_HA; break; |
| 1588 |
case BFD_RELOC_PPC_DTPREL: r = R_PPC_DTPREL32; break; |
| 1589 |
case BFD_RELOC_PPC_GOT_TLSGD16: r = R_PPC_GOT_TLSGD16; break; |
| 1590 |
case BFD_RELOC_PPC_GOT_TLSGD16_LO: r = R_PPC_GOT_TLSGD16_LO; break; |
| 1591 |
case BFD_RELOC_PPC_GOT_TLSGD16_HI: r = R_PPC_GOT_TLSGD16_HI; break; |
| 1592 |
case BFD_RELOC_PPC_GOT_TLSGD16_HA: r = R_PPC_GOT_TLSGD16_HA; break; |
| 1593 |
case BFD_RELOC_PPC_GOT_TLSLD16: r = R_PPC_GOT_TLSLD16; break; |
| 1594 |
case BFD_RELOC_PPC_GOT_TLSLD16_LO: r = R_PPC_GOT_TLSLD16_LO; break; |
| 1595 |
case BFD_RELOC_PPC_GOT_TLSLD16_HI: r = R_PPC_GOT_TLSLD16_HI; break; |
| 1596 |
case BFD_RELOC_PPC_GOT_TLSLD16_HA: r = R_PPC_GOT_TLSLD16_HA; break; |
| 1597 |
case BFD_RELOC_PPC_GOT_TPREL16: r = R_PPC_GOT_TPREL16; break; |
| 1598 |
case BFD_RELOC_PPC_GOT_TPREL16_LO: r = R_PPC_GOT_TPREL16_LO; break; |
| 1599 |
case BFD_RELOC_PPC_GOT_TPREL16_HI: r = R_PPC_GOT_TPREL16_HI; break; |
| 1600 |
case BFD_RELOC_PPC_GOT_TPREL16_HA: r = R_PPC_GOT_TPREL16_HA; break; |
| 1601 |
case BFD_RELOC_PPC_GOT_DTPREL16: r = R_PPC_GOT_DTPREL16; break; |
| 1602 |
case BFD_RELOC_PPC_GOT_DTPREL16_LO: r = R_PPC_GOT_DTPREL16_LO; break; |
| 1603 |
case BFD_RELOC_PPC_GOT_DTPREL16_HI: r = R_PPC_GOT_DTPREL16_HI; break; |
| 1604 |
case BFD_RELOC_PPC_GOT_DTPREL16_HA: r = R_PPC_GOT_DTPREL16_HA; break; |
| 1605 |
case BFD_RELOC_PPC_EMB_NADDR32: r = R_PPC_EMB_NADDR32; break; |
| 1606 |
case BFD_RELOC_PPC_EMB_NADDR16: r = R_PPC_EMB_NADDR16; break; |
| 1607 |
case BFD_RELOC_PPC_EMB_NADDR16_LO: r = R_PPC_EMB_NADDR16_LO; break; |
| 1608 |
case BFD_RELOC_PPC_EMB_NADDR16_HI: r = R_PPC_EMB_NADDR16_HI; break; |
| 1609 |
case BFD_RELOC_PPC_EMB_NADDR16_HA: r = R_PPC_EMB_NADDR16_HA; break; |
| 1610 |
case BFD_RELOC_PPC_EMB_SDAI16: r = R_PPC_EMB_SDAI16; break; |
| 1611 |
case BFD_RELOC_PPC_EMB_SDA2I16: r = R_PPC_EMB_SDA2I16; break; |
| 1612 |
case BFD_RELOC_PPC_EMB_SDA2REL: r = R_PPC_EMB_SDA2REL; break; |
| 1613 |
case BFD_RELOC_PPC_EMB_SDA21: r = R_PPC_EMB_SDA21; break; |
| 1614 |
case BFD_RELOC_PPC_EMB_MRKREF: r = R_PPC_EMB_MRKREF; break; |
| 1615 |
case BFD_RELOC_PPC_EMB_RELSEC16: r = R_PPC_EMB_RELSEC16; break; |
| 1616 |
case BFD_RELOC_PPC_EMB_RELST_LO: r = R_PPC_EMB_RELST_LO; break; |
| 1617 |
case BFD_RELOC_PPC_EMB_RELST_HI: r = R_PPC_EMB_RELST_HI; break; |
| 1618 |
case BFD_RELOC_PPC_EMB_RELST_HA: r = R_PPC_EMB_RELST_HA; break; |
| 1619 |
case BFD_RELOC_PPC_EMB_BIT_FLD: r = R_PPC_EMB_BIT_FLD; break; |
| 1620 |
case BFD_RELOC_PPC_EMB_RELSDA: r = R_PPC_EMB_RELSDA; break; |
| 1621 |
case BFD_RELOC_16_PCREL: r = R_PPC_REL16; break; |
| 1622 |
case BFD_RELOC_LO16_PCREL: r = R_PPC_REL16_LO; break; |
| 1623 |
case BFD_RELOC_HI16_PCREL: r = R_PPC_REL16_HI; break; |
| 1624 |
case BFD_RELOC_HI16_S_PCREL: r = R_PPC_REL16_HA; break; |
| 1625 |
case BFD_RELOC_VTABLE_INHERIT: r = R_PPC_GNU_VTINHERIT; break; |
| 1626 |
case BFD_RELOC_VTABLE_ENTRY: r = R_PPC_GNU_VTENTRY; break; |
| 1627 |
} |
| 1628 |
|
| 1629 |
return ppc_elf_howto_table[r]; |
| 1630 |
}; |
| 1631 |
|
| 1632 |
static reloc_howto_type * |
| 1633 |
ppc_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, |
| 1634 |
const char *r_name) |
| 1635 |
{ |
| 1636 |
unsigned int i; |
| 1637 |
|
| 1638 |
for (i = 0; |
| 1639 |
i < sizeof (ppc_elf_howto_raw) / sizeof (ppc_elf_howto_raw[0]); |
| 1640 |
i++) |
| 1641 |
if (ppc_elf_howto_raw[i].name != NULL |
| 1642 |
&& strcasecmp (ppc_elf_howto_raw[i].name, r_name) == 0) |
| 1643 |
return &ppc_elf_howto_raw[i]; |
| 1644 |
|
| 1645 |
return NULL; |
| 1646 |
} |
| 1647 |
|
| 1648 |
/* Set the howto pointer for a PowerPC ELF reloc. */ |
| 1649 |
|
| 1650 |
static void |
| 1651 |
ppc_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, |
| 1652 |
arelent *cache_ptr, |
| 1653 |
Elf_Internal_Rela *dst) |
| 1654 |
{ |
| 1655 |
/* Initialize howto table if not already done. */ |
| 1656 |
if (!ppc_elf_howto_table[R_PPC_ADDR32]) |
| 1657 |
ppc_elf_howto_init (); |
| 1658 |
|
| 1659 |
BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_PPC_max); |
| 1660 |
cache_ptr->howto = ppc_elf_howto_table[ELF32_R_TYPE (dst->r_info)]; |
| 1661 |
|
| 1662 |
/* Just because the above assert didn't trigger doesn't mean that |
| 1663 |
ELF32_R_TYPE (dst->r_info) is necessarily a valid relocation. */ |
| 1664 |
if (!cache_ptr->howto) |
| 1665 |
{ |
| 1666 |
(*_bfd_error_handler) (_("%B: invalid relocation type %d"), |
| 1667 |
abfd, ELF32_R_TYPE (dst->r_info)); |
| 1668 |
bfd_set_error (bfd_error_bad_value); |
| 1669 |
|
| 1670 |
cache_ptr->howto = ppc_elf_howto_table[R_PPC_NONE]; |
| 1671 |
} |
| 1672 |
} |
| 1673 |
|
| 1674 |
/* Handle the R_PPC_ADDR16_HA and R_PPC_REL16_HA relocs. */ |
| 1675 |
|
| 1676 |
static bfd_reloc_status_type |
| 1677 |
ppc_elf_addr16_ha_reloc (bfd *abfd ATTRIBUTE_UNUSED, |
| 1678 |
arelent *reloc_entry, |
| 1679 |
asymbol *symbol, |
| 1680 |
void *data ATTRIBUTE_UNUSED, |
| 1681 |
asection *input_section, |
| 1682 |
bfd *output_bfd, |
| 1683 |
char **error_message ATTRIBUTE_UNUSED) |
| 1684 |
{ |
| 1685 |
bfd_vma relocation; |
| 1686 |
|
| 1687 |
if (output_bfd != NULL) |
| 1688 |
{ |
| 1689 |
reloc_entry->address += input_section->output_offset; |
| 1690 |
return bfd_reloc_ok; |
| 1691 |
} |
| 1692 |
|
| 1693 |
if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) |
| 1694 |
return bfd_reloc_outofrange; |
| 1695 |
|
| 1696 |
if (bfd_is_com_section (symbol->section)) |
| 1697 |
relocation = 0; |
| 1698 |
else |
| 1699 |
relocation = symbol->value; |
| 1700 |
|
| 1701 |
relocation += symbol->section->output_section->vma; |
| 1702 |
relocation += symbol->section->output_offset; |
| 1703 |
relocation += reloc_entry->addend; |
| 1704 |
if (reloc_entry->howto->pc_relative) |
| 1705 |
relocation -= reloc_entry->address; |
| 1706 |
|
| 1707 |
reloc_entry->addend += (relocation & 0x8000) << 1; |
| 1708 |
|
| 1709 |
return bfd_reloc_continue; |
| 1710 |
} |
| 1711 |
|
| 1712 |
static bfd_reloc_status_type |
| 1713 |
ppc_elf_unhandled_reloc (bfd *abfd, |
| 1714 |
arelent *reloc_entry, |
| 1715 |
asymbol *symbol, |
| 1716 |
void *data, |
| 1717 |
asection *input_section, |
| 1718 |
bfd *output_bfd, |
| 1719 |
char **error_message) |
| 1720 |
{ |
| 1721 |
/* If this is a relocatable link (output_bfd test tells us), just |
| 1722 |
call the generic function. Any adjustment will be done at final |
| 1723 |
link time. */ |
| 1724 |
if (output_bfd != NULL) |
| 1725 |
return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, |
| 1726 |
input_section, output_bfd, error_message); |
| 1727 |
|
| 1728 |
if (error_message != NULL) |
| 1729 |
{ |
| 1730 |
static char buf[60]; |
| 1731 |
sprintf (buf, _("generic linker can't handle %s"), |
| 1732 |
reloc_entry->howto->name); |
| 1733 |
*error_message = buf; |
| 1734 |
} |
| 1735 |
return bfd_reloc_dangerous; |
| 1736 |
} |
| 1737 |
|
| 1738 |
/* Sections created by the linker. */ |
| 1739 |
|
| 1740 |
typedef struct elf_linker_section |
| 1741 |
{ |
| 1742 |
/* Pointer to the bfd section. */ |
| 1743 |
asection *section; |
| 1744 |
/* Section name. */ |
| 1745 |
const char *name; |
| 1746 |
/* Associated bss section name. */ |
| 1747 |
const char *bss_name; |
| 1748 |
/* Associated symbol name. */ |
| 1749 |
const char *sym_name; |
| 1750 |
/* Associated symbol. */ |
| 1751 |
struct elf_link_hash_entry *sym; |
| 1752 |
} elf_linker_section_t; |
| 1753 |
|
| 1754 |
/* Linked list of allocated pointer entries. This hangs off of the |
| 1755 |
symbol lists, and provides allows us to return different pointers, |
| 1756 |
based on different addend's. */ |
| 1757 |
|
| 1758 |
typedef struct elf_linker_section_pointers |
| 1759 |
{ |
| 1760 |
/* next allocated pointer for this symbol */ |
| 1761 |
struct elf_linker_section_pointers *next; |
| 1762 |
/* offset of pointer from beginning of section */ |
| 1763 |
bfd_vma offset; |
| 1764 |
/* addend used */ |
| 1765 |
bfd_vma addend; |
| 1766 |
/* which linker section this is */ |
| 1767 |
elf_linker_section_t *lsect; |
| 1768 |
} elf_linker_section_pointers_t; |
| 1769 |
|
| 1770 |
struct ppc_elf_obj_tdata |
| 1771 |
{ |
| 1772 |
struct elf_obj_tdata elf; |
| 1773 |
|
| 1774 |
/* A mapping from local symbols to offsets into the various linker |
| 1775 |
sections added. This is index by the symbol index. */ |
| 1776 |
elf_linker_section_pointers_t **linker_section_pointers; |
| 1777 |
|
| 1778 |
/* Flags used to auto-detect plt type. */ |
| 1779 |
unsigned int makes_plt_call : 1; |
| 1780 |
unsigned int has_rel16 : 1; |
| 1781 |
}; |
| 1782 |
|
| 1783 |
#define ppc_elf_tdata(bfd) \ |
| 1784 |
((struct ppc_elf_obj_tdata *) (bfd)->tdata.any) |
| 1785 |
|
| 1786 |
#define elf_local_ptr_offsets(bfd) \ |
| 1787 |
(ppc_elf_tdata (bfd)->linker_section_pointers) |
| 1788 |
|
| 1789 |
#define is_ppc_elf(bfd) \ |
| 1790 |
(bfd_get_flavour (bfd) == bfd_target_elf_flavour \ |
| 1791 |
&& elf_object_id (bfd) == PPC32_ELF_TDATA) |
| 1792 |
|
| 1793 |
/* Override the generic function because we store some extras. */ |
| 1794 |
|
| 1795 |
static bfd_boolean |
| 1796 |
ppc_elf_mkobject (bfd *abfd) |
| 1797 |
{ |
| 1798 |
return bfd_elf_allocate_object (abfd, sizeof (struct ppc_elf_obj_tdata), |
| 1799 |
PPC32_ELF_TDATA); |
| 1800 |
} |
| 1801 |
|
| 1802 |
/* Fix bad default arch selected for a 32 bit input bfd when the |
| 1803 |
default is 64 bit. */ |
| 1804 |
|
| 1805 |
static bfd_boolean |
| 1806 |
ppc_elf_object_p (bfd *abfd) |
| 1807 |
{ |
| 1808 |
if (abfd->arch_info->the_default && abfd->arch_info->bits_per_word == 64) |
| 1809 |
{ |
| 1810 |
Elf_Internal_Ehdr *i_ehdr = elf_elfheader (abfd); |
| 1811 |
|
| 1812 |
if (i_ehdr->e_ident[EI_CLASS] == ELFCLASS32) |
| 1813 |
{ |
| 1814 |
/* Relies on arch after 64 bit default being 32 bit default. */ |
| 1815 |
abfd->arch_info = abfd->arch_info->next; |
| 1816 |
BFD_ASSERT (abfd->arch_info->bits_per_word == 32); |
| 1817 |
} |
| 1818 |
} |
| 1819 |
return TRUE; |
| 1820 |
} |
| 1821 |
|
| 1822 |
/* Function to set whether a module needs the -mrelocatable bit set. */ |
| 1823 |
|
| 1824 |
static bfd_boolean |
| 1825 |
ppc_elf_set_private_flags (bfd *abfd, flagword flags) |
| 1826 |
{ |
| 1827 |
BFD_ASSERT (!elf_flags_init (abfd) |
| 1828 |
|| elf_elfheader (abfd)->e_flags == flags); |
| 1829 |
|
| 1830 |
elf_elfheader (abfd)->e_flags = flags; |
| 1831 |
elf_flags_init (abfd) = TRUE; |
| 1832 |
return TRUE; |
| 1833 |
} |
| 1834 |
|
| 1835 |
/* Support for core dump NOTE sections. */ |
| 1836 |
|
| 1837 |
static bfd_boolean |
| 1838 |
ppc_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) |
| 1839 |
{ |
| 1840 |
int offset; |
| 1841 |
unsigned int size; |
| 1842 |
|
| 1843 |
switch (note->descsz) |
| 1844 |
{ |
| 1845 |
default: |
| 1846 |
return FALSE; |
| 1847 |
|
| 1848 |
case 268: /* Linux/PPC. */ |
| 1849 |
/* pr_cursig */ |
| 1850 |
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12); |
| 1851 |
|
| 1852 |
/* pr_pid */ |
| 1853 |
elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24); |
| 1854 |
|
| 1855 |
/* pr_reg */ |
| 1856 |
offset = 72; |
| 1857 |
size = 192; |
| 1858 |
|
| 1859 |
break; |
| 1860 |
} |
| 1861 |
|
| 1862 |
/* Make a ".reg/999" section. */ |
| 1863 |
return _bfd_elfcore_make_pseudosection (abfd, ".reg", |
| 1864 |
size, note->descpos + offset); |
| 1865 |
} |
| 1866 |
|
| 1867 |
static bfd_boolean |
| 1868 |
ppc_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) |
| 1869 |
{ |
| 1870 |
switch (note->descsz) |
| 1871 |
{ |
| 1872 |
default: |
| 1873 |
return FALSE; |
| 1874 |
|
| 1875 |
case 128: /* Linux/PPC elf_prpsinfo. */ |
| 1876 |
elf_tdata (abfd)->core_program |
| 1877 |
= _bfd_elfcore_strndup (abfd, note->descdata + 32, 16); |
| 1878 |
elf_tdata (abfd)->core_command |
| 1879 |
= _bfd_elfcore_strndup (abfd, note->descdata + 48, 80); |
| 1880 |
} |
| 1881 |
|
| 1882 |
/* Note that for some reason, a spurious space is tacked |
| 1883 |
onto the end of the args in some (at least one anyway) |
| 1884 |
implementations, so strip it off if it exists. */ |
| 1885 |
|
| 1886 |
{ |
| 1887 |
char *command = elf_tdata (abfd)->core_command; |
| 1888 |
int n = strlen (command); |
| 1889 |
|
| 1890 |
if (0 < n && command[n - 1] == ' ') |
| 1891 |
command[n - 1] = '\0'; |
| 1892 |
} |
| 1893 |
|
| 1894 |
return TRUE; |
| 1895 |
} |
| 1896 |
|
| 1897 |
static char * |
| 1898 |
ppc_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type, ...) |
| 1899 |
{ |
| 1900 |
switch (note_type) |
| 1901 |
{ |
| 1902 |
default: |
| 1903 |
return NULL; |
| 1904 |
|
| 1905 |
case NT_PRPSINFO: |
| 1906 |
{ |
| 1907 |
char data[128]; |
| 1908 |
va_list ap; |
| 1909 |
|
| 1910 |
va_start (ap, note_type); |
| 1911 |
memset (data, 0, 32); |
| 1912 |
strncpy (data + 32, va_arg (ap, const char *), 16); |
| 1913 |
strncpy (data + 48, va_arg (ap, const char *), 80); |
| 1914 |
va_end (ap); |
| 1915 |
return elfcore_write_note (abfd, buf, bufsiz, |
| 1916 |
"CORE", note_type, data, sizeof (data)); |
| 1917 |
} |
| 1918 |
|
| 1919 |
case NT_PRSTATUS: |
| 1920 |
{ |
| 1921 |
char data[268]; |
| 1922 |
va_list ap; |
| 1923 |
long pid; |
| 1924 |
int cursig; |
| 1925 |
const void *greg; |
| 1926 |
|
| 1927 |
va_start (ap, note_type); |
| 1928 |
memset (data, 0, 72); |
| 1929 |
pid = va_arg (ap, long); |
| 1930 |
bfd_put_32 (abfd, pid, data + 24); |
| 1931 |
cursig = va_arg (ap, int); |
| 1932 |
bfd_put_16 (abfd, cursig, data + 12); |
| 1933 |
greg = va_arg (ap, const void *); |
| 1934 |
memcpy (data + 72, greg, 192); |
| 1935 |
memset (data + 264, 0, 4); |
| 1936 |
va_end (ap); |
| 1937 |
return elfcore_write_note (abfd, buf, bufsiz, |
| 1938 |
"CORE", note_type, data, sizeof (data)); |
| 1939 |
} |
| 1940 |
} |
| 1941 |
} |
| 1942 |
|
| 1943 |
/* Return address for Ith PLT stub in section PLT, for relocation REL |
| 1944 |
or (bfd_vma) -1 if it should not be included. */ |
| 1945 |
|
| 1946 |
static bfd_vma |
| 1947 |
ppc_elf_plt_sym_val (bfd_vma i ATTRIBUTE_UNUSED, |
| 1948 |
const asection *plt ATTRIBUTE_UNUSED, |
| 1949 |
const arelent *rel) |
| 1950 |
{ |
| 1951 |
return rel->address; |
| 1952 |
} |
| 1953 |
|
| 1954 |
/* Handle a PowerPC specific section when reading an object file. This |
| 1955 |
is called when bfd_section_from_shdr finds a section with an unknown |
| 1956 |
type. */ |
| 1957 |
|
| 1958 |
static bfd_boolean |
| 1959 |
ppc_elf_section_from_shdr (bfd *abfd, |
| 1960 |
Elf_Internal_Shdr *hdr, |
| 1961 |
const char *name, |
| 1962 |
int shindex) |
| 1963 |
{ |
| 1964 |
asection *newsect; |
| 1965 |
flagword flags; |
| 1966 |
|
| 1967 |
if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex)) |
| 1968 |
return FALSE; |
| 1969 |
|
| 1970 |
newsect = hdr->bfd_section; |
| 1971 |
flags = bfd_get_section_flags (abfd, newsect); |
| 1972 |
if (hdr->sh_flags & SHF_EXCLUDE) |
| 1973 |
flags |= SEC_EXCLUDE; |
| 1974 |
|
| 1975 |
if (hdr->sh_type == SHT_ORDERED) |
| 1976 |
flags |= SEC_SORT_ENTRIES; |
| 1977 |
|
| 1978 |
bfd_set_section_flags (abfd, newsect, flags); |
| 1979 |
return TRUE; |
| 1980 |
} |
| 1981 |
|
| 1982 |
/* Set up any other section flags and such that may be necessary. */ |
| 1983 |
|
| 1984 |
static bfd_boolean |
| 1985 |
ppc_elf_fake_sections (bfd *abfd ATTRIBUTE_UNUSED, |
| 1986 |
Elf_Internal_Shdr *shdr, |
| 1987 |
asection *asect) |
| 1988 |
{ |
| 1989 |
if ((asect->flags & (SEC_GROUP | SEC_EXCLUDE)) == SEC_EXCLUDE) |
| 1990 |
shdr->sh_flags |= SHF_EXCLUDE; |
| 1991 |
|
| 1992 |
if ((asect->flags & SEC_SORT_ENTRIES) != 0) |
| 1993 |
shdr->sh_type = SHT_ORDERED; |
| 1994 |
|
| 1995 |
return TRUE; |
| 1996 |
} |
| 1997 |
|
| 1998 |
/* If we have .sbss2 or .PPC.EMB.sbss0 output sections, we |
| 1999 |
need to bump up the number of section headers. */ |
| 2000 |
|
| 2001 |
static int |
| 2002 |
ppc_elf_additional_program_headers (bfd *abfd, |
| 2003 |
struct bfd_link_info *info ATTRIBUTE_UNUSED) |
| 2004 |
{ |
| 2005 |
asection *s; |
| 2006 |
int ret = 0; |
| 2007 |
|
| 2008 |
s = bfd_get_section_by_name (abfd, ".sbss2"); |
| 2009 |
if (s != NULL && (s->flags & SEC_ALLOC) != 0) |
| 2010 |
++ret; |
| 2011 |
|
| 2012 |
s = bfd_get_section_by_name (abfd, ".PPC.EMB.sbss0"); |
| 2013 |
if (s != NULL && (s->flags & SEC_ALLOC) != 0) |
| 2014 |
++ret; |
| 2015 |
|
| 2016 |
return ret; |
| 2017 |
} |
| 2018 |
|
| 2019 |
/* Add extra PPC sections -- Note, for now, make .sbss2 and |
| 2020 |
.PPC.EMB.sbss0 a normal section, and not a bss section so |
| 2021 |
that the linker doesn't crater when trying to make more than |
| 2022 |
2 sections. */ |
| 2023 |
|
| 2024 |
static const struct bfd_elf_special_section ppc_elf_special_sections[] = |
| 2025 |
{ |
| 2026 |
{ STRING_COMMA_LEN (".plt"), 0, SHT_NOBITS, SHF_ALLOC + SHF_EXECINSTR }, |
| 2027 |
{ STRING_COMMA_LEN (".sbss"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, |
| 2028 |
{ STRING_COMMA_LEN (".sbss2"), -2, SHT_PROGBITS, SHF_ALLOC }, |
| 2029 |
{ STRING_COMMA_LEN (".sdata"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, |
| 2030 |
{ STRING_COMMA_LEN (".sdata2"), -2, SHT_PROGBITS, SHF_ALLOC }, |
| 2031 |
{ STRING_COMMA_LEN (".tags"), 0, SHT_ORDERED, SHF_ALLOC }, |
| 2032 |
{ STRING_COMMA_LEN (".PPC.EMB.apuinfo"), 0, SHT_NOTE, 0 }, |
| 2033 |
{ STRING_COMMA_LEN (".PPC.EMB.sbss0"), 0, SHT_PROGBITS, SHF_ALLOC }, |
| 2034 |
{ STRING_COMMA_LEN (".PPC.EMB.sdata0"), 0, SHT_PROGBITS, SHF_ALLOC }, |
| 2035 |
{ NULL, 0, 0, 0, 0 } |
| 2036 |
}; |
| 2037 |
|
| 2038 |
/* This is what we want for new plt/got. */ |
| 2039 |
static struct bfd_elf_special_section ppc_alt_plt = |
| 2040 |
{ STRING_COMMA_LEN (".plt"), 0, SHT_PROGBITS, SHF_ALLOC }; |
| 2041 |
|
| 2042 |
static const struct bfd_elf_special_section * |
| 2043 |
ppc_elf_get_sec_type_attr (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) |
| 2044 |
{ |
| 2045 |
const struct bfd_elf_special_section *ssect; |
| 2046 |
|
| 2047 |
/* See if this is one of the special sections. */ |
| 2048 |
if (sec->name == NULL) |
| 2049 |
return NULL; |
| 2050 |
|
| 2051 |
ssect = _bfd_elf_get_special_section (sec->name, ppc_elf_special_sections, |
| 2052 |
sec->use_rela_p); |
| 2053 |
if (ssect != NULL) |
| 2054 |
{ |
| 2055 |
if (ssect == ppc_elf_special_sections && (sec->flags & SEC_LOAD) != 0) |
| 2056 |
ssect = &ppc_alt_plt; |
| 2057 |
return ssect; |
| 2058 |
} |
| 2059 |
|
| 2060 |
return _bfd_elf_get_sec_type_attr (abfd, sec); |
| 2061 |
} |
| 2062 |
|
| 2063 |
/* Very simple linked list structure for recording apuinfo values. */ |
| 2064 |
typedef struct apuinfo_list |
| 2065 |
{ |
| 2066 |
struct apuinfo_list *next; |
| 2067 |
unsigned long value; |
| 2068 |
} |
| 2069 |
apuinfo_list; |
| 2070 |
|
| 2071 |
static apuinfo_list *head; |
| 2072 |
|
| 2073 |
|
| 2074 |
static void |
| 2075 |
apuinfo_list_init (void) |
| 2076 |
{ |
| 2077 |
head = NULL; |
| 2078 |
} |
| 2079 |
|
| 2080 |
static void |
| 2081 |
apuinfo_list_add (unsigned long value) |
| 2082 |
{ |
| 2083 |
apuinfo_list *entry = head; |
| 2084 |
|
| 2085 |
while (entry != NULL) |
| 2086 |
{ |
| 2087 |
if (entry->value == value) |
| 2088 |
return; |
| 2089 |
entry = entry->next; |
| 2090 |
} |
| 2091 |
|
| 2092 |
entry = bfd_malloc (sizeof (* entry)); |
| 2093 |
if (entry == NULL) |
| 2094 |
return; |
| 2095 |
|
| 2096 |
entry->value = value; |
| 2097 |
entry->next = head; |
| 2098 |
head = entry; |
| 2099 |
} |
| 2100 |
|
| 2101 |
static unsigned |
| 2102 |
apuinfo_list_length (void) |
| 2103 |
{ |
| 2104 |
apuinfo_list *entry; |
| 2105 |
unsigned long count; |
| 2106 |
|
| 2107 |
for (entry = head, count = 0; |
| 2108 |
entry; |
| 2109 |
entry = entry->next) |
| 2110 |
++ count; |
| 2111 |
|
| 2112 |
return count; |
| 2113 |
} |
| 2114 |
|
| 2115 |
static inline unsigned long |
| 2116 |
apuinfo_list_element (unsigned long number) |
| 2117 |
{ |
| 2118 |
apuinfo_list * entry; |
| 2119 |
|
| 2120 |
for (entry = head; |
| 2121 |
entry && number --; |
| 2122 |
entry = entry->next) |
| 2123 |
; |
| 2124 |
|
| 2125 |
return entry ? entry->value : 0; |
| 2126 |
} |
| 2127 |
|
| 2128 |
static void |
| 2129 |
apuinfo_list_finish (void) |
| 2130 |
{ |
| 2131 |
apuinfo_list *entry; |
| 2132 |
|
| 2133 |
for (entry = head; entry;) |
| 2134 |
{ |
| 2135 |
apuinfo_list *next = entry->next; |
| 2136 |
free (entry); |
| 2137 |
entry = next; |
| 2138 |
} |
| 2139 |
|
| 2140 |
head = NULL; |
| 2141 |
} |
| 2142 |
|
| 2143 |
#define APUINFO_SECTION_NAME ".PPC.EMB.apuinfo" |
| 2144 |
#define APUINFO_LABEL "APUinfo" |
| 2145 |
|
| 2146 |
/* Scan the input BFDs and create a linked list of |
| 2147 |
the APUinfo values that will need to be emitted. */ |
| 2148 |
|
| 2149 |
static void |
| 2150 |
ppc_elf_begin_write_processing (bfd *abfd, struct bfd_link_info *link_info) |
| 2151 |
{ |
| 2152 |
bfd *ibfd; |
| 2153 |
asection *asec; |
| 2154 |
char *buffer; |
| 2155 |
unsigned num_input_sections; |
| 2156 |
bfd_size_type output_section_size; |
| 2157 |
unsigned i; |
| 2158 |
unsigned num_entries; |
| 2159 |
unsigned long offset; |
| 2160 |
unsigned long length; |
| 2161 |
const char *error_message = NULL; |
| 2162 |
|
| 2163 |
if (link_info == NULL) |
| 2164 |
return; |
| 2165 |
|
| 2166 |
/* Scan the input bfds, looking for apuinfo sections. */ |
| 2167 |
num_input_sections = 0; |
| 2168 |
output_section_size = 0; |
| 2169 |
|
| 2170 |
for (ibfd = link_info->input_bfds; ibfd; ibfd = ibfd->link_next) |
| 2171 |
{ |
| 2172 |
asec = bfd_get_section_by_name (ibfd, APUINFO_SECTION_NAME); |
| 2173 |
if (asec) |
| 2174 |
{ |
| 2175 |
++ num_input_sections; |
| 2176 |
output_section_size += asec->size; |
| 2177 |
} |
| 2178 |
} |
| 2179 |
|
| 2180 |
/* We need at least one input sections |
| 2181 |
in order to make merging worthwhile. */ |
| 2182 |
if (num_input_sections < 1) |
| 2183 |
return; |
| 2184 |
|
| 2185 |
/* Just make sure that the output section exists as well. */ |
| 2186 |
asec = bfd_get_section_by_name (abfd, APUINFO_SECTION_NAME); |
| 2187 |
if (asec == NULL) |
| 2188 |
return; |
| 2189 |
|
| 2190 |
/* Allocate a buffer for the contents of the input sections. */ |
| 2191 |
buffer = bfd_malloc (output_section_size); |
| 2192 |
if (buffer == NULL) |
| 2193 |
return; |
| 2194 |
|
| 2195 |
offset = 0; |
| 2196 |
apuinfo_list_init (); |
| 2197 |
|
| 2198 |
/* Read in the input sections contents. */ |
| 2199 |
for (ibfd = link_info->input_bfds; ibfd; ibfd = ibfd->link_next) |
| 2200 |
{ |
| 2201 |
unsigned long datum; |
| 2202 |
char *ptr; |
| 2203 |
|
| 2204 |
asec = bfd_get_section_by_name (ibfd, APUINFO_SECTION_NAME); |
| 2205 |
if (asec == NULL) |
| 2206 |
continue; |
| 2207 |
|
| 2208 |
length = asec->size; |
| 2209 |
if (length < 24) |
| 2210 |
{ |
| 2211 |
error_message = _("corrupt or empty %s section in %B"); |
| 2212 |
goto fail; |
| 2213 |
} |
| 2214 |
|
| 2215 |
if (bfd_seek (ibfd, asec->filepos, SEEK_SET) != 0 |
| 2216 |
|| (bfd_bread (buffer + offset, length, ibfd) != length)) |
| 2217 |
{ |
| 2218 |
error_message = _("unable to read in %s section from %B"); |
| 2219 |
goto fail; |
| 2220 |
} |
| 2221 |
|
| 2222 |
/* Process the contents of the section. */ |
| 2223 |
ptr = buffer + offset; |
| 2224 |
error_message = _("corrupt %s section in %B"); |
| 2225 |
|
| 2226 |
/* Verify the contents of the header. Note - we have to |
| 2227 |
extract the values this way in order to allow for a |
| 2228 |
host whose endian-ness is different from the target. */ |
| 2229 |
datum = bfd_get_32 (ibfd, ptr); |
| 2230 |
if (datum != sizeof APUINFO_LABEL) |
| 2231 |
goto fail; |
| 2232 |
|
| 2233 |
datum = bfd_get_32 (ibfd, ptr + 8); |
| 2234 |
if (datum != 0x2) |
| 2235 |
goto fail; |
| 2236 |
|
| 2237 |
if (strcmp (ptr + 12, APUINFO_LABEL) != 0) |
| 2238 |
goto fail; |
| 2239 |
|
| 2240 |
/* Get the number of bytes used for apuinfo entries. */ |
| 2241 |
datum = bfd_get_32 (ibfd, ptr + 4); |
| 2242 |
if (datum + 20 != length) |
| 2243 |
goto fail; |
| 2244 |
|
| 2245 |
/* Make sure that we do not run off the end of the section. */ |
| 2246 |
if (offset + length > output_section_size) |
| 2247 |
goto fail; |
| 2248 |
|
| 2249 |
/* Scan the apuinfo section, building a list of apuinfo numbers. */ |
| 2250 |
for (i = 0; i < datum; i += 4) |
| 2251 |
apuinfo_list_add (bfd_get_32 (ibfd, ptr + 20 + i)); |
| 2252 |
|
| 2253 |
/* Update the offset. */ |
| 2254 |
offset += length; |
| 2255 |
} |
| 2256 |
|
| 2257 |
error_message = NULL; |
| 2258 |
|
| 2259 |
/* Compute the size of the output section. */ |
| 2260 |
num_entries = apuinfo_list_length (); |
| 2261 |
output_section_size = 20 + num_entries * 4; |
| 2262 |
|
| 2263 |
asec = bfd_get_section_by_name (abfd, APUINFO_SECTION_NAME); |
| 2264 |
|
| 2265 |
if (! bfd_set_section_size (abfd, asec, output_section_size)) |
| 2266 |
ibfd = abfd, |
| 2267 |
error_message = _("warning: unable to set size of %s section in %B"); |
| 2268 |
|
| 2269 |
fail: |
| 2270 |
free (buffer); |
| 2271 |
|
| 2272 |
if (error_message) |
| 2273 |
(*_bfd_error_handler) (error_message, ibfd, APUINFO_SECTION_NAME); |
| 2274 |
} |
| 2275 |
|
| 2276 |
/* Prevent the output section from accumulating the input sections' |
| 2277 |
contents. We have already stored this in our linked list structure. */ |
| 2278 |
|
| 2279 |
static bfd_boolean |
| 2280 |
ppc_elf_write_section (bfd *abfd ATTRIBUTE_UNUSED, |
| 2281 |
struct bfd_link_info *link_info ATTRIBUTE_UNUSED, |
| 2282 |
asection *asec, |
| 2283 |
bfd_byte *contents ATTRIBUTE_UNUSED) |
| 2284 |
{ |
| 2285 |
return (apuinfo_list_length () |
| 2286 |
&& strcmp (asec->name, APUINFO_SECTION_NAME) == 0); |
| 2287 |
} |
| 2288 |
|
| 2289 |
/* Finally we can generate the output section. */ |
| 2290 |
|
| 2291 |
static void |
| 2292 |
ppc_elf_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED) |
| 2293 |
{ |
| 2294 |
bfd_byte *buffer; |
| 2295 |
asection *asec; |
| 2296 |
unsigned i; |
| 2297 |
unsigned num_entries; |
| 2298 |
bfd_size_type length; |
| 2299 |
|
| 2300 |
asec = bfd_get_section_by_name (abfd, APUINFO_SECTION_NAME); |
| 2301 |
if (asec == NULL) |
| 2302 |
return; |
| 2303 |
|
| 2304 |
if (apuinfo_list_length () == 0) |
| 2305 |
return; |
| 2306 |
|
| 2307 |
length = asec->size; |
| 2308 |
if (length < 20) |
| 2309 |
return; |
| 2310 |
|
| 2311 |
buffer = bfd_malloc (length); |
| 2312 |
if (buffer == NULL) |
| 2313 |
{ |
| 2314 |
(*_bfd_error_handler) |
| 2315 |
(_("failed to allocate space for new APUinfo section.")); |
| 2316 |
return; |
| 2317 |
} |
| 2318 |
|
| 2319 |
/* Create the apuinfo header. */ |
| 2320 |
num_entries = apuinfo_list_length (); |
| 2321 |
bfd_put_32 (abfd, sizeof APUINFO_LABEL, buffer); |
| 2322 |
bfd_put_32 (abfd, num_entries * 4, buffer + 4); |
| 2323 |
bfd_put_32 (abfd, 0x2, buffer + 8); |
| 2324 |
strcpy ((char *) buffer + 12, APUINFO_LABEL); |
| 2325 |
|
| 2326 |
length = 20; |
| 2327 |
for (i = 0; i < num_entries; i++) |
| 2328 |
{ |
| 2329 |
bfd_put_32 (abfd, apuinfo_list_element (i), buffer + length); |
| 2330 |
length += 4; |
| 2331 |
} |
| 2332 |
|
| 2333 |
if (length != asec->size) |
| 2334 |
(*_bfd_error_handler) (_("failed to compute new APUinfo section.")); |
| 2335 |
|
| 2336 |
if (! bfd_set_section_contents (abfd, asec, buffer, (file_ptr) 0, length)) |
| 2337 |
(*_bfd_error_handler) (_("failed to install new APUinfo section.")); |
| 2338 |
|
| 2339 |
free (buffer); |
| 2340 |
|
| 2341 |
apuinfo_list_finish (); |
| 2342 |
} |
| 2343 |
|
| 2344 |
static bfd_boolean |
| 2345 |
is_nonpic_glink_stub (bfd *abfd, asection *glink, bfd_vma off) |
| 2346 |
{ |
| 2347 |
bfd_byte buf[GLINK_ENTRY_SIZE]; |
| 2348 |
|
| 2349 |
if (!bfd_get_section_contents (abfd, glink, buf, off, GLINK_ENTRY_SIZE)) |
| 2350 |
return FALSE; |
| 2351 |
|
| 2352 |
return ((bfd_get_32 (abfd, buf + 0) & 0xffff0000) == LIS_11 |
| 2353 |
&& (bfd_get_32 (abfd, buf + 4) & 0xffff0000) == LWZ_11_11 |
| 2354 |
&& bfd_get_32 (abfd, buf + 8) == MTCTR_11 |
| 2355 |
&& bfd_get_32 (abfd, buf + 12) == BCTR); |
| 2356 |
} |
| 2357 |
|
| 2358 |
static bfd_boolean |
| 2359 |
section_covers_vma (bfd *abfd ATTRIBUTE_UNUSED, asection *section, void *ptr) |
| 2360 |
{ |
| 2361 |
bfd_vma vma = *(bfd_vma *) ptr; |
| 2362 |
return ((section->flags & SEC_ALLOC) != 0 |
| 2363 |
&& section->vma <= vma |
| 2364 |
&& vma < section->vma + section->size); |
| 2365 |
} |
| 2366 |
|
| 2367 |
static long |
| 2368 |
ppc_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms, |
| 2369 |
long dynsymcount, asymbol **dynsyms, |
| 2370 |
asymbol **ret) |
| 2371 |
{ |
| 2372 |
bfd_boolean (*slurp_relocs) (bfd *, asection *, asymbol **, bfd_boolean); |
| 2373 |
asection *plt, *relplt, *dynamic, *glink; |
| 2374 |
bfd_vma glink_vma = 0; |
| 2375 |
bfd_vma resolv_vma = 0; |
| 2376 |
bfd_vma stub_vma; |
| 2377 |
asymbol *s; |
| 2378 |
arelent *p; |
| 2379 |
long count, i; |
| 2380 |
size_t size; |
| 2381 |
char *names; |
| 2382 |
bfd_byte buf[4]; |
| 2383 |
|
| 2384 |
*ret = NULL; |
| 2385 |
|
| 2386 |
if ((abfd->flags & (DYNAMIC | EXEC_P)) == 0) |
| 2387 |
return 0; |
| 2388 |
|
| 2389 |
if (dynsymcount <= 0) |
| 2390 |
return 0; |
| 2391 |
|
| 2392 |
relplt = bfd_get_section_by_name (abfd, ".rela.plt"); |
| 2393 |
if (relplt == NULL) |
| 2394 |
return 0; |
| 2395 |
|
| 2396 |
plt = bfd_get_section_by_name (abfd, ".plt"); |
| 2397 |
if (plt == NULL) |
| 2398 |
return 0; |
| 2399 |
|
| 2400 |
/* Call common code to handle old-style executable PLTs. */ |
| 2401 |
if (elf_section_flags (plt) & SHF_EXECINSTR) |
| 2402 |
return _bfd_elf_get_synthetic_symtab (abfd, symcount, syms, |
| 2403 |
dynsymcount, dynsyms, ret); |
| 2404 |
|
| 2405 |
/* If this object was prelinked, the prelinker stored the address |
| 2406 |
of .glink at got[1]. If it wasn't prelinked, got[1] will be zero. */ |
| 2407 |
dynamic = bfd_get_section_by_name (abfd, ".dynamic"); |
| 2408 |
if (dynamic != NULL) |
| 2409 |
{ |
| 2410 |
bfd_byte *dynbuf, *extdyn, *extdynend; |
| 2411 |
size_t extdynsize; |
| 2412 |
void (*swap_dyn_in) (bfd *, const void *, Elf_Internal_Dyn *); |
| 2413 |
|
| 2414 |
if (!bfd_malloc_and_get_section (abfd, dynamic, &dynbuf)) |
| 2415 |
return -1; |
| 2416 |
|
| 2417 |
extdynsize = get_elf_backend_data (abfd)->s->sizeof_dyn; |
| 2418 |
swap_dyn_in = get_elf_backend_data (abfd)->s->swap_dyn_in; |
| 2419 |
|
| 2420 |
extdyn = dynbuf; |
| 2421 |
extdynend = extdyn + dynamic->size; |
| 2422 |
for (; extdyn < extdynend; extdyn += extdynsize) |
| 2423 |
{ |
| 2424 |
Elf_Internal_Dyn dyn; |
| 2425 |
(*swap_dyn_in) (abfd, extdyn, &dyn); |
| 2426 |
|
| 2427 |
if (dyn.d_tag == DT_NULL) |
| 2428 |
break; |
| 2429 |
|
| 2430 |
if (dyn.d_tag == DT_PPC_GOT) |
| 2431 |
{ |
| 2432 |
unsigned int g_o_t = dyn.d_un.d_val; |
| 2433 |
asection *got = bfd_get_section_by_name (abfd, ".got"); |
| 2434 |
if (got != NULL |
| 2435 |
&& bfd_get_section_contents (abfd, got, buf, |
| 2436 |
g_o_t - got->vma + 4, 4)) |
| 2437 |
glink_vma = bfd_get_32 (abfd, buf); |
| 2438 |
break; |
| 2439 |
} |
| 2440 |
} |
| 2441 |
free (dynbuf); |
| 2442 |
} |
| 2443 |
|
| 2444 |
/* Otherwise we read the first plt entry. */ |
| 2445 |
if (glink_vma == 0) |
| 2446 |
{ |
| 2447 |
if (bfd_get_section_contents (abfd, plt, buf, 0, 4)) |
| 2448 |
glink_vma = bfd_get_32 (abfd, buf); |
| 2449 |
} |
| 2450 |
|
| 2451 |
if (glink_vma == 0) |
| 2452 |
return 0; |
| 2453 |
|
| 2454 |
/* The .glink section usually does not survive the final |
| 2455 |
link; search for the section (usually .text) where the |
| 2456 |
glink stubs now reside. */ |
| 2457 |
glink = bfd_sections_find_if (abfd, section_covers_vma, &glink_vma); |
| 2458 |
if (glink == NULL) |
| 2459 |
return 0; |
| 2460 |
|
| 2461 |
/* Determine glink PLT resolver by reading the relative branch |
| 2462 |
from the first glink stub. */ |
| 2463 |
if (bfd_get_section_contents (abfd, glink, buf, |
| 2464 |
glink_vma - glink->vma, 4)) |
| 2465 |
{ |
| 2466 |
unsigned int insn = bfd_get_32 (abfd, buf); |
| 2467 |
|
| 2468 |
/* The first glink stub may either branch to the resolver ... */ |
| 2469 |
insn ^= B; |
| 2470 |
if ((insn & ~0x3fffffc) == 0) |
| 2471 |
resolv_vma = glink_vma + (insn ^ 0x2000000) - 0x2000000; |
| 2472 |
|
| 2473 |
/* ... or fall through a bunch of NOPs. */ |
| 2474 |
else if ((insn ^ B ^ NOP) == 0) |
| 2475 |
for (i = 4; |
| 2476 |
bfd_get_section_contents (abfd, glink, buf, |
| 2477 |
glink_vma - glink->vma + i, 4); |
| 2478 |
i += 4) |
| 2479 |
if (bfd_get_32 (abfd, buf) != NOP) |
| 2480 |
{ |
| 2481 |
resolv_vma = glink_vma + i; |
| 2482 |
break; |
| 2483 |
} |
| 2484 |
} |
| 2485 |
|
| 2486 |
count = relplt->size / sizeof (Elf32_External_Rela); |
| 2487 |
stub_vma = glink_vma - (bfd_vma) count * 16; |
| 2488 |
/* If the stubs are those for -shared/-pie then we might have |
| 2489 |
multiple stubs for each plt entry. If that is the case then |
| 2490 |
there is no way to associate stubs with their plt entries short |
| 2491 |
of figuring out the GOT pointer value used in the stub. */ |
| 2492 |
if (!is_nonpic_glink_stub (abfd, glink, |
| 2493 |
glink_vma - GLINK_ENTRY_SIZE - glink->vma)) |
| 2494 |
return 0; |
| 2495 |
|
| 2496 |
slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table; |
| 2497 |
if (! (*slurp_relocs) (abfd, relplt, dynsyms, TRUE)) |
| 2498 |
return -1; |
| 2499 |
|
| 2500 |
size = count * sizeof (asymbol); |
| 2501 |
p = relplt->relocation; |
| 2502 |
for (i = 0; i < count; i++, p++) |
| 2503 |
{ |
| 2504 |
size += strlen ((*p->sym_ptr_ptr)->name) + sizeof ("@plt"); |
| 2505 |
if (p->addend != 0) |
| 2506 |
size += sizeof ("+0x") - 1 + 8; |
| 2507 |
} |
| 2508 |
|
| 2509 |
size += sizeof (asymbol) + sizeof ("__glink"); |
| 2510 |
|
| 2511 |
if (resolv_vma) |
| 2512 |
size += sizeof (asymbol) + sizeof ("__glink_PLTresolve"); |
| 2513 |
|
| 2514 |
s = *ret = bfd_malloc (size); |
| 2515 |
if (s == NULL) |
| 2516 |
return -1; |
| 2517 |
|
| 2518 |
names = (char *) (s + count + 1 + (resolv_vma != 0)); |
| 2519 |
p = relplt->relocation; |
| 2520 |
for (i = 0; i < count; i++, p++) |
| 2521 |
{ |
| 2522 |
size_t len; |
| 2523 |
|
| 2524 |
*s = **p->sym_ptr_ptr; |
| 2525 |
/* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set. Since |
| 2526 |
we are defining a symbol, ensure one of them is set. */ |
| 2527 |
if ((s->flags & BSF_LOCAL) == 0) |
| 2528 |
s->flags |= BSF_GLOBAL; |
| 2529 |
s->flags |= BSF_SYNTHETIC; |
| 2530 |
s->section = glink; |
| 2531 |
s->value = stub_vma - glink->vma; |
| 2532 |
s->name = names; |
| 2533 |
s->udata.p = NULL; |
| 2534 |
len = strlen ((*p->sym_ptr_ptr)->name); |
| 2535 |
memcpy (names, (*p->sym_ptr_ptr)->name, len); |
| 2536 |
names += len; |
| 2537 |
if (p->addend != 0) |
| 2538 |
{ |
| 2539 |
memcpy (names, "+0x", sizeof ("+0x") - 1); |
| 2540 |
names += sizeof ("+0x") - 1; |
| 2541 |
bfd_sprintf_vma (abfd, names, p->addend); |
| 2542 |
names += strlen (names); |
| 2543 |
} |
| 2544 |
memcpy (names, "@plt", sizeof ("@plt")); |
| 2545 |
names += sizeof ("@plt"); |
| 2546 |
++s; |
| 2547 |
stub_vma += 16; |
| 2548 |
} |
| 2549 |
|
| 2550 |
/* Add a symbol at the start of the glink branch table. */ |
| 2551 |
memset (s, 0, sizeof *s); |
| 2552 |
s->the_bfd = abfd; |
| 2553 |
s->flags = BSF_GLOBAL | BSF_SYNTHETIC; |
| 2554 |
s->section = glink; |
| 2555 |
s->value = glink_vma - glink->vma; |
| 2556 |
s->name = names; |
| 2557 |
memcpy (names, "__glink", sizeof ("__glink")); |
| 2558 |
names += sizeof ("__glink"); |
| 2559 |
s++; |
| 2560 |
count++; |
| 2561 |
|
| 2562 |
if (resolv_vma) |
| 2563 |
{ |
| 2564 |
/* Add a symbol for the glink PLT resolver. */ |
| 2565 |
memset (s, 0, sizeof *s); |
| 2566 |
s->the_bfd = abfd; |
| 2567 |
s->flags = BSF_GLOBAL | BSF_SYNTHETIC; |
| 2568 |
s->section = glink; |
| 2569 |
s->value = resolv_vma - glink->vma; |
| 2570 |
s->name = names; |
| 2571 |
memcpy (names, "__glink_PLTresolve", sizeof ("__glink_PLTresolve")); |
| 2572 |
names += sizeof ("__glink_PLTresolve"); |
| 2573 |
s++; |
| 2574 |
count++; |
| 2575 |
} |
| 2576 |
|
| 2577 |
return count; |
| 2578 |
} |
| 2579 |
|
| 2580 |
/* The following functions are specific to the ELF linker, while |
| 2581 |
functions above are used generally. They appear in this file more |
| 2582 |
or less in the order in which they are called. eg. |
| 2583 |
ppc_elf_check_relocs is called early in the link process, |
| 2584 |
ppc_elf_finish_dynamic_sections is one of the last functions |
| 2585 |
called. */ |
| 2586 |
|
| 2587 |
/* The PPC linker needs to keep track of the number of relocs that it |
| 2588 |
decides to copy as dynamic relocs in check_relocs for each symbol. |
| 2589 |
This is so that it can later discard them if they are found to be |
| 2590 |
unnecessary. We store the information in a field extending the |
| 2591 |
regular ELF linker hash table. */ |
| 2592 |
|
| 2593 |
struct ppc_elf_dyn_relocs |
| 2594 |
{ |
| 2595 |
struct ppc_elf_dyn_relocs *next; |
| 2596 |
|
| 2597 |
/* The input section of the reloc. */ |
| 2598 |
asection *sec; |
| 2599 |
|
| 2600 |
/* Total number of relocs copied for the input section. */ |
| 2601 |
bfd_size_type count; |
| 2602 |
|
| 2603 |
/* Number of pc-relative relocs copied for the input section. */ |
| 2604 |
bfd_size_type pc_count; |
| 2605 |
}; |
| 2606 |
|
| 2607 |
/* Track PLT entries needed for a given symbol. We might need more |
| 2608 |
than one glink entry per symbol. */ |
| 2609 |
struct plt_entry |
| 2610 |
{ |
| 2611 |
struct plt_entry *next; |
| 2612 |
|
| 2613 |
/* -fPIC uses multiple GOT sections, one per file, called ".got2". |
| 2614 |
This field stores the offset into .got2 used to initialise the |
| 2615 |
GOT pointer reg. It will always be at least 32768 (and for |
| 2616 |
current gcc this is the only offset used). */ |
| 2617 |
bfd_vma addend; |
| 2618 |
|
| 2619 |
/* The .got2 section. */ |
| 2620 |
asection *sec; |
| 2621 |
|
| 2622 |
/* PLT refcount or offset. */ |
| 2623 |
union |
| 2624 |
{ |
| 2625 |
bfd_signed_vma refcount; |
| 2626 |
bfd_vma offset; |
| 2627 |
} plt; |
| 2628 |
|
| 2629 |
/* .glink stub offset. */ |
| 2630 |
bfd_vma glink_offset; |
| 2631 |
}; |
| 2632 |
|
| 2633 |
/* Of those relocs that might be copied as dynamic relocs, this function |
| 2634 |
selects those that must be copied when linking a shared library, |
| 2635 |
even when the symbol is local. */ |
| 2636 |
|
| 2637 |
static int |
| 2638 |
must_be_dyn_reloc (struct bfd_link_info *info, |
| 2639 |
enum elf_ppc_reloc_type r_type) |
| 2640 |
{ |
| 2641 |
switch (r_type) |
| 2642 |
{ |
| 2643 |
default: |
| 2644 |
return 1; |
| 2645 |
|
| 2646 |
case R_PPC_REL24: |
| 2647 |
case R_PPC_REL14: |
| 2648 |
case R_PPC_REL14_BRTAKEN: |
| 2649 |
case R_PPC_REL14_BRNTAKEN: |
| 2650 |
case R_PPC_REL32: |
| 2651 |
return 0; |
| 2652 |
|
| 2653 |
case R_PPC_TPREL32: |
| 2654 |
case R_PPC_TPREL16: |
| 2655 |
case R_PPC_TPREL16_LO: |
| 2656 |
case R_PPC_TPREL16_HI: |
| 2657 |
case R_PPC_TPREL16_HA: |
| 2658 |
return !info->executable; |
| 2659 |
} |
| 2660 |
} |
| 2661 |
|
| 2662 |
/* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid |
| 2663 |
copying dynamic variables from a shared lib into an app's dynbss |
| 2664 |
section, and instead use a dynamic relocation to point into the |
| 2665 |
shared lib. */ |
| 2666 |
#define ELIMINATE_COPY_RELOCS 1 |
| 2667 |
|
| 2668 |
/* PPC ELF linker hash entry. */ |
| 2669 |
|
| 2670 |
struct ppc_elf_link_hash_entry |
| 2671 |
{ |
| 2672 |
struct elf_link_hash_entry elf; |
| 2673 |
|
| 2674 |
/* If this symbol is used in the linker created sections, the processor |
| 2675 |
specific backend uses this field to map the field into the offset |
| 2676 |
from the beginning of the section. */ |
| 2677 |
elf_linker_section_pointers_t *linker_section_pointer; |
| 2678 |
|
| 2679 |
/* Track dynamic relocs copied for this symbol. */ |
| 2680 |
struct ppc_elf_dyn_relocs *dyn_relocs; |
| 2681 |
|
| 2682 |
/* Contexts in which symbol is used in the GOT (or TOC). |
| 2683 |
TLS_GD .. TLS_TLS bits are or'd into the mask as the |
| 2684 |
corresponding relocs are encountered during check_relocs. |
| 2685 |
tls_optimize clears TLS_GD .. TLS_TPREL when optimizing to |
| 2686 |
indicate the corresponding GOT entry type is not needed. */ |
| 2687 |
#define TLS_GD 1 /* GD reloc. */ |
| 2688 |
#define TLS_LD 2 /* LD reloc. */ |
| 2689 |
#define TLS_TPREL 4 /* TPREL reloc, => IE. */ |
| 2690 |
#define TLS_DTPREL 8 /* DTPREL reloc, => LD. */ |
| 2691 |
#define TLS_TLS 16 /* Any TLS reloc. */ |
| 2692 |
#define TLS_TPRELGD 32 /* TPREL reloc resulting from GD->IE. */ |
| 2693 |
#define PLT_IFUNC 64 /* STT_GNU_IFUNC. */ |
| 2694 |
char tls_mask; |
| 2695 |
|
| 2696 |
/* Nonzero if we have seen a small data relocation referring to this |
| 2697 |
symbol. */ |
| 2698 |
unsigned char has_sda_refs; |
| 2699 |
}; |
| 2700 |
|
| 2701 |
#define ppc_elf_hash_entry(ent) ((struct ppc_elf_link_hash_entry *) (ent)) |
| 2702 |
|
| 2703 |
/* PPC ELF linker hash table. */ |
| 2704 |
|
| 2705 |
struct ppc_elf_link_hash_table |
| 2706 |
{ |
| 2707 |
struct elf_link_hash_table elf; |
| 2708 |
|
| 2709 |
/* Short-cuts to get to dynamic linker sections. */ |
| 2710 |
asection *got; |
| 2711 |
asection *relgot; |
| 2712 |
asection *glink; |
| 2713 |
asection *plt; |
| 2714 |
asection *relplt; |
| 2715 |
asection *iplt; |
| 2716 |
asection *reliplt; |
| 2717 |
asection *dynbss; |
| 2718 |
asection *relbss; |
| 2719 |
asection *dynsbss; |
| 2720 |
asection *relsbss; |
| 2721 |
elf_linker_section_t sdata[2]; |
| 2722 |
asection *sbss; |
| 2723 |
|
| 2724 |
/* The (unloaded but important) .rela.plt.unloaded on VxWorks. */ |
| 2725 |
asection *srelplt2; |
| 2726 |
|
| 2727 |
/* The .got.plt section (VxWorks only)*/ |
| 2728 |
asection *sgotplt; |
| 2729 |
|
| 2730 |
/* Shortcut to __tls_get_addr. */ |
| 2731 |
struct elf_link_hash_entry *tls_get_addr; |
| 2732 |
|
| 2733 |
/* The bfd that forced an old-style PLT. */ |
| 2734 |
bfd *old_bfd; |
| 2735 |
|
| 2736 |
/* TLS local dynamic got entry handling. */ |
| 2737 |
union { |
| 2738 |
bfd_signed_vma refcount; |
| 2739 |
bfd_vma offset; |
| 2740 |
} tlsld_got; |
| 2741 |
|
| 2742 |
/* Offset of branch table to PltResolve function in glink. */ |
| 2743 |
bfd_vma glink_pltresolve; |
| 2744 |
|
| 2745 |
/* Size of reserved GOT entries. */ |
| 2746 |
unsigned int got_header_size; |
| 2747 |
/* Non-zero if allocating the header left a gap. */ |
| 2748 |
unsigned int got_gap; |
| 2749 |
|
| 2750 |
/* The type of PLT we have chosen to use. */ |
| 2751 |
enum ppc_elf_plt_type plt_type; |
| 2752 |
|
| 2753 |
/* Set if we should emit symbols for stubs. */ |
| 2754 |
unsigned int emit_stub_syms:1; |
| 2755 |
|
| 2756 |
/* True if the target system is VxWorks. */ |
| 2757 |
unsigned int is_vxworks:1; |
| 2758 |
|
| 2759 |
/* The size of PLT entries. */ |
| 2760 |
int plt_entry_size; |
| 2761 |
/* The distance between adjacent PLT slots. */ |
| 2762 |
int plt_slot_size; |
| 2763 |
/* The size of the first PLT entry. */ |
| 2764 |
int plt_initial_entry_size; |
| 2765 |
|
| 2766 |
/* Small local sym cache. */ |
| 2767 |
struct sym_cache sym_cache; |
| 2768 |
}; |
| 2769 |
|
| 2770 |
/* Get the PPC ELF linker hash table from a link_info structure. */ |
| 2771 |
|
| 2772 |
#define ppc_elf_hash_table(p) \ |
| 2773 |
((struct ppc_elf_link_hash_table *) (p)->hash) |
| 2774 |
|
| 2775 |
/* Create an entry in a PPC ELF linker hash table. */ |
| 2776 |
|
| 2777 |
static struct bfd_hash_entry * |
| 2778 |
ppc_elf_link_hash_newfunc (struct bfd_hash_entry *entry, |
| 2779 |
struct bfd_hash_table *table, |
| 2780 |
const char *string) |
| 2781 |
{ |
| 2782 |
/* Allocate the structure if it has not already been allocated by a |
| 2783 |
subclass. */ |
| 2784 |
if (entry == NULL) |
| 2785 |
{ |
| 2786 |
entry = bfd_hash_allocate (table, |
| 2787 |
sizeof (struct ppc_elf_link_hash_entry)); |
| 2788 |
if (entry == NULL) |
| 2789 |
return entry; |
| 2790 |
} |
| 2791 |
|
| 2792 |
/* Call the allocation method of the superclass. */ |
| 2793 |
entry = _bfd_elf_link_hash_newfunc (entry, table, string); |
| 2794 |
if (entry != NULL) |
| 2795 |
{ |
| 2796 |
ppc_elf_hash_entry (entry)->linker_section_pointer = NULL; |
| 2797 |
ppc_elf_hash_entry (entry)->dyn_relocs = NULL; |
| 2798 |
ppc_elf_hash_entry (entry)->tls_mask = 0; |
| 2799 |
} |
| 2800 |
|
| 2801 |
return entry; |
| 2802 |
} |
| 2803 |
|
| 2804 |
/* Create a PPC ELF linker hash table. */ |
| 2805 |
|
| 2806 |
static struct bfd_link_hash_table * |
| 2807 |
ppc_elf_link_hash_table_create (bfd *abfd) |
| 2808 |
{ |
| 2809 |
struct ppc_elf_link_hash_table *ret; |
| 2810 |
|
| 2811 |
ret = bfd_zmalloc (sizeof (struct ppc_elf_link_hash_table)); |
| 2812 |
if (ret == NULL) |
| 2813 |
return NULL; |
| 2814 |
|
| 2815 |
if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, |
| 2816 |
ppc_elf_link_hash_newfunc, |
| 2817 |
sizeof (struct ppc_elf_link_hash_entry))) |
| 2818 |
{ |
| 2819 |
free (ret); |
| 2820 |
return NULL; |
| 2821 |
} |
| 2822 |
|
| 2823 |
ret->elf.init_plt_refcount.refcount = 0; |
| 2824 |
ret->elf.init_plt_refcount.glist = NULL; |
| 2825 |
ret->elf.init_plt_offset.offset = 0; |
| 2826 |
ret->elf.init_plt_offset.glist = NULL; |
| 2827 |
|
| 2828 |
ret->sdata[0].name = ".sdata"; |
| 2829 |
ret->sdata[0].sym_name = "_SDA_BASE_"; |
| 2830 |
ret->sdata[0].bss_name = ".sbss"; |
| 2831 |
|
| 2832 |
ret->sdata[1].name = ".sdata2"; |
| 2833 |
ret->sdata[1].sym_name = "_SDA2_BASE_"; |
| 2834 |
ret->sdata[1].bss_name = ".sbss2"; |
| 2835 |
|
| 2836 |
ret->plt_entry_size = 12; |
| 2837 |
ret->plt_slot_size = 8; |
| 2838 |
ret->plt_initial_entry_size = 72; |
| 2839 |
|
| 2840 |
return &ret->elf.root; |
| 2841 |
} |
| 2842 |
|
| 2843 |
/* Create .got and the related sections. */ |
| 2844 |
|
| 2845 |
static bfd_boolean |
| 2846 |
ppc_elf_create_got (bfd *abfd, struct bfd_link_info *info) |
| 2847 |
{ |
| 2848 |
struct ppc_elf_link_hash_table *htab; |
| 2849 |
asection *s; |
| 2850 |
flagword flags; |
| 2851 |
|
| 2852 |
if (!_bfd_elf_create_got_section (abfd, info)) |
| 2853 |
return FALSE; |
| 2854 |
|
| 2855 |
htab = ppc_elf_hash_table (info); |
| 2856 |
htab->got = s = bfd_get_section_by_name (abfd, ".got"); |
| 2857 |
if (s == NULL) |
| 2858 |
abort (); |
| 2859 |
|
| 2860 |
if (htab->is_vxworks) |
| 2861 |
{ |
| 2862 |
htab->sgotplt = bfd_get_section_by_name (abfd, ".got.plt"); |
| 2863 |
if (!htab->sgotplt) |
| 2864 |
abort (); |
| 2865 |
} |
| 2866 |
else |
| 2867 |
{ |
| 2868 |
/* The powerpc .got has a blrl instruction in it. Mark it |
| 2869 |
executable. */ |
| 2870 |
flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS |
| 2871 |
| SEC_IN_MEMORY | SEC_LINKER_CREATED); |
| 2872 |
if (!bfd_set_section_flags (abfd, s, flags)) |
| 2873 |
return FALSE; |
| 2874 |
} |
| 2875 |
|
| 2876 |
htab->relgot = bfd_get_section_by_name (abfd, ".rela.got"); |
| 2877 |
if (!htab->relgot) |
| 2878 |
abort (); |
| 2879 |
|
| 2880 |
return TRUE; |
| 2881 |
} |
| 2882 |
|
| 2883 |
static bfd_boolean |
| 2884 |
ppc_elf_create_glink (bfd *abfd, struct bfd_link_info *info) |
| 2885 |
{ |
| 2886 |
struct ppc_elf_link_hash_table *htab = ppc_elf_hash_table (info); |
| 2887 |
asection *s; |
| 2888 |
flagword flags; |
| 2889 |
|
| 2890 |
flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY | SEC_HAS_CONTENTS |
| 2891 |
| SEC_IN_MEMORY | SEC_LINKER_CREATED); |
| 2892 |
s = bfd_make_section_anyway_with_flags (abfd, ".glink", flags); |
| 2893 |
htab->glink = s; |
| 2894 |
if (s == NULL |
| 2895 |
|| !bfd_set_section_alignment (abfd, s, 4)) |
| 2896 |
return FALSE; |
| 2897 |
|
| 2898 |
flags = SEC_ALLOC | SEC_LINKER_CREATED; |
| 2899 |
s = bfd_make_section_anyway_with_flags (abfd, ".iplt", flags); |
| 2900 |
htab->iplt = s; |
| 2901 |
if (s == NULL |
| 2902 |
|| !bfd_set_section_alignment (abfd, s, 4)) |
| 2903 |
return FALSE; |
| 2904 |
|
| 2905 |
flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_HAS_CONTENTS |
| 2906 |
| SEC_IN_MEMORY | SEC_LINKER_CREATED); |
| 2907 |
s = bfd_make_section_with_flags (abfd, ".rela.iplt", flags); |
| 2908 |
htab->reliplt = s; |
| 2909 |
if (s == NULL |
| 2910 |
|| ! bfd_set_section_alignment (abfd, s, 2)) |
| 2911 |
return FALSE; |
| 2912 |
return TRUE; |
| 2913 |
} |
| 2914 |
|
| 2915 |
/* We have to create .dynsbss and .rela.sbss here so that they get mapped |
| 2916 |
to output sections (just like _bfd_elf_create_dynamic_sections has |
| 2917 |
to create .dynbss and .rela.bss). */ |
| 2918 |
|
| 2919 |
static bfd_boolean |
| 2920 |
ppc_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) |
| 2921 |
{ |
| 2922 |
struct ppc_elf_link_hash_table *htab; |
| 2923 |
asection *s; |
| 2924 |
flagword flags; |
| 2925 |
|
| 2926 |
htab = ppc_elf_hash_table (info); |
| 2927 |
|
| 2928 |
if (htab->got == NULL |
| 2929 |
&& !ppc_elf_create_got (abfd, info)) |
| 2930 |
return FALSE; |
| 2931 |
|
| 2932 |
if (!_bfd_elf_create_dynamic_sections (abfd, info)) |
| 2933 |
return FALSE; |
| 2934 |
|
| 2935 |
if (htab->glink == NULL |
| 2936 |
&& !ppc_elf_create_glink (abfd, info)) |
| 2937 |
return FALSE; |
| 2938 |
|
| 2939 |
htab->dynbss = bfd_get_section_by_name (abfd, ".dynbss"); |
| 2940 |
s = bfd_make_section_with_flags (abfd, ".dynsbss", |
| 2941 |
SEC_ALLOC | SEC_LINKER_CREATED); |
| 2942 |
htab->dynsbss = s; |
| 2943 |
if (s == NULL) |
| 2944 |
return FALSE; |
| 2945 |
|
| 2946 |
if (! info->shared) |
| 2947 |
{ |
| 2948 |
htab->relbss = bfd_get_section_by_name (abfd, ".rela.bss"); |
| 2949 |
flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_HAS_CONTENTS |
| 2950 |
| SEC_IN_MEMORY | SEC_LINKER_CREATED); |
| 2951 |
s = bfd_make_section_with_flags (abfd, ".rela.sbss", flags); |
| 2952 |
htab->relsbss = s; |
| 2953 |
if (s == NULL |
| 2954 |
|| ! bfd_set_section_alignment (abfd, s, 2)) |
| 2955 |
return FALSE; |
| 2956 |
} |
| 2957 |
|
| 2958 |
if (htab->is_vxworks |
| 2959 |
&& !elf_vxworks_create_dynamic_sections (abfd, info, &htab->srelplt2)) |
| 2960 |
return FALSE; |
| 2961 |
|
| 2962 |
htab->relplt = bfd_get_section_by_name (abfd, ".rela.plt"); |
| 2963 |
htab->plt = s = bfd_get_section_by_name (abfd, ".plt"); |
| 2964 |
if (s == NULL) |
| 2965 |
abort (); |
| 2966 |
|
| 2967 |
flags = SEC_ALLOC | SEC_CODE | SEC_LINKER_CREATED; |
| 2968 |
if (htab->plt_type == PLT_VXWORKS) |
| 2969 |
/* The VxWorks PLT is a loaded section with contents. */ |
| 2970 |
flags |= SEC_HAS_CONTENTS | SEC_LOAD | SEC_READONLY; |
| 2971 |
return bfd_set_section_flags (abfd, s, flags); |
| 2972 |
} |
| 2973 |
|
| 2974 |
/* Copy the extra info we tack onto an elf_link_hash_entry. */ |
| 2975 |
|
| 2976 |
static void |
| 2977 |
ppc_elf_copy_indirect_symbol (struct bfd_link_info *info, |
| 2978 |
struct elf_link_hash_entry *dir, |
| 2979 |
struct elf_link_hash_entry *ind) |
| 2980 |
{ |
| 2981 |
struct ppc_elf_link_hash_entry *edir, *eind; |
| 2982 |
|
| 2983 |
edir = (struct ppc_elf_link_hash_entry *) dir; |
| 2984 |
eind = (struct ppc_elf_link_hash_entry *) ind; |
| 2985 |
|
| 2986 |
if (eind->dyn_relocs != NULL) |
| 2987 |
{ |
| 2988 |
if (edir->dyn_relocs != NULL) |
| 2989 |
{ |
| 2990 |
struct ppc_elf_dyn_relocs **pp; |
| 2991 |
struct ppc_elf_dyn_relocs *p; |
| 2992 |
|
| 2993 |
/* Add reloc counts against the indirect sym to the direct sym |
| 2994 |
list. Merge any entries against the same section. */ |
| 2995 |
for (pp = &eind->dyn_relocs; (p = *pp) != NULL; ) |
| 2996 |
{ |
| 2997 |
struct ppc_elf_dyn_relocs *q; |
| 2998 |
|
| 2999 |
for (q = edir->dyn_relocs; q != NULL; q = q->next) |
| 3000 |
if (q->sec == p->sec) |
| 3001 |
{ |
| 3002 |
q->pc_count += p->pc_count; |
| 3003 |
q->count += p->count; |
| 3004 |
*pp = p->next; |
| 3005 |
break; |
| 3006 |
} |
| 3007 |
if (q == NULL) |
| 3008 |
pp = &p->next; |
| 3009 |
} |
| 3010 |
*pp = edir->dyn_relocs; |
| 3011 |
} |
| 3012 |
|
| 3013 |
edir->dyn_relocs = eind->dyn_relocs; |
| 3014 |
eind->dyn_relocs = NULL; |
| 3015 |
} |
| 3016 |
|
| 3017 |
edir->tls_mask |= eind->tls_mask; |
| 3018 |
edir->has_sda_refs |= eind->has_sda_refs; |
| 3019 |
|
| 3020 |
/* If called to transfer flags for a weakdef during processing |
| 3021 |
of elf_adjust_dynamic_symbol, don't copy non_got_ref. |
| 3022 |
We clear it ourselves for ELIMINATE_COPY_RELOCS. */ |
| 3023 |
if (!(ELIMINATE_COPY_RELOCS |
| 3024 |
&& eind->elf.root.type != bfd_link_hash_indirect |
| 3025 |
&& edir->elf.dynamic_adjusted)) |
| 3026 |
edir->elf.non_got_ref |= eind->elf.non_got_ref; |
| 3027 |
|
| 3028 |
edir->elf.ref_dynamic |= eind->elf.ref_dynamic; |
| 3029 |
edir->elf.ref_regular |= eind->elf.ref_regular; |
| 3030 |
edir->elf.ref_regular_nonweak |= eind->elf.ref_regular_nonweak; |
| 3031 |
edir->elf.needs_plt |= eind->elf.needs_plt; |
| 3032 |
edir->elf.pointer_equality_needed |= eind->elf.pointer_equality_needed; |
| 3033 |
|
| 3034 |
/* If we were called to copy over info for a weak sym, that's all. */ |
| 3035 |
if (eind->elf.root.type != bfd_link_hash_indirect) |
| 3036 |
return; |
| 3037 |
|
| 3038 |
/* Copy over the GOT refcount entries that we may have already seen to |
| 3039 |
the symbol which just became indirect. */ |
| 3040 |
edir->elf.got.refcount += eind->elf.got.refcount; |
| 3041 |
eind->elf.got.refcount = 0; |
| 3042 |
|
| 3043 |
/* And plt entries. */ |
| 3044 |
if (eind->elf.plt.plist != NULL) |
| 3045 |
{ |
| 3046 |
if (edir->elf.plt.plist != NULL) |
| 3047 |
{ |
| 3048 |
struct plt_entry **entp; |
| 3049 |
struct plt_entry *ent; |
| 3050 |
|
| 3051 |
for (entp = &eind->elf.plt.plist; (ent = *entp) != NULL; ) |
| 3052 |
{ |
| 3053 |
struct plt_entry *dent; |
| 3054 |
|
| 3055 |
for (dent = edir->elf.plt.plist; dent != NULL; dent = dent->next) |
| 3056 |
if (dent->sec == ent->sec && dent->addend == ent->addend) |
| 3057 |
{ |
| 3058 |
dent->plt.refcount += ent->plt.refcount; |
| 3059 |
*entp = ent->next; |
| 3060 |
break; |
| 3061 |
} |
| 3062 |
if (dent == NULL) |
| 3063 |
entp = &ent->next; |
| 3064 |
} |
| 3065 |
*entp = edir->elf.plt.plist; |
| 3066 |
} |
| 3067 |
|
| 3068 |
edir->elf.plt.plist = eind->elf.plt.plist; |
| 3069 |
eind->elf.plt.plist = NULL; |
| 3070 |
} |
| 3071 |
|
| 3072 |
if (eind->elf.dynindx != -1) |
| 3073 |
{ |
| 3074 |
if (edir->elf.dynindx != -1) |
| 3075 |
_bfd_elf_strtab_delref (elf_hash_table (info)->dynstr, |
| 3076 |
edir->elf.dynstr_index); |
| 3077 |
edir->elf.dynindx = eind->elf.dynindx; |
| 3078 |
edir->elf.dynstr_index = eind->elf.dynstr_index; |
| 3079 |
eind->elf.dynindx = -1; |
| 3080 |
eind->elf.dynstr_index = 0; |
| 3081 |
} |
| 3082 |
} |
| 3083 |
|
| 3084 |
/* Hook called by the linker routine which adds symbols from an object |
| 3085 |
file. We use it to put .comm items in .sbss, and not .bss. */ |
| 3086 |
|
| 3087 |
static bfd_boolean |
| 3088 |
ppc_elf_add_symbol_hook (bfd *abfd, |
| 3089 |
struct bfd_link_info *info, |
| 3090 |
Elf_Internal_Sym *sym, |
| 3091 |
const char **namep ATTRIBUTE_UNUSED, |
| 3092 |
flagword *flagsp ATTRIBUTE_UNUSED, |
| 3093 |
asection **secp, |
| 3094 |
bfd_vma *valp) |
| 3095 |
{ |
| 3096 |
if (sym->st_shndx == SHN_COMMON |
| 3097 |
&& !info->relocatable |
| 3098 |
&& is_ppc_elf (info->output_bfd) |
| 3099 |
&& sym->st_size <= elf_gp_size (abfd)) |
| 3100 |
{ |
| 3101 |
/* Common symbols less than or equal to -G nn bytes are automatically |
| 3102 |
put into .sbss. */ |
| 3103 |
struct ppc_elf_link_hash_table *htab; |
| 3104 |
|
| 3105 |
htab = ppc_elf_hash_table (info); |
| 3106 |
if (htab->sbss == NULL) |
| 3107 |
{ |
| 3108 |
flagword flags = SEC_IS_COMMON | SEC_LINKER_CREATED; |
| 3109 |
|
| 3110 |
if (!htab->elf.dynobj) |
| 3111 |
htab->elf.dynobj = abfd; |
| 3112 |
|
| 3113 |
htab->sbss = bfd_make_section_anyway_with_flags (htab->elf.dynobj, |
| 3114 |
".sbss", |
| 3115 |
flags); |
| 3116 |
if (htab->sbss == NULL) |
| 3117 |
return FALSE; |
| 3118 |
} |
| 3119 |
|
| 3120 |
*secp = htab->sbss; |
| 3121 |
*valp = sym->st_size; |
| 3122 |
} |
| 3123 |
|
| 3124 |
if (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC) |
| 3125 |
elf_tdata (info->output_bfd)->has_ifunc_symbols = TRUE; |
| 3126 |
|
| 3127 |
return TRUE; |
| 3128 |
} |
| 3129 |
|
| 3130 |
static bfd_boolean |
| 3131 |
create_sdata_sym (struct ppc_elf_link_hash_table *htab, |
| 3132 |
elf_linker_section_t *lsect) |
| 3133 |
{ |
| 3134 |
lsect->sym = elf_link_hash_lookup (&htab->elf, lsect->sym_name, |
| 3135 |
TRUE, FALSE, TRUE); |
| 3136 |
if (lsect->sym == NULL) |
| 3137 |
return FALSE; |
| 3138 |
if (lsect->sym->root.type == bfd_link_hash_new) |
| 3139 |
lsect->sym->non_elf = 0; |
| 3140 |
lsect->sym->ref_regular = 1; |
| 3141 |
return TRUE; |
| 3142 |
} |
| 3143 |
|
| 3144 |
/* Create a special linker section. */ |
| 3145 |
|
| 3146 |
static bfd_boolean |
| 3147 |
ppc_elf_create_linker_section (bfd *abfd, |
| 3148 |
struct bfd_link_info *info, |
| 3149 |
flagword flags, |
| 3150 |
elf_linker_section_t *lsect) |
| 3151 |
{ |
| 3152 |
struct ppc_elf_link_hash_table *htab = ppc_elf_hash_table (info); |
| 3153 |
asection *s; |
| 3154 |
|
| 3155 |
flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY |
| 3156 |
| SEC_LINKER_CREATED); |
| 3157 |
|
| 3158 |
/* Record the first bfd that needs the special sections. */ |
| 3159 |
if (!htab->elf.dynobj) |
| 3160 |
htab->elf.dynobj = abfd; |
| 3161 |
|
| 3162 |
s = bfd_make_section_anyway_with_flags (htab->elf.dynobj, |
| 3163 |
lsect->name, |
| 3164 |
flags); |
| 3165 |
if (s == NULL |
| 3166 |
|| !bfd_set_section_alignment (htab->elf.dynobj, s, 2)) |
| 3167 |
return FALSE; |
| 3168 |
lsect->section = s; |
| 3169 |
|
| 3170 |
return create_sdata_sym (htab, lsect); |
| 3171 |
} |
| 3172 |
|
| 3173 |
/* Find a linker generated pointer with a given addend and type. */ |
| 3174 |
|
| 3175 |
static elf_linker_section_pointers_t * |
| 3176 |
elf_find_pointer_linker_section |
| 3177 |
(elf_linker_section_pointers_t *linker_pointers, |
| 3178 |
bfd_vma addend, |
| 3179 |
elf_linker_section_t *lsect) |
| 3180 |
{ |
| 3181 |
for ( ; linker_pointers != NULL; linker_pointers = linker_pointers->next) |
| 3182 |
if (lsect == linker_pointers->lsect && addend == linker_pointers->addend) |
| 3183 |
return linker_pointers; |
| 3184 |
|
| 3185 |
return NULL; |
| 3186 |
} |
| 3187 |
|
| 3188 |
/* Allocate a pointer to live in a linker created section. */ |
| 3189 |
|
| 3190 |
static bfd_boolean |
| 3191 |
elf_create_pointer_linker_section (bfd *abfd, |
| 3192 |
elf_linker_section_t *lsect, |
| 3193 |
struct elf_link_hash_entry *h, |
| 3194 |
const Elf_Internal_Rela *rel) |
| 3195 |
{ |
| 3196 |
elf_linker_section_pointers_t **ptr_linker_section_ptr = NULL; |
| 3197 |
elf_linker_section_pointers_t *linker_section_ptr; |
| 3198 |
unsigned long r_symndx = ELF32_R_SYM (rel->r_info); |
| 3199 |
bfd_size_type amt; |
| 3200 |
|
| 3201 |
BFD_ASSERT (lsect != NULL); |
| 3202 |
|
| 3203 |
/* Is this a global symbol? */ |
| 3204 |
if (h != NULL) |
| 3205 |
{ |
| 3206 |
struct ppc_elf_link_hash_entry *eh; |
| 3207 |
|
| 3208 |
/* Has this symbol already been allocated? If so, our work is done. */ |
| 3209 |
eh = (struct ppc_elf_link_hash_entry *) h; |
| 3210 |
if (elf_find_pointer_linker_section (eh->linker_section_pointer, |
| 3211 |
rel->r_addend, |
| 3212 |
lsect)) |
| 3213 |
return TRUE; |
| 3214 |
|
| 3215 |
ptr_linker_section_ptr = &eh->linker_section_pointer; |
| 3216 |
} |
| 3217 |
else |
| 3218 |
{ |
| 3219 |
BFD_ASSERT (is_ppc_elf (abfd)); |
| 3220 |
|
| 3221 |
/* Allocation of a pointer to a local symbol. */ |
| 3222 |
elf_linker_section_pointers_t **ptr = elf_local_ptr_offsets (abfd); |
| 3223 |
|
| 3224 |
/* Allocate a table to hold the local symbols if first time. */ |
| 3225 |
if (!ptr) |
| 3226 |
{ |
| 3227 |
unsigned int num_symbols = elf_symtab_hdr (abfd).sh_info; |
| 3228 |
|
| 3229 |
amt = num_symbols; |
| 3230 |
amt *= sizeof (elf_linker_section_pointers_t *); |
| 3231 |
ptr = bfd_zalloc (abfd, amt); |
| 3232 |
|
| 3233 |
if (!ptr) |
| 3234 |
return FALSE; |
| 3235 |
|
| 3236 |
elf_local_ptr_offsets (abfd) = ptr; |
| 3237 |
} |
| 3238 |
|
| 3239 |
/* Has this symbol already been allocated? If so, our work is done. */ |
| 3240 |
if (elf_find_pointer_linker_section (ptr[r_symndx], |
| 3241 |
rel->r_addend, |
| 3242 |
lsect)) |
| 3243 |
return TRUE; |
| 3244 |
|
| 3245 |
ptr_linker_section_ptr = &ptr[r_symndx]; |
| 3246 |
} |
| 3247 |
|
| 3248 |
/* Allocate space for a pointer in the linker section, and allocate |
| 3249 |
a new pointer record from internal memory. */ |
| 3250 |
BFD_ASSERT (ptr_linker_section_ptr != NULL); |
| 3251 |
amt = sizeof (elf_linker_section_pointers_t); |
| 3252 |
linker_section_ptr = bfd_alloc (abfd, amt); |
| 3253 |
|
| 3254 |
if (!linker_section_ptr) |
| 3255 |
return FALSE; |
| 3256 |
|
| 3257 |
linker_section_ptr->next = *ptr_linker_section_ptr; |
| 3258 |
linker_section_ptr->addend = rel->r_addend; |
| 3259 |
linker_section_ptr->lsect = lsect; |
| 3260 |
*ptr_linker_section_ptr = linker_section_ptr; |
| 3261 |
|
| 3262 |
linker_section_ptr->offset = lsect->section->size; |
| 3263 |
lsect->section->size += 4; |
| 3264 |
|
| 3265 |
#ifdef DEBUG |
| 3266 |
fprintf (stderr, |
| 3267 |
"Create pointer in linker section %s, offset = %ld, section size = %ld\n", |
| 3268 |
lsect->name, (long) linker_section_ptr->offset, |
| 3269 |
(long) lsect->section->size); |
| 3270 |
#endif |
| 3271 |
|
| 3272 |
return TRUE; |
| 3273 |
} |
| 3274 |
|
| 3275 |
static struct plt_entry ** |
| 3276 |
update_local_sym_info (bfd *abfd, |
| 3277 |
Elf_Internal_Shdr *symtab_hdr, |
| 3278 |
unsigned long r_symndx, |
| 3279 |
int tls_type) |
| 3280 |
{ |
| 3281 |
bfd_signed_vma *local_got_refcounts = elf_local_got_refcounts (abfd); |
| 3282 |
struct plt_entry **local_plt; |
| 3283 |
char *local_got_tls_masks; |
| 3284 |
|
| 3285 |
if (local_got_refcounts == NULL) |
| 3286 |
{ |
| 3287 |
bfd_size_type size = symtab_hdr->sh_info; |
| 3288 |
|
| 3289 |
size *= (sizeof (*local_got_refcounts) |
| 3290 |
+ sizeof (*local_plt) |
| 3291 |
+ sizeof (*local_got_tls_masks)); |
| 3292 |
local_got_refcounts = bfd_zalloc (abfd, size); |
| 3293 |
if (local_got_refcounts == NULL) |
| 3294 |
return NULL; |
| 3295 |
elf_local_got_refcounts (abfd) = local_got_refcounts; |
| 3296 |
} |
| 3297 |
|
| 3298 |
local_plt = (struct plt_entry **) (local_got_refcounts + symtab_hdr->sh_info); |
| 3299 |
local_got_tls_masks = (char *) (local_plt + symtab_hdr->sh_info); |
| 3300 |
local_got_tls_masks[r_symndx] |= tls_type; |
| 3301 |
if (tls_type != PLT_IFUNC) |
| 3302 |
local_got_refcounts[r_symndx] += 1; |
| 3303 |
return local_plt + r_symndx; |
| 3304 |
} |
| 3305 |
|
| 3306 |
static bfd_boolean |
| 3307 |
update_plt_info (bfd *abfd, struct plt_entry **plist, |
| 3308 |
asection *sec, bfd_vma addend) |
| 3309 |
{ |
| 3310 |
struct plt_entry *ent; |
| 3311 |
|
| 3312 |
for (ent = *plist; ent != NULL; ent = ent->next) |
| 3313 |
if (ent->sec == sec && ent->addend == addend) |
| 3314 |
break; |
| 3315 |
if (ent == NULL) |
| 3316 |
{ |
| 3317 |
bfd_size_type amt = sizeof (*ent); |
| 3318 |
ent = bfd_alloc (abfd, amt); |
| 3319 |
if (ent == NULL) |
| 3320 |
return FALSE; |
| 3321 |
ent->next = *plist; |
| 3322 |
ent->sec = sec; |
| 3323 |
ent->addend = addend; |
| 3324 |
ent->plt.refcount = 0; |
| 3325 |
*plist = ent; |
| 3326 |
} |
| 3327 |
ent->plt.refcount += 1; |
| 3328 |
return TRUE; |
| 3329 |
} |
| 3330 |
|
| 3331 |
static struct plt_entry * |
| 3332 |
find_plt_ent (struct plt_entry **plist, asection *sec, bfd_vma addend) |
| 3333 |
{ |
| 3334 |
struct plt_entry *ent; |
| 3335 |
|
| 3336 |
if (addend < 32768) |
| 3337 |
sec = NULL; |
| 3338 |
for (ent = *plist; ent != NULL; ent = ent->next) |
| 3339 |
if (ent->sec == sec && ent->addend == addend) |
| 3340 |
break; |
| 3341 |
return ent; |
| 3342 |
} |
| 3343 |
|
| 3344 |
static bfd_boolean |
| 3345 |
is_branch_reloc (enum elf_ppc_reloc_type r_type) |
| 3346 |
{ |
| 3347 |
return (r_type == R_PPC_PLTREL24 |
| 3348 |
|| r_type == R_PPC_LOCAL24PC |
| 3349 |
|| r_type == R_PPC_REL24 |
| 3350 |
|| r_type == R_PPC_REL14 |
| 3351 |
|| r_type == R_PPC_REL14_BRTAKEN |
| 3352 |
|| r_type == R_PPC_REL14_BRNTAKEN |
| 3353 |
|| r_type == R_PPC_ADDR24 |
| 3354 |
|| r_type == R_PPC_ADDR14 |
| 3355 |
|| r_type == R_PPC_ADDR14_BRTAKEN |
| 3356 |
|| r_type == R_PPC_ADDR14_BRNTAKEN); |
| 3357 |
} |
| 3358 |
|
| 3359 |
static void |
| 3360 |
bad_shared_reloc (bfd *abfd, enum elf_ppc_reloc_type r_type) |
| 3361 |
{ |
| 3362 |
(*_bfd_error_handler) |
| 3363 |
(_("%B: relocation %s cannot be used when making a shared object"), |
| 3364 |
abfd, |
| 3365 |
ppc_elf_howto_table[r_type]->name); |
| 3366 |
bfd_set_error (bfd_error_bad_value); |
| 3367 |
} |
| 3368 |
|
| 3369 |
/* Look through the relocs for a section during the first phase, and |
| 3370 |
allocate space in the global offset table or procedure linkage |
| 3371 |
table. */ |
| 3372 |
|
| 3373 |
static bfd_boolean |
| 3374 |
ppc_elf_check_relocs (bfd *abfd, |
| 3375 |
struct bfd_link_info *info, |
| 3376 |
asection *sec, |
| 3377 |
const Elf_Internal_Rela *relocs) |
| 3378 |
{ |
| 3379 |
struct ppc_elf_link_hash_table *htab; |
| 3380 |
Elf_Internal_Shdr *symtab_hdr; |
| 3381 |
struct elf_link_hash_entry **sym_hashes; |
| 3382 |
const Elf_Internal_Rela *rel; |
| 3383 |
const Elf_Internal_Rela *rel_end; |
| 3384 |
asection *got2, *sreloc; |
| 3385 |
struct elf_link_hash_entry *tga; |
| 3386 |
|
| 3387 |
if (info->relocatable) |
| 3388 |
return TRUE; |
| 3389 |
|
| 3390 |
/* Don't do anything special with non-loaded, non-alloced sections. |
| 3391 |
In particular, any relocs in such sections should not affect GOT |
| 3392 |
and PLT reference counting (ie. we don't allow them to create GOT |
| 3393 |
or PLT entries), there's no possibility or desire to optimize TLS |
| 3394 |
relocs, and there's not much point in propagating relocs to shared |
| 3395 |
libs that the dynamic linker won't relocate. */ |
| 3396 |
if ((sec->flags & SEC_ALLOC) == 0) |
| 3397 |
return TRUE; |
| 3398 |
|
| 3399 |
#ifdef DEBUG |
| 3400 |
_bfd_error_handler ("ppc_elf_check_relocs called for section %A in %B", |
| 3401 |
sec, abfd); |
| 3402 |
#endif |
| 3403 |
|
| 3404 |
BFD_ASSERT (is_ppc_elf (abfd)); |
| 3405 |
|
| 3406 |
/* Initialize howto table if not already done. */ |
| 3407 |
if (!ppc_elf_howto_table[R_PPC_ADDR32]) |
| 3408 |
ppc_elf_howto_init (); |
| 3409 |
|
| 3410 |
htab = ppc_elf_hash_table (info); |
| 3411 |
tga = elf_link_hash_lookup (&htab->elf, "__tls_get_addr", |
| 3412 |
FALSE, FALSE, TRUE); |
| 3413 |
symtab_hdr = &elf_symtab_hdr (abfd); |
| 3414 |
sym_hashes = elf_sym_hashes (abfd); |
| 3415 |
got2 = bfd_get_section_by_name (abfd, ".got2"); |
| 3416 |
sreloc = NULL; |
| 3417 |
|
| 3418 |
rel_end = relocs + sec->reloc_count; |
| 3419 |
for (rel = relocs; rel < rel_end; rel++) |
| 3420 |
{ |
| 3421 |
unsigned long r_symndx; |
| 3422 |
enum elf_ppc_reloc_type r_type; |
| 3423 |
struct elf_link_hash_entry *h; |
| 3424 |
int tls_type; |
| 3425 |
struct plt_entry **ifunc; |
| 3426 |
|
| 3427 |
r_symndx = ELF32_R_SYM (rel->r_info); |
| 3428 |
if (r_symndx < symtab_hdr->sh_info) |
| 3429 |
h = NULL; |
| 3430 |
else |
| 3431 |
{ |
| 3432 |
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; |
| 3433 |
while (h->root.type == bfd_link_hash_indirect |
| 3434 |
|| h->root.type == bfd_link_hash_warning) |
| 3435 |
h = (struct elf_link_hash_entry *) h->root.u.i.link; |
| 3436 |
} |
| 3437 |
|
| 3438 |
/* If a relocation refers to _GLOBAL_OFFSET_TABLE_, create the .got. |
| 3439 |
This shows up in particular in an R_PPC_ADDR32 in the eabi |
| 3440 |
startup code. */ |
| 3441 |
if (h != NULL |
| 3442 |
&& htab->got == NULL |
| 3443 |
&& strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) |
| 3444 |
{ |
| 3445 |
if (htab->elf.dynobj == NULL) |
| 3446 |
htab->elf.dynobj = abfd; |
| 3447 |
if (!ppc_elf_create_got (htab->elf.dynobj, info)) |
| 3448 |
return FALSE; |
| 3449 |
BFD_ASSERT (h == htab->elf.hgot); |
| 3450 |
} |
| 3451 |
|
| 3452 |
tls_type = 0; |
| 3453 |
ifunc = NULL; |
| 3454 |
r_type = ELF32_R_TYPE (rel->r_info); |
| 3455 |
if (!htab->is_vxworks && is_branch_reloc (r_type)) |
| 3456 |
{ |
| 3457 |
if (h != NULL && h == tga) |
| 3458 |
{ |
| 3459 |
if (rel != relocs |
| 3460 |
&& (ELF32_R_TYPE (rel[-1].r_info) == R_PPC_TLSGD |
| 3461 |
|| ELF32_R_TYPE (rel[-1].r_info) == R_PPC_TLSLD)) |
| 3462 |
/* We have a new-style __tls_get_addr call with a marker |
| 3463 |
reloc. */ |
| 3464 |
; |
| 3465 |
else |
| 3466 |
/* Mark this section as having an old-style call. */ |
| 3467 |
sec->has_tls_get_addr_call = 1; |
| 3468 |
} |
| 3469 |
|
| 3470 |
/* STT_GNU_IFUNC symbols must have a PLT entry. */ |
| 3471 |
if (h != NULL) |
| 3472 |
{ |
| 3473 |
if (h->type == STT_GNU_IFUNC) |
| 3474 |
{ |
| 3475 |
h->needs_plt = 1; |
| 3476 |
ifunc = &h->plt.plist; |
| 3477 |
} |
| 3478 |
} |
| 3479 |
else |
| 3480 |
{ |
| 3481 |
Elf_Internal_Sym *isym = bfd_sym_from_r_symndx (&htab->sym_cache, |
| 3482 |
abfd, r_symndx); |
| 3483 |
if (isym == NULL) |
| 3484 |
return FALSE; |
| 3485 |
|
| 3486 |
if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC) |
| 3487 |
{ |
| 3488 |
ifunc = update_local_sym_info (abfd, symtab_hdr, r_symndx, |
| 3489 |
PLT_IFUNC); |
| 3490 |
if (ifunc == NULL) |
| 3491 |
return FALSE; |
| 3492 |
} |
| 3493 |
} |
| 3494 |
if (ifunc != NULL) |
| 3495 |
{ |
| 3496 |
bfd_vma addend = 0; |
| 3497 |
|
| 3498 |
if (r_type == R_PPC_PLTREL24) |
| 3499 |
{ |
| 3500 |
ppc_elf_tdata (abfd)->makes_plt_call = 1; |
| 3501 |
addend = rel->r_addend; |
| 3502 |
} |
| 3503 |
if (!update_plt_info (abfd, ifunc, |
| 3504 |
addend < 32768 ? NULL : got2, addend)) |
| 3505 |
return FALSE; |
| 3506 |
|
| 3507 |
if (htab->glink == NULL) |
| 3508 |
{ |
| 3509 |
if (htab->elf.dynobj == NULL) |
| 3510 |
htab->elf.dynobj = abfd; |
| 3511 |
if (!ppc_elf_create_glink (htab->elf.dynobj, info)) |
| 3512 |
return FALSE; |
| 3513 |
} |
| 3514 |
} |
| 3515 |
} |
| 3516 |
|
| 3517 |
switch (r_type) |
| 3518 |
{ |
| 3519 |
case R_PPC_TLSGD: |
| 3520 |
case R_PPC_TLSLD: |
| 3521 |
/* These special tls relocs tie a call to __tls_get_addr with |
| 3522 |
its parameter symbol. */ |
| 3523 |
break; |
| 3524 |
|
| 3525 |
case R_PPC_GOT_TLSLD16: |
| 3526 |
case R_PPC_GOT_TLSLD16_LO: |
| 3527 |
case R_PPC_GOT_TLSLD16_HI: |
| 3528 |
case R_PPC_GOT_TLSLD16_HA: |
| 3529 |
tls_type = TLS_TLS | TLS_LD; |
| 3530 |
goto dogottls; |
| 3531 |
|
| 3532 |
case R_PPC_GOT_TLSGD16: |
| 3533 |
case R_PPC_GOT_TLSGD16_LO: |
| 3534 |
case R_PPC_GOT_TLSGD16_HI: |
| 3535 |
case R_PPC_GOT_TLSGD16_HA: |
| 3536 |
tls_type = TLS_TLS | TLS_GD; |
| 3537 |
goto dogottls; |
| 3538 |
|
| 3539 |
case R_PPC_GOT_TPREL16: |
| 3540 |
case R_PPC_GOT_TPREL16_LO: |
| 3541 |
case R_PPC_GOT_TPREL16_HI: |
| 3542 |
case R_PPC_GOT_TPREL16_HA: |
| 3543 |
if (!info->executable) |
| 3544 |
info->flags |= DF_STATIC_TLS; |
| 3545 |
tls_type
| |