| 1 |
/* BFD back-end for HP PA-RISC ELF files. |
/* BFD back-end for HP PA-RISC ELF files. |
| 2 |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001, |
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001, |
| 3 |
2002, 2003, 2004, 2005, 2006, 2007, 2008 |
2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
| 4 |
Free Software Foundation, Inc. |
Free Software Foundation, Inc. |
| 5 |
|
|
| 6 |
Original code by |
Original code by |
| 301 |
/* Set if we need a .plt stub to support lazy dynamic linking. */ |
/* Set if we need a .plt stub to support lazy dynamic linking. */ |
| 302 |
unsigned int need_plt_stub:1; |
unsigned int need_plt_stub:1; |
| 303 |
|
|
| 304 |
/* Small local sym to section mapping cache. */ |
/* Small local sym cache. */ |
| 305 |
struct sym_sec_cache sym_sec; |
struct sym_cache sym_cache; |
| 306 |
|
|
| 307 |
/* Data for LDM relocations. */ |
/* Data for LDM relocations. */ |
| 308 |
union |
union |
| 460 |
htab->has_17bit_branch = 0; |
htab->has_17bit_branch = 0; |
| 461 |
htab->has_22bit_branch = 0; |
htab->has_22bit_branch = 0; |
| 462 |
htab->need_plt_stub = 0; |
htab->need_plt_stub = 0; |
| 463 |
htab->sym_sec.abfd = NULL; |
htab->sym_cache.abfd = NULL; |
| 464 |
htab->tls_ldm_got.refcount = 0; |
htab->tls_ldm_got.refcount = 0; |
| 465 |
|
|
| 466 |
return &htab->etab.root; |
return &htab->etab.root; |
| 1011 |
htab->srelplt = bfd_get_section_by_name (abfd, ".rela.plt"); |
htab->srelplt = bfd_get_section_by_name (abfd, ".rela.plt"); |
| 1012 |
|
|
| 1013 |
htab->sgot = bfd_get_section_by_name (abfd, ".got"); |
htab->sgot = bfd_get_section_by_name (abfd, ".got"); |
| 1014 |
htab->srelgot = bfd_make_section_with_flags (abfd, ".rela.got", |
htab->srelgot = bfd_get_section_by_name (abfd, ".rela.got"); |
|
(SEC_ALLOC |
|
|
| SEC_LOAD |
|
|
| SEC_HAS_CONTENTS |
|
|
| SEC_IN_MEMORY |
|
|
| SEC_LINKER_CREATED |
|
|
| SEC_READONLY)); |
|
|
if (htab->srelgot == NULL |
|
|
|| ! bfd_set_section_alignment (abfd, htab->srelgot, 2)) |
|
|
return FALSE; |
|
| 1015 |
|
|
| 1016 |
htab->sdynbss = bfd_get_section_by_name (abfd, ".dynbss"); |
htab->sdynbss = bfd_get_section_by_name (abfd, ".dynbss"); |
| 1017 |
htab->srelbss = bfd_get_section_by_name (abfd, ".rela.bss"); |
htab->srelbss = bfd_get_section_by_name (abfd, ".rela.bss"); |
| 1104 |
return r_type; |
return r_type; |
| 1105 |
} |
} |
| 1106 |
|
|
| 1107 |
|
/* Return a pointer to the local GOT, PLT and TLS reference counts |
| 1108 |
|
for ABFD. Returns NULL if the storage allocation fails. */ |
| 1109 |
|
|
| 1110 |
|
static bfd_signed_vma * |
| 1111 |
|
hppa32_elf_local_refcounts (bfd *abfd) |
| 1112 |
|
{ |
| 1113 |
|
Elf_Internal_Shdr *symtab_hdr = &elf_tdata (abfd)->symtab_hdr; |
| 1114 |
|
bfd_signed_vma *local_refcounts; |
| 1115 |
|
|
| 1116 |
|
local_refcounts = elf_local_got_refcounts (abfd); |
| 1117 |
|
if (local_refcounts == NULL) |
| 1118 |
|
{ |
| 1119 |
|
bfd_size_type size; |
| 1120 |
|
|
| 1121 |
|
/* Allocate space for local GOT and PLT reference |
| 1122 |
|
counts. Done this way to save polluting elf_obj_tdata |
| 1123 |
|
with another target specific pointer. */ |
| 1124 |
|
size = symtab_hdr->sh_info; |
| 1125 |
|
size *= 2 * sizeof (bfd_signed_vma); |
| 1126 |
|
/* Add in space to store the local GOT TLS types. */ |
| 1127 |
|
size += symtab_hdr->sh_info; |
| 1128 |
|
local_refcounts = bfd_zalloc (abfd, size); |
| 1129 |
|
if (local_refcounts == NULL) |
| 1130 |
|
return NULL; |
| 1131 |
|
elf_local_got_refcounts (abfd) = local_refcounts; |
| 1132 |
|
memset (hppa_elf_local_got_tls_type (abfd), GOT_UNKNOWN, |
| 1133 |
|
symtab_hdr->sh_info); |
| 1134 |
|
} |
| 1135 |
|
return local_refcounts; |
| 1136 |
|
} |
| 1137 |
|
|
| 1138 |
|
|
| 1139 |
/* Look through the relocs for a section during the first phase, and |
/* Look through the relocs for a section during the first phase, and |
| 1140 |
calculate needed space in the global offset table, procedure linkage |
calculate needed space in the global offset table, procedure linkage |
| 1141 |
table, and dynamic reloc sections. At this point we haven't |
table, and dynamic reloc sections. At this point we haven't |
| 1382 |
bfd_signed_vma *local_got_refcounts; |
bfd_signed_vma *local_got_refcounts; |
| 1383 |
|
|
| 1384 |
/* This is a global offset table entry for a local symbol. */ |
/* This is a global offset table entry for a local symbol. */ |
| 1385 |
local_got_refcounts = elf_local_got_refcounts (abfd); |
local_got_refcounts = hppa32_elf_local_refcounts (abfd); |
| 1386 |
if (local_got_refcounts == NULL) |
if (local_got_refcounts == NULL) |
| 1387 |
{ |
return FALSE; |
|
bfd_size_type size; |
|
|
|
|
|
/* Allocate space for local got offsets and local |
|
|
plt offsets. Done this way to save polluting |
|
|
elf_obj_tdata with another target specific |
|
|
pointer. */ |
|
|
size = symtab_hdr->sh_info; |
|
|
size *= 2 * sizeof (bfd_signed_vma); |
|
|
/* Add in space to store the local GOT TLS types. */ |
|
|
size += symtab_hdr->sh_info; |
|
|
local_got_refcounts = bfd_zalloc (abfd, size); |
|
|
if (local_got_refcounts == NULL) |
|
|
return FALSE; |
|
|
elf_local_got_refcounts (abfd) = local_got_refcounts; |
|
|
memset (hppa_elf_local_got_tls_type (abfd), |
|
|
GOT_UNKNOWN, symtab_hdr->sh_info); |
|
|
} |
|
| 1388 |
local_got_refcounts[r_symndx] += 1; |
local_got_refcounts[r_symndx] += 1; |
| 1389 |
|
|
| 1390 |
old_tls_type = hppa_elf_local_got_tls_type (abfd) [r_symndx]; |
old_tls_type = hppa_elf_local_got_tls_type (abfd) [r_symndx]; |
| 1431 |
bfd_signed_vma *local_got_refcounts; |
bfd_signed_vma *local_got_refcounts; |
| 1432 |
bfd_signed_vma *local_plt_refcounts; |
bfd_signed_vma *local_plt_refcounts; |
| 1433 |
|
|
| 1434 |
local_got_refcounts = elf_local_got_refcounts (abfd); |
local_got_refcounts = hppa32_elf_local_refcounts (abfd); |
| 1435 |
if (local_got_refcounts == NULL) |
if (local_got_refcounts == NULL) |
| 1436 |
{ |
return FALSE; |
|
bfd_size_type size; |
|
|
|
|
|
/* Allocate space for local got offsets and local |
|
|
plt offsets. */ |
|
|
size = symtab_hdr->sh_info; |
|
|
size *= 2 * sizeof (bfd_signed_vma); |
|
|
/* Add in space to store the local GOT TLS types. */ |
|
|
size += symtab_hdr->sh_info; |
|
|
local_got_refcounts = bfd_zalloc (abfd, size); |
|
|
if (local_got_refcounts == NULL) |
|
|
return FALSE; |
|
|
elf_local_got_refcounts (abfd) = local_got_refcounts; |
|
|
} |
|
| 1437 |
local_plt_refcounts = (local_got_refcounts |
local_plt_refcounts = (local_got_refcounts |
| 1438 |
+ symtab_hdr->sh_info); |
+ symtab_hdr->sh_info); |
| 1439 |
local_plt_refcounts[r_symndx] += 1; |
local_plt_refcounts[r_symndx] += 1; |
| 1522 |
/* Track dynamic relocs needed for local syms too. |
/* Track dynamic relocs needed for local syms too. |
| 1523 |
We really need local syms available to do this |
We really need local syms available to do this |
| 1524 |
easily. Oh well. */ |
easily. Oh well. */ |
|
|
|
| 1525 |
asection *sr; |
asection *sr; |
| 1526 |
void *vpp; |
void *vpp; |
| 1527 |
|
Elf_Internal_Sym *isym; |
| 1528 |
|
|
| 1529 |
sr = bfd_section_from_r_symndx (abfd, &htab->sym_sec, |
isym = bfd_sym_from_r_symndx (&htab->sym_cache, |
| 1530 |
sec, r_symndx); |
abfd, r_symndx); |
| 1531 |
if (sr == NULL) |
if (isym == NULL) |
| 1532 |
return FALSE; |
return FALSE; |
| 1533 |
|
|
| 1534 |
|
sr = bfd_section_from_elf_index (abfd, isym->st_shndx); |
| 1535 |
|
if (sr == NULL) |
| 1536 |
|
sr = sec; |
| 1537 |
|
|
| 1538 |
vpp = &elf_section_data (sr)->local_dynrel; |
vpp = &elf_section_data (sr)->local_dynrel; |
| 1539 |
hdh_head = (struct elf32_hppa_dyn_reloc_entry **) vpp; |
hdh_head = (struct elf32_hppa_dyn_reloc_entry **) vpp; |
| 1540 |
} |
} |
| 3406 |
(_("%B(%A+0x%lx): %s fixup for insn 0x%x is not supported in a non-shared link"), |
(_("%B(%A+0x%lx): %s fixup for insn 0x%x is not supported in a non-shared link"), |
| 3407 |
input_bfd, |
input_bfd, |
| 3408 |
input_section, |
input_section, |
| 3409 |
offset, |
(long) offset, |
| 3410 |
howto->name, |
howto->name, |
| 3411 |
insn); |
insn); |
| 3412 |
} |
} |
| 3570 |
(_("%B(%A+0x%lx): cannot reach %s, recompile with -ffunction-sections"), |
(_("%B(%A+0x%lx): cannot reach %s, recompile with -ffunction-sections"), |
| 3571 |
input_bfd, |
input_bfd, |
| 3572 |
input_section, |
input_section, |
| 3573 |
offset, |
(long) offset, |
| 3574 |
hsh->bh_root.string); |
hsh->bh_root.string); |
| 3575 |
bfd_set_error (bfd_error_bad_value); |
bfd_set_error (bfd_error_bad_value); |
| 3576 |
return bfd_reloc_notsupported; |
return bfd_reloc_notsupported; |