From 9a742a902f48369144cdbf5333392f128c74ab7b Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sat, 2 Sep 2017 05:05:30 -0700 Subject: [PATCH] i386: Check VxWorks with htab->is_vxworks * elf32-i386.c (elf_i386_allocate_dynrelocs): Check VxWorks with htab->is_vxworks. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_finish_dynamic_symbol): Likewise. (elf_i386_finish_dynamic_sections): Likewise. --- bfd/ChangeLog | 9 +++++++++ bfd/elf32-i386.c | 23 ++++++++--------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 2bcee4929ce..554c1e75201 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,12 @@ +2017-09-02 H.J. Lu + + * elf32-i386.c (elf_i386_allocate_dynrelocs): Check VxWorks + with htab->is_vxworks. + (elf_i386_size_dynamic_sections): Likewise. + (elf_i386_relocate_section): Likewise. + (elf_i386_finish_dynamic_symbol): Likewise. + (elf_i386_finish_dynamic_sections): Likewise. + 2017-09-02 H.J. Lu * elf32-i386.c (GOT_TLS_IE, GOT_TLS_IE_POS, GOT_TLS_IE_NEG, diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 252a09d424e..3d8a4ae8975 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1971,7 +1971,6 @@ elf_i386_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) struct elf_dyn_relocs *p; unsigned plt_entry_size; bfd_boolean resolved_to_zero; - const struct elf_i386_backend_data *bed; if (h->root.type == bfd_link_hash_indirect) return TRUE; @@ -1983,8 +1982,6 @@ elf_i386_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) if (htab == NULL) return FALSE; - bed = get_elf_i386_backend_data (info->output_bfd); - plt_entry_size = htab->plt.plt_entry_size; resolved_to_zero = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, @@ -2144,7 +2141,7 @@ elf_i386_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) } } - if (bed->os == is_vxworks && !bfd_link_pic (info)) + if (htab->is_vxworks && !bfd_link_pic (info)) { /* VxWorks has a second set of relocations for each PLT entry in executables. They go in a separate relocation section, @@ -2281,7 +2278,7 @@ elf_i386_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) } } - if (bed->os == is_vxworks) + if (htab->is_vxworks) { struct elf_dyn_relocs **pp; for (pp = &eh->dyn_relocs; (p = *pp) != NULL; ) @@ -2595,8 +2592,7 @@ elf_i386_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) linker script /DISCARD/, so we'll be discarding the relocs too. */ } - else if ((get_elf_i386_backend_data (output_bfd)->os - == is_vxworks) + else if (htab->is_vxworks && strcmp (p->sec->output_section->name, ".tls_vars") == 0) { @@ -2927,7 +2923,7 @@ elf_i386_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) return FALSE; } } - if (get_elf_i386_backend_data (output_bfd)->os == is_vxworks + if (htab->is_vxworks && !elf_vxworks_add_dynamic_entries (output_bfd, info)) return FALSE; } @@ -3027,8 +3023,7 @@ elf_i386_relocate_section (bfd *output_bfd, local_tlsdesc_gotents = elf_x86_local_tlsdesc_gotent (input_bfd); /* We have to handle relocations in vxworks .tls_vars sections specially, because the dynamic loader is 'weird'. */ - is_vxworks_tls = ((get_elf_i386_backend_data (output_bfd)->os - == is_vxworks) + is_vxworks_tls = (htab->is_vxworks && bfd_link_pic (info) && !strcmp (input_section->output_section->name, ".tls_vars")); @@ -4583,7 +4578,6 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd, { struct elf_x86_link_hash_table *htab; unsigned plt_entry_size; - const struct elf_i386_backend_data *abed; struct elf_x86_link_hash_entry *eh; bfd_boolean local_undefweak; bfd_boolean use_plt_second; @@ -4592,7 +4586,6 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd, if (htab == NULL) return FALSE; - abed = get_elf_i386_backend_data (output_bfd); plt_entry_size = htab->plt.plt_entry_size; /* Use the second PLT section only if there is .plt section. */ @@ -4701,7 +4694,7 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd, resolved_plt->contents + plt_offset + htab->plt.plt_got_offset); - if (abed->os == is_vxworks) + if (htab->is_vxworks) { int s, k, reloc_index; @@ -5119,7 +5112,7 @@ elf_i386_finish_dynamic_sections (bfd *output_bfd, switch (dyn.d_tag) { default: - if (abed->os == is_vxworks + if (htab->is_vxworks && elf_vxworks_finish_dynamic_entry (output_bfd, &dyn)) break; continue; @@ -5174,7 +5167,7 @@ elf_i386_finish_dynamic_sections (bfd *output_bfd, htab->elf.splt->contents + htab->lazy_plt->plt0_got2_offset); - if (abed->os == is_vxworks) + if (htab->is_vxworks) { Elf_Internal_Rela rel; int num_plts = (htab->elf.splt->size -- 2.30.2