diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2013-09-28 23:03:40 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2013-09-28 23:03:40 +0000 |
commit | 64fa5e4ddf951327c3c950505a840cb4e2aa0559 (patch) | |
tree | 2a478a838353f08e6904939e428420812fb52ba1 /contrib/binutils/bfd | |
parent | 0210509acd4bcf53b116da01deb0f25b1d16da89 (diff) | |
download | src-64fa5e4ddf951327c3c950505a840cb4e2aa0559.tar.gz src-64fa5e4ddf951327c3c950505a840cb4e2aa0559.zip |
Fix a bug in ld, where indirect symbols are not handled properly during
linking of a shared library, leading to corrupt indexes in the dynamic
symbol table. This should fix the multimedia/ffmpegthumbnailer port.
Approved by: re (kib)
Reported by: swills
MFC after: 2 weeks
Notes
Notes:
svn path=/head/; revision=255931
Diffstat (limited to 'contrib/binutils/bfd')
-rw-r--r-- | contrib/binutils/bfd/elflink.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/contrib/binutils/bfd/elflink.c b/contrib/binutils/bfd/elflink.c index 44973febfa83..f5c989d7a778 100644 --- a/contrib/binutils/bfd/elflink.c +++ b/contrib/binutils/bfd/elflink.c @@ -488,12 +488,28 @@ bfd_elf_record_link_assignment (bfd *output_bfd, if (h->root.u.undef.next != NULL || htab->root.undefs_tail == &h->root) bfd_link_repair_undef_list (&htab->root); } - - if (h->root.type == bfd_link_hash_new) + else if (h->root.type == bfd_link_hash_new) { bfd_elf_link_mark_dynamic_symbol (info, h, NULL); h->non_elf = 0; } + else if (h->root.type == bfd_link_hash_indirect) + { + const struct elf_backend_data *bed = get_elf_backend_data (output_bfd); + struct elf_link_hash_entry *hv = h; + do + hv = (struct elf_link_hash_entry *) hv->root.u.i.link; + while (hv->root.type == bfd_link_hash_indirect + || hv->root.type == bfd_link_hash_warning); + h->root.type = bfd_link_hash_undefined; + hv->root.type = bfd_link_hash_indirect; + hv->root.u.i.link = (struct bfd_link_hash_entry *) h; + (*bed->elf_backend_copy_indirect_symbol) (info, h, hv); + } + else if (h->root.type == bfd_link_hash_warning) + { + abort (); + } /* If this symbol is being provided by the linker script, and it is currently defined by a dynamic object, but not by a regular @@ -1417,10 +1433,10 @@ _bfd_elf_merge_symbol (bfd *abfd, case, we make the versioned symbol point to the normal one. */ const struct elf_backend_data *bed = get_elf_backend_data (abfd); flip->root.type = h->root.type; + flip->root.u.undef.abfd = h->root.u.undef.abfd; h->root.type = bfd_link_hash_indirect; h->root.u.i.link = (struct bfd_link_hash_entry *) flip; (*bed->elf_backend_copy_indirect_symbol) (info, flip, h); - flip->root.u.undef.abfd = h->root.u.undef.abfd; if (h->def_dynamic) { h->def_dynamic = 0; |