X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Farc-got.h;h=a86061bcb38f32a33cddb4b0531863c00d7851fc;hb=09aca9495c4794e586680f359e612ece173148ec;hp=00deb01f4b10f5741dfad0ee700383765afc6122;hpb=f7e8b360fe6dd93aae7cb4af554dc66364da4fe0;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/arc-got.h b/bfd/arc-got.h index 00deb01f4b..a86061bcb3 100644 --- a/bfd/arc-got.h +++ b/bfd/arc-got.h @@ -1,5 +1,5 @@ /* ARC-specific support for 32-bit ELF - Copyright (C) 1994-2016 Free Software Foundation, Inc. + Copyright (C) 1994-2018 Free Software Foundation, Inc. Contributed by Cupertino Miranda (cmiranda@synopsys.com). This file is part of BFD, the Binary File Descriptor library. @@ -22,6 +22,8 @@ #ifndef ARC_GOT_H #define ARC_GOT_H +#define TCB_SIZE (8) + enum tls_type_e { GOT_UNKNOWN = 0, @@ -225,10 +227,10 @@ arc_fill_got_info_for_reloc (enum tls_type_e type, { case GOT_NORMAL: { - bfd_vma offset + bfd_vma offset = ADD_SYMBOL_REF_SEC_AND_RELOC (got, bfd_link_pic (info) || h != NULL, h); - new_got_entry_to_list (list, type, offset, TLS_GOT_NONE); + new_got_entry_to_list (list, type, offset, TLS_GOT_NONE); } break; @@ -260,14 +262,14 @@ arc_fill_got_info_for_reloc (enum tls_type_e type, static bfd_vma -relocate_fix_got_relocs_for_got_info (struct got_entry ** list_p, - enum tls_type_e type, - struct bfd_link_info * info, - bfd * output_bfd, - unsigned long r_symndx, - Elf_Internal_Sym * local_syms, - asection ** local_sections, - struct elf_link_hash_entry * h, +relocate_fix_got_relocs_for_got_info (struct got_entry ** list_p, + enum tls_type_e type, + struct bfd_link_info * info, + bfd * output_bfd, + unsigned long r_symndx, + Elf_Internal_Sym * local_syms, + asection ** local_sections, + struct elf_link_hash_entry * h, struct arc_relocation_data * reloc_data) { struct elf_link_hash_table *htab = elf_hash_table (info); @@ -318,7 +320,7 @@ relocate_fix_got_relocs_for_got_info (struct got_entry ** list_p, } - if (entry && entry->processed == FALSE) + if (entry && !entry->processed) { switch (entry->type) { @@ -334,13 +336,15 @@ relocate_fix_got_relocs_for_got_info (struct got_entry ** list_p, ? 4 : 0)); ARC_DEBUG ("arc_info: FIXED -> %s value = %#lx " - "@ %p, for symbol %s\n", + "@ %lx, for symbol %s\n", (entry->type == GOT_TLS_GD ? "GOT_TLS_GD" : "GOT_TLS_IE"), (long) (sym_value - sec_vma), - htab->sgot->contents + entry->offset - + (entry->existing_entries == TLS_GOT_MOD_AND_OFF - ? 4 : 0), + (long) (htab->sgot->output_section->vma + + htab->sgot->output_offset->vma + + entry->offset + + (entry->existing_entries == TLS_GOT_MOD_AND_OFF + ? 4 : 0)), symbol_name); } break; @@ -351,14 +355,23 @@ relocate_fix_got_relocs_for_got_info (struct got_entry ** list_p, bfd_vma ATTRIBUTE_UNUSED sec_vma = tls_sec->output_section->vma; + bfd_put_32 (output_bfd, + sym_value - sec_vma + + (elf_hash_table (info)->dynamic_sections_created ? 0 : TCB_SIZE), + htab->sgot->contents + entry->offset + + (entry->existing_entries == TLS_GOT_MOD_AND_OFF + ? 4 : 0)); + ARC_DEBUG ("arc_info: FIXED -> %s value = %#lx " "@ %p, for symbol %s\n", (entry->type == GOT_TLS_GD ? "GOT_TLS_GD" : "GOT_TLS_IE"), (long) (sym_value - sec_vma), - htab->sgot->contents + entry->offset - + (entry->existing_entries == TLS_GOT_MOD_AND_OFF - ? 4 : 0), + (long) (htab->sgot->output_section->vma + + htab->sgot->output_offset->vma + + entry->offset + + (entry->existing_entries == TLS_GOT_MOD_AND_OFF + ? 4 : 0)), symbol_name); } break; @@ -369,12 +382,21 @@ relocate_fix_got_relocs_for_got_info (struct got_entry ** list_p, = reloc_data->sym_section->output_section->vma + reloc_data->sym_section->output_offset; - if (h->root.type != bfd_link_hash_undefweak) + if (h != NULL + && h->root.type == bfd_link_hash_undefweak) + ARC_DEBUG ("arc_info: PATCHED: NOT_PATCHED " + "@ %#08lx for sym %s in got offset %#lx " + "(is undefweak)\n", + (long) (htab->sgot->output_section->vma + + htab->sgot->output_offset + + entry->offset), + symbol_name, + (long) entry->offset); + else { bfd_put_32 (output_bfd, reloc_data->sym_value + sec_vma, htab->sgot->contents + entry->offset); - ARC_DEBUG ("arc_info: PATCHED: %#08lx " "@ %#08lx for sym %s in got offset %#lx\n", (long) (reloc_data->sym_value + sec_vma), @@ -383,17 +405,6 @@ relocate_fix_got_relocs_for_got_info (struct got_entry ** list_p, symbol_name, (long) entry->offset); } - else - { - ARC_DEBUG ("arc_info: PATCHED: NOT_PATCHED " - "@ %#08lx for sym %s in got offset %#lx " - "(is undefweak)\n", - (long) (htab->sgot->output_section->vma - + htab->sgot->output_offset - + entry->offset), - symbol_name, - (long) entry->offset); - } } break; default: @@ -419,7 +430,7 @@ create_got_dynrelocs_for_single_entry (struct got_entry *list, bfd_vma got_offset = list->offset; if (list->type == GOT_NORMAL - && list->created_dyn_relocation == FALSE) + && !list->created_dyn_relocation) { if (bfd_link_pic (info) && h != NULL @@ -438,7 +449,7 @@ create_got_dynrelocs_for_single_entry (struct got_entry *list, list->created_dyn_relocation = TRUE; } else if (list->existing_entries != TLS_GOT_NONE - && list->created_dyn_relocation == FALSE) + && !list->created_dyn_relocation) { /* TODO TLS: This is not called for local symbols. In order to correctly implement TLS, this should also @@ -449,14 +460,14 @@ create_got_dynrelocs_for_single_entry (struct got_entry *list, enum tls_got_entries e = list->existing_entries; BFD_ASSERT (list->type != GOT_TLS_GD - || list->existing_entries == TLS_GOT_MOD_AND_OFF); + || list->existing_entries == TLS_GOT_MOD_AND_OFF); bfd_vma dynindx = (h == NULL || h->dynindx == -1) ? 0 : h->dynindx; if (e == TLS_GOT_MOD_AND_OFF || e == TLS_GOT_MOD) { ADD_RELA (output_bfd, got, got_offset, dynindx, - R_ARC_TLS_DTPMOD, 0); + R_ARC_TLS_DTPMOD, 0); ARC_DEBUG ("arc_info: TLS_DYNRELOC: type = %d, \ GOT_OFFSET = %#lx, GOT_VMA = %#lx, INDEX = %ld, ADDEND = 0x0\n", list->type, @@ -470,8 +481,10 @@ GOT_OFFSET = %#lx, GOT_VMA = %#lx, INDEX = %ld, ADDEND = 0x0\n", { bfd_vma addend = 0; if (list->type == GOT_TLS_IE) + { addend = bfd_get_32 (output_bfd, htab->sgot->contents + got_offset); + } ADD_RELA (output_bfd, got, got_offset + (e == TLS_GOT_MOD_AND_OFF ? 4 : 0), @@ -496,7 +509,7 @@ static void create_got_dynrelocs_for_got_info (struct got_entry **list_p, bfd *output_bfd, struct bfd_link_info * info, - struct elf_link_hash_entry *h) + struct elf_link_hash_entry *h) { if (list_p == NULL) return;