1
1
/* IA-64 support for 64-bit ELF
2
Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
2
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004
3
Free Software Foundation, Inc.
3
4
Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
5
6
This file is part of BFD, the Binary File Descriptor library.
51
54
descriptor for a MIN_PLT entry, and requires one IPLT reloc.
53
56
MIN_PLT Created by PLTOFF entries against dynamic symbols. This
54
does not reqire dynamic relocations. */
57
does not require dynamic relocations. */
56
59
#define NELEMS(a) ((int) (sizeof (a) / sizeof ((a)[0])))
79
82
bfd_vma dtpmod_offset;
80
83
bfd_vma dtprel_offset;
82
/* The symbol table entry, if any, that this was derrived from. */
85
/* The symbol table entry, if any, that this was derived from. */
83
86
struct elf_link_hash_entry *h;
85
88
/* Used to count non-got, non-plt relocations for delayed sizing
123
130
unsigned sec_merge_done : 1;
126
struct elfNN_ia64_local_hash_table
128
struct bfd_hash_table root;
129
/* No additional fields for now. */
132
133
struct elfNN_ia64_link_hash_entry
134
135
struct elf_link_hash_entry root;
153
154
unsigned self_dtpmod_done : 1;/* has self DTPMOD entry been finished? */
154
155
bfd_vma self_dtpmod_offset; /* .got offset to self DTPMOD entry */
156
struct elfNN_ia64_local_hash_table loc_hash_table;
157
htab_t loc_hash_table;
158
void *loc_hash_memory;
159
161
struct elfNN_ia64_allocate_data
190
192
static void elfNN_ia64_final_write_processing
191
193
PARAMS ((bfd *abfd, bfd_boolean linker));
192
194
static bfd_boolean elfNN_ia64_add_symbol_hook
193
PARAMS ((bfd *abfd, struct bfd_link_info *info, const Elf_Internal_Sym *sym,
195
PARAMS ((bfd *abfd, struct bfd_link_info *info, Elf_Internal_Sym *sym,
194
196
const char **namep, flagword *flagsp, asection **secp,
196
198
static int elfNN_ia64_additional_program_headers
197
199
PARAMS ((bfd *abfd));
198
200
static bfd_boolean elfNN_ia64_modify_segment_map
201
PARAMS ((bfd *, struct bfd_link_info *));
200
202
static bfd_boolean elfNN_ia64_is_local_label_name
201
203
PARAMS ((bfd *abfd, const char *name));
202
204
static bfd_boolean elfNN_ia64_dynamic_symbol_p
203
205
PARAMS ((struct elf_link_hash_entry *h, struct bfd_link_info *info, int));
204
static bfd_boolean elfNN_ia64_local_hash_table_init
205
PARAMS ((struct elfNN_ia64_local_hash_table *ht, bfd *abfd,
206
new_hash_entry_func new));
207
static struct bfd_hash_entry *elfNN_ia64_new_loc_hash_entry
208
PARAMS ((struct bfd_hash_entry *entry, struct bfd_hash_table *table,
209
const char *string));
210
206
static struct bfd_hash_entry *elfNN_ia64_new_elf_hash_entry
211
207
PARAMS ((struct bfd_hash_entry *entry, struct bfd_hash_table *table,
212
208
const char *string));
215
211
struct elf_link_hash_entry *));
216
212
static void elfNN_ia64_hash_hide_symbol
217
213
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean));
214
static hashval_t elfNN_ia64_local_htab_hash PARAMS ((const void *));
215
static int elfNN_ia64_local_htab_eq PARAMS ((const void *ptr1,
218
217
static struct bfd_link_hash_table *elfNN_ia64_hash_table_create
219
218
PARAMS ((bfd *abfd));
220
static struct elfNN_ia64_local_hash_entry *elfNN_ia64_local_hash_lookup
221
PARAMS ((struct elfNN_ia64_local_hash_table *table, const char *string,
222
bfd_boolean create, bfd_boolean copy));
219
static void elfNN_ia64_hash_table_free
220
PARAMS ((struct bfd_link_hash_table *hash));
223
221
static bfd_boolean elfNN_ia64_global_dyn_sym_thunk
224
222
PARAMS ((struct bfd_hash_entry *, PTR));
225
static bfd_boolean elfNN_ia64_local_dyn_sym_thunk
226
PARAMS ((struct bfd_hash_entry *, PTR));
223
static int elfNN_ia64_local_dyn_sym_thunk
224
PARAMS ((void **, PTR));
227
225
static void elfNN_ia64_dyn_sym_traverse
228
226
PARAMS ((struct elfNN_ia64_link_hash_table *ia64_info,
229
227
bfd_boolean (*func) (struct elfNN_ia64_dyn_sym_info *, PTR),
249
247
static asection *get_reloc_section
250
248
PARAMS ((bfd *abfd, struct elfNN_ia64_link_hash_table *ia64_info,
251
249
asection *sec, bfd_boolean create));
252
static bfd_boolean count_dyn_reloc
253
PARAMS ((bfd *abfd, struct elfNN_ia64_dyn_sym_info *dyn_i,
254
asection *srel, int type));
255
250
static bfd_boolean elfNN_ia64_check_relocs
256
251
PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *sec,
257
252
const Elf_Internal_Rela *relocs));
641
636
static const bfd_byte plt_full_entry[PLT_FULL_ENTRY_SIZE] =
643
638
0x0b, 0x78, 0x00, 0x02, 0x00, 0x24, /* [MMI] addl r15=0,r1;; */
644
0x00, 0x41, 0x3c, 0x30, 0x28, 0xc0, /* ld8 r16=[r15],8 */
639
0x00, 0x41, 0x3c, 0x70, 0x29, 0xc0, /* ld8.acq r16=[r15],8*/
645
640
0x01, 0x08, 0x00, 0x84, /* mov r14=r1;; */
646
641
0x11, 0x08, 0x00, 0x1e, 0x18, 0x10, /* [MIB] ld8 r1=[r15] */
647
642
0x60, 0x80, 0x04, 0x80, 0x03, 0x00, /* mov b6=r16 */
678
673
oor_branch_size = itanium ? sizeof (oor_ip) : sizeof (oor_brl);
677
elfNN_ia64_relax_brl (bfd *abfd, bfd_byte *contents, bfd_vma off)
681
bfd_vma t0, t1, i0, i1, i2;
683
hit_addr = (bfd_byte *) (contents + off);
684
hit_addr -= (long) hit_addr & 0x3;
685
t0 = bfd_get_64 (abfd, hit_addr);
686
t1 = bfd_get_64 (abfd, hit_addr + 8);
688
/* Keep the instruction in slot 0. */
689
i0 = (t0 >> 5) & 0x1ffffffffffLL;
690
/* Use nop.b for slot 1. */
692
/* For slot 2, turn brl into br by masking out bit 40. */
693
i2 = (t1 >> 23) & 0x0ffffffffffLL;
695
/* Turn a MLX bundle into a MBB bundle with the same stop-bit
698
if ((t0 & 0x1fLL) == 5)
700
t0 = (i1 << 46) | (i0 << 5) | template;
701
t1 = (i2 << 23) | (i1 >> 18);
703
bfd_put_64 (abfd, t0, hit_addr);
704
bfd_put_64 (abfd, t1, hit_addr + 8);
682
707
/* These functions do relaxation for IA-64 ELF. */
715
740
/* Don't even try to relax for non-ELF outputs. */
716
if (link_info->hash->creator->flavour != bfd_target_elf_flavour)
741
if (!is_elf_hash_table (link_info->hash))
719
744
/* Nothing to do if there are no relocations or there is no need for
720
745
the relax finalize pass. */
721
746
if ((sec->flags & SEC_RELOC) == 0
722
747
|| sec->reloc_count == 0
723
|| (link_info->relax_finalizing
748
|| (!link_info->need_relax_finalize
724
749
&& sec->need_finalize_relax == 0))
771
796
case R_IA64_PCREL21BI:
772
797
case R_IA64_PCREL21M:
773
798
case R_IA64_PCREL21F:
774
if (link_info->relax_finalizing)
799
/* In the finalize pass, all br relaxations are done. We can
801
if (!link_info->need_relax_finalize)
776
803
is_branch = TRUE;
806
case R_IA64_PCREL60B:
807
/* We can't optimize brl to br before the finalize pass since
808
br relaxations will increase the code size. Defer it to
809
the finalize pass. */
810
if (link_info->need_relax_finalize)
812
sec->need_finalize_relax = 1;
779
818
case R_IA64_LTOFF22X:
780
819
case R_IA64_LDXMOV:
781
if (!link_info->relax_finalizing)
820
/* We can't relax ldx/mov before the finalize pass since
821
br relaxations will increase the code size. Defer it to
822
the finalize pass. */
823
if (link_info->need_relax_finalize)
783
825
sec->need_finalize_relax = 1;
811
853
isym = isymbuf + ELFNN_R_SYM (irel->r_info);
812
854
if (isym->st_shndx == SHN_UNDEF)
813
continue; /* We can't do anthing with undefined symbols. */
855
continue; /* We can't do anything with undefined symbols. */
814
856
else if (isym->st_shndx == SHN_ABS)
815
857
tsec = bfd_abs_section_ptr;
816
858
else if (isym->st_shndx == SHN_COMMON)
889
933
/* If the branch is in range, no need to do anything. */
890
934
if ((bfd_signed_vma) (symaddr - reladdr) >= -0x1000000
891
935
&& (bfd_signed_vma) (symaddr - reladdr) <= 0x0FFFFF0)
937
/* If the 60-bit branch is in 21-bit range, optimize it. */
938
if (r_type == R_IA64_PCREL60B)
940
elfNN_ia64_relax_brl (abfd, contents, roff);
943
= ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
946
/* If the original relocation offset points to slot
947
1, change it to slot 2. */
948
if ((irel->r_offset & 3) == 1)
954
else if (r_type == R_IA64_PCREL60B)
894
957
/* If the branch and target are in the same section, you've
918
981
/* Resize the current section to make room for the new branch. */
919
982
trampoff = (sec->_cooked_size + 15) & (bfd_vma) -16;
984
/* If trampoline is out of range, there is nothing we
986
offset = trampoff - (roff & (bfd_vma) -4);
987
if (offset < -0x1000000 || offset > 0x0FFFFF0)
920
990
amt = trampoff + size;
921
991
contents = (bfd_byte *) bfd_realloc (contents, amt);
922
992
if (contents == NULL)
1036
/* If trampoline is out of range, there is nothing we
1038
offset = f->trampoff - (roff & (bfd_vma) -4);
1039
if (offset < -0x1000000 || offset > 0x0FFFFF0)
966
1042
/* Nop out the reloc, since we're finalizing things here. */
967
1043
irel->r_info = ELFNN_R_INFO (0, R_IA64_NONE);
970
/* Fix up the existing branch to hit the trampoline. Hope like
971
hell this doesn't overflow too. */
972
if (elfNN_ia64_install_value (abfd, contents + roff,
973
f->trampoff - (roff & (bfd_vma) -4),
1046
/* Fix up the existing branch to hit the trampoline. */
1047
if (elfNN_ia64_install_value (abfd, contents + roff, offset,
974
1048
r_type) != bfd_reloc_ok)
975
1049
goto error_return;
1079
1153
/* ??? Resize .rela.got too. */
1082
if (link_info->relax_finalizing)
1156
if (!link_info->need_relax_finalize)
1083
1157
sec->need_finalize_relax = 0;
1085
1159
*again = changed_contents || changed_relocs;
1356
1430
elfNN_ia64_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
1358
1432
struct bfd_link_info *info;
1359
const Elf_Internal_Sym *sym;
1433
Elf_Internal_Sym *sym;
1360
1434
const char **namep ATTRIBUTE_UNUSED;
1361
1435
flagword *flagsp ATTRIBUTE_UNUSED;
1362
1436
asection **secp;
1413
1487
static bfd_boolean
1414
elfNN_ia64_modify_segment_map (abfd)
1488
elfNN_ia64_modify_segment_map (abfd, info)
1490
struct bfd_link_info *info ATTRIBUTE_UNUSED;
1417
1492
struct elf_segment_map *m, **pm;
1418
1493
Elf_Internal_Shdr *hdr;
1552
1627
return _bfd_elf_dynamic_symbol_p (h, info, ignore_protected);
1556
elfNN_ia64_local_hash_table_init (ht, abfd, new)
1557
struct elfNN_ia64_local_hash_table *ht;
1558
bfd *abfd ATTRIBUTE_UNUSED;
1559
new_hash_entry_func new;
1561
memset (ht, 0, sizeof (*ht));
1562
return bfd_hash_table_init (&ht->root, new);
1565
static struct bfd_hash_entry*
1566
elfNN_ia64_new_loc_hash_entry (entry, table, string)
1567
struct bfd_hash_entry *entry;
1568
struct bfd_hash_table *table;
1571
struct elfNN_ia64_local_hash_entry *ret;
1572
ret = (struct elfNN_ia64_local_hash_entry *) entry;
1574
/* Allocate the structure if it has not already been allocated by a
1577
ret = bfd_hash_allocate (table, sizeof (*ret));
1582
/* Initialize our local data. All zeros, and definitely easier
1583
than setting a handful of bit fields. */
1584
memset (ret, 0, sizeof (*ret));
1586
/* Call the allocation method of the superclass. */
1587
ret = ((struct elfNN_ia64_local_hash_entry *)
1588
bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
1590
return (struct bfd_hash_entry *) ret;
1593
1630
static struct bfd_hash_entry*
1594
1631
elfNN_ia64_new_elf_hash_entry (entry, table, string)
1595
1632
struct bfd_hash_entry *entry;
1636
1673
(ind->root.elf_link_hash_flags
1637
1674
& (ELF_LINK_HASH_REF_DYNAMIC
1638
1675
| ELF_LINK_HASH_REF_REGULAR
1639
| ELF_LINK_HASH_REF_REGULAR_NONWEAK));
1676
| ELF_LINK_HASH_REF_REGULAR_NONWEAK
1677
| ELF_LINK_HASH_NEEDS_PLT));
1641
1679
if (ind->root.root.type != bfd_link_hash_indirect)
1730
/* Compute a hash of a local hash entry. */
1733
elfNN_ia64_local_htab_hash (ptr)
1736
struct elfNN_ia64_local_hash_entry *entry
1737
= (struct elfNN_ia64_local_hash_entry *) ptr;
1739
return (((entry->id & 0xff) << 24) | ((entry->id & 0xff00) << 8))
1740
^ entry->r_sym ^ (entry->id >> 16);
1743
/* Compare local hash entries. */
1746
elfNN_ia64_local_htab_eq (ptr1, ptr2)
1747
const void *ptr1, *ptr2;
1749
struct elfNN_ia64_local_hash_entry *entry1
1750
= (struct elfNN_ia64_local_hash_entry *) ptr1;
1751
struct elfNN_ia64_local_hash_entry *entry2
1752
= (struct elfNN_ia64_local_hash_entry *) ptr2;
1754
return entry1->id == entry2->id && entry1->r_sym == entry2->r_sym;
1692
1757
/* Create the derived linker hash table. The IA-64 ELF port uses this
1693
1758
derived hash table to keep information specific to the IA-64 ElF
1694
1759
linker (without using static variables). */
1713
if (!elfNN_ia64_local_hash_table_init (&ret->loc_hash_table, abfd,
1714
elfNN_ia64_new_loc_hash_entry))
1778
ret->loc_hash_table = htab_try_create (1024, elfNN_ia64_local_htab_hash,
1779
elfNN_ia64_local_htab_eq, NULL);
1780
ret->loc_hash_memory = objalloc_create ();
1781
if (!ret->loc_hash_table || !ret->loc_hash_memory)
1720
1787
return &ret->root.root;
1723
/* Look up an entry in a Alpha ELF linker hash table. */
1790
/* Destroy IA-64 linker hash table. */
1725
static INLINE struct elfNN_ia64_local_hash_entry *
1726
elfNN_ia64_local_hash_lookup(table, string, create, copy)
1727
struct elfNN_ia64_local_hash_table *table;
1729
bfd_boolean create, copy;
1793
elfNN_ia64_hash_table_free (hash)
1794
struct bfd_link_hash_table *hash;
1731
return ((struct elfNN_ia64_local_hash_entry *)
1732
bfd_hash_lookup (&table->root, string, create, copy));
1796
struct elfNN_ia64_link_hash_table *ia64_info
1797
= (struct elfNN_ia64_link_hash_table *) hash;
1798
if (ia64_info->loc_hash_table)
1799
htab_delete (ia64_info->loc_hash_table);
1800
if (ia64_info->loc_hash_memory)
1801
objalloc_free ((struct objalloc *) ia64_info->loc_hash_memory);
1802
_bfd_generic_link_hash_table_free (hash);
1735
1805
/* Traverse both local and global hash tables. */
1763
1833
static bfd_boolean
1764
elfNN_ia64_local_dyn_sym_thunk (xentry, xdata)
1765
struct bfd_hash_entry *xentry;
1834
elfNN_ia64_local_dyn_sym_thunk (slot, xdata)
1768
1838
struct elfNN_ia64_local_hash_entry *entry
1769
= (struct elfNN_ia64_local_hash_entry *) xentry;
1839
= (struct elfNN_ia64_local_hash_entry *) *slot;
1770
1840
struct elfNN_ia64_dyn_sym_traverse_data *data
1771
1841
= (struct elfNN_ia64_dyn_sym_traverse_data *) xdata;
1772
1842
struct elfNN_ia64_dyn_sym_info *dyn_i;
1774
1844
for (dyn_i = entry->info; dyn_i; dyn_i = dyn_i->next)
1775
1845
if (! (*data->func) (dyn_i, data->data))
1791
1861
elf_link_hash_traverse (&ia64_info->root,
1792
1862
elfNN_ia64_global_dyn_sym_thunk, &xdata);
1793
bfd_hash_traverse (&ia64_info->loc_hash_table.root,
1794
elfNN_ia64_local_dyn_sym_thunk, &xdata);
1863
htab_traverse (ia64_info->loc_hash_table,
1864
elfNN_ia64_local_dyn_sym_thunk, &xdata);
1797
1867
static bfd_boolean
1853
1923
const Elf_Internal_Rela *rel;
1854
1924
bfd_boolean create;
1856
struct elfNN_ia64_local_hash_entry *ret;
1926
struct elfNN_ia64_local_hash_entry e, *ret;
1857
1927
asection *sec = abfd->sections;
1858
char addr_name [34];
1860
BFD_ASSERT ((sizeof (sec->id)*2 + 1 + sizeof (unsigned long)*2 + 1) <= 34);
1863
/* Construct a string for use in the elfNN_ia64_local_hash_table.
1864
name describes what was once anonymous memory. */
1866
sprintf (addr_name, "%x:%lx",
1867
sec->id, (unsigned long) ELFNN_R_SYM (rel->r_info));
1869
/* Collect the canonical entry data for this address. */
1870
ret = elfNN_ia64_local_hash_lookup (&ia64_info->loc_hash_table,
1871
addr_name, create, create);
1928
hashval_t h = (((sec->id & 0xff) << 24) | ((sec->id & 0xff00) << 8))
1929
^ ELFNN_R_SYM (rel->r_info) ^ (sec->id >> 16);
1933
e.r_sym = ELFNN_R_SYM (rel->r_info);
1934
slot = htab_find_slot_with_hash (ia64_info->loc_hash_table, &e, h,
1935
create ? INSERT : NO_INSERT);
1941
return (struct elfNN_ia64_local_hash_entry *) *slot;
1943
ret = (struct elfNN_ia64_local_hash_entry *)
1944
objalloc_alloc ((struct objalloc *) ia64_info->loc_hash_memory,
1945
sizeof (struct elfNN_ia64_local_hash_entry));
1948
memset (ret, 0, sizeof (*ret));
1950
ret->r_sym = ELFNN_R_SYM (rel->r_info);
1955
2036
/* Create function descriptor section (.opd). This section is called .opd
1956
because it contains "official prodecure descriptors". The "official"
2037
because it contains "official procedure descriptors". The "official"
1957
2038
refers to the fact that these descriptors are used when taking the address
1958
2039
of a procedure, thus ensuring a unique address for each procedure. */
1995
2076
asection *fptr_rel;
1996
fptr_rel = bfd_make_section(abfd, ".rela.opd");
2077
fptr_rel = bfd_make_section(dynobj, ".rela.opd");
1997
2078
if (fptr_rel == NULL
1998
|| !bfd_set_section_flags (abfd, fptr_rel,
2079
|| !bfd_set_section_flags (dynobj, fptr_rel,
1999
2080
(SEC_ALLOC | SEC_LOAD
2000
2081
| SEC_HAS_CONTENTS
2001
2082
| SEC_IN_MEMORY
2098
if (sec->flags & SEC_READONLY)
2099
ia64_info->reltext = 1;
2104
2182
static bfd_boolean
2105
count_dyn_reloc (abfd, dyn_i, srel, type)
2107
struct elfNN_ia64_dyn_sym_info *dyn_i;
2183
count_dyn_reloc (bfd *abfd, struct elfNN_ia64_dyn_sym_info *dyn_i,
2184
asection *srel, int type, bfd_boolean reltext)
2111
2186
struct elfNN_ia64_dyn_reloc_entry *rent;
2414
if (!count_dyn_reloc (abfd, dyn_i, srel, dynrel_type))
2490
if (!count_dyn_reloc (abfd, dyn_i, srel, dynrel_type,
2491
(sec->flags & SEC_READONLY) != 0))
2554
2631
BFD_ASSERT ((h->root.type == bfd_link_hash_defined)
2555
2632
|| (h->root.type == bfd_link_hash_defweak));
2557
if (!_bfd_elfNN_link_record_local_dynamic_symbol
2634
if (!bfd_elf_link_record_local_dynamic_symbol
2558
2635
(x->info, h->root.u.def.section->owner,
2559
2636
global_sym_index (h)))
2862
2941
data.ofs = (data.ofs + 31) & (bfd_vma) -32;
2864
2943
elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_plt2_entries, &data);
2944
if (data.ofs != 0 || ia64_info->root.dynamic_sections_created)
2946
/* FIXME: we always reserve the memory for dynamic linker even if
2947
there are no PLT entries since dynamic linker may assume the
2948
reserved memory always exists. */
2867
2950
BFD_ASSERT (ia64_info->root.dynamic_sections_created);
2869
2952
ia64_info->plt_sec->_raw_size = data.ofs;
2929
3012
ia64_info->fptr_sec = NULL;
3014
else if (sec == ia64_info->rel_fptr_sec)
3017
ia64_info->rel_fptr_sec = NULL;
3019
/* We use the reloc_count field as a counter if we need to
3020
copy relocs into the output file. */
3021
sec->reloc_count = 0;
2931
3023
else if (sec == ia64_info->plt_sec)
2995
3087
/* The DT_DEBUG entry is filled in by the dynamic linker and used
2996
3088
by the debugger. */
2997
3089
#define add_dynamic_entry(TAG, VAL) \
2998
bfd_elfNN_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
3090
_bfd_elf_add_dynamic_entry (info, TAG, VAL)
3000
3092
if (!add_dynamic_entry (DT_DEBUG, 0))
3545
3637
elfNN_ia64_tprel_base (info)
3546
3638
struct bfd_link_info *info;
3548
struct elf_link_tls_segment *tls_segment
3549
= elf_hash_table (info)->tls_segment;
3640
asection *tls_sec = elf_hash_table (info)->tls_sec;
3551
BFD_ASSERT (tls_segment != NULL);
3552
return (tls_segment->start
3553
- align_power ((bfd_vma) 16, tls_segment->align));
3642
BFD_ASSERT (tls_sec != NULL);
3643
return tls_sec->vma - align_power ((bfd_vma) 16, tls_sec->alignment_power);
3556
3646
/* Return the base VMA address which should be subtracted from real addresses
3561
3651
elfNN_ia64_dtprel_base (info)
3562
3652
struct bfd_link_info *info;
3564
BFD_ASSERT (elf_hash_table (info)->tls_segment != NULL);
3565
return elf_hash_table (info)->tls_segment->start;
3654
BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL);
3655
return elf_hash_table (info)->tls_sec->vma;
3568
3658
/* Called through qsort to sort the .IA_64.unwind section during a
3849
3939
if (r_symndx < symtab_hdr->sh_info)
3851
3941
/* Reloc against local symbol. */
3852
3943
sym = local_syms + r_symndx;
3853
3944
sym_sec = local_sections[r_symndx];
3854
value = _bfd_elf_rela_local_sym (output_bfd, sym, sym_sec, rel);
3946
value = _bfd_elf_rela_local_sym (output_bfd, sym, &msec, rel);
3855
3947
if ((sym_sec->flags & SEC_MERGE)
3856
3948
&& ELF_ST_TYPE (sym->st_info) == STT_SECTION
3857
3949
&& sym_sec->sec_info_type == ELF_INFO_TYPE_MERGE)
3889
3980
bfd_boolean unresolved_reloc;
3890
3981
bfd_boolean warned;
3982
struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
3892
RELOC_FOR_GLOBAL_SYMBOL (h, elf_sym_hashes (input_bfd),
3894
symtab_hdr, value, sym_sec,
3895
unresolved_reloc, info,
3984
RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
3985
r_symndx, symtab_hdr, sym_hashes,
3987
unresolved_reloc, warned);
3898
3989
if (h->root.type == bfd_link_hash_undefweak)
3899
3990
undef_weak_ref = TRUE;
3930
4021
BFD_ASSERT (srel != NULL);
4028
/* ??? People shouldn't be doing non-pic code in
4029
shared libraries nor dynamic executables. */
4030
(*_bfd_error_handler)
4031
(_("%s: non-pic code with imm relocation against dynamic symbol `%s'"),
4032
bfd_archive_filename (input_bfd),
4033
h->root.root.string);
3932
4041
/* If we don't need dynamic symbol lookup, find a
3933
4042
matching RELATIVE relocation. */
3934
4043
dyn_r_type = r_type;
3959
/* We can't represent this without a dynamic symbol.
3960
Adjust the relocation to be against an output
3961
section symbol, which are always present in the
3962
dynamic symbol table. */
3963
/* ??? People shouldn't be doing non-pic code in
3964
shared libraries. Hork. */
3965
(*_bfd_error_handler)
3966
(_("%s: linking non-pic code in a shared library"),
3967
bfd_archive_filename (input_bfd));
3972
4071
addend = value;
4501
4600
/* Mark the symbol as undefined, rather than as defined in the
4502
4601
plt section. Leave the value alone. */
4503
4602
/* ??? We didn't redefine it in adjust_dynamic_symbol in the
4504
first place. But perhaps elflink.h did some for us. */
4603
first place. But perhaps elflink.c did some for us. */
4505
4604
if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
4506
4605
sym->st_shndx = SHN_UNDEF;
4871
4970
/* Stuff for the BFD linker: */
4872
4971
#define bfd_elfNN_bfd_link_hash_table_create \
4873
4972
elfNN_ia64_hash_table_create
4973
#define bfd_elfNN_bfd_link_hash_table_free \
4974
elfNN_ia64_hash_table_free
4874
4975
#define elf_backend_create_dynamic_sections \
4875
4976
elfNN_ia64_create_dynamic_sections
4876
4977
#define elf_backend_check_relocs \
4899
5000
#define elf_backend_want_plt_sym 0
4900
5001
#define elf_backend_plt_alignment 5
4901
5002
#define elf_backend_got_header_size 0
4902
#define elf_backend_plt_header_size PLT_HEADER_SIZE
4903
5003
#define elf_backend_want_got_plt 1
4904
5004
#define elf_backend_may_use_rel_p 1
4905
5005
#define elf_backend_may_use_rela_p 1