X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf32-i370.c;h=4f6d727cec5a9d598b4f3c226988625512928ee7;hb=2fafa20b344ef572d2e1b5002ba9a39e10d1c44c;hp=0508aeb3ddd579068af6ea8051d37dc101e71510;hpb=6d00b590316c0b08de21a264893b0fd627c54686;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c index 0508aeb3dd..4f6d727cec 100644 --- a/bfd/elf32-i370.c +++ b/bfd/elf32-i370.c @@ -1,5 +1,5 @@ /* i370-specific support for 32-bit ELF - Copyright (C) 1994-2014 Free Software Foundation, Inc. + Copyright (C) 1994-2016 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. Hacked by Linas Vepstas for i370 linas@linas.org @@ -40,11 +40,11 @@ static reloc_howto_type i370_elf_howto_raw[] = /* This reloc does nothing. */ HOWTO (R_I370_NONE, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ + 3, /* size (0 = byte, 1 = short, 2 = long) */ + 0, /* bitsize */ FALSE, /* pc_relative */ 0, /* bitpos */ - complain_overflow_bitfield, /* complain_on_overflow */ + complain_overflow_dont, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_I370_NONE", /* name */ FALSE, /* partial_inplace */ @@ -294,12 +294,21 @@ i370_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr, Elf_Internal_Rela *dst) { + unsigned int r_type; + if (!i370_elf_howto_table[ R_I370_ADDR31 ]) /* Initialize howto table. */ i370_elf_howto_init (); - BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_I370_max); - cache_ptr->howto = i370_elf_howto_table[ELF32_R_TYPE (dst->r_info)]; + r_type = ELF32_R_TYPE (dst->r_info); + if (r_type >= R_I370_max) + { + (*_bfd_error_handler) (_("%B: unrecognised I370 reloc number: %d"), + abfd, r_type); + bfd_set_error (bfd_error_bad_value); + r_type = R_I370_NONE; + } + cache_ptr->howto = i370_elf_howto_table[r_type]; } /* Hack alert -- the following several routines look generic to me ... @@ -424,7 +433,7 @@ i370_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) if (s == NULL) return FALSE; - if (! info->shared) + if (! bfd_link_pic (info)) { s = bfd_make_section_anyway_with_flags (abfd, ".rela.sbss", flags | SEC_READONLY); @@ -494,7 +503,7 @@ i370_elf_adjust_dynamic_symbol (struct bfd_link_info *info, only references to the symbol are via the global offset table. For such cases we need not do anything here; the relocations will be handled correctly by relocate_section. */ - if (info->shared) + if (bfd_link_pic (info)) return TRUE; /* We must allocate the symbol in our .dynbss section, which will @@ -534,7 +543,7 @@ i370_elf_adjust_dynamic_symbol (struct bfd_link_info *info, h->needs_copy = 1; } - return _bfd_elf_adjust_dynamic_copy (h, s); + return _bfd_elf_adjust_dynamic_copy (info, h, s); } /* Increment the index of a dynamic symbol by a given amount. Called @@ -585,7 +594,7 @@ i370_elf_size_dynamic_sections (bfd *output_bfd, if (elf_hash_table (info)->dynamic_sections_created) { /* Set the contents of the .interp section to the interpreter. */ - if (info->executable) + if (bfd_link_executable (info) && !info->nointerp) { s = bfd_get_linker_section (dynobj, ".interp"); BFD_ASSERT (s != NULL); @@ -704,7 +713,7 @@ i370_elf_size_dynamic_sections (bfd *output_bfd, #define add_dynamic_entry(TAG, VAL) \ _bfd_elf_add_dynamic_entry (info, TAG, VAL) - if (!info->shared) + if (!bfd_link_pic (info)) { if (!add_dynamic_entry (DT_DEBUG, 0)) return FALSE; @@ -746,7 +755,7 @@ i370_elf_size_dynamic_sections (bfd *output_bfd, locations in linker-created sections that do not have externally-visible names. Instead, we should work out precisely which sections relocations are targeted at. */ - if (info->shared) + if (bfd_link_pic (info)) { int c; @@ -795,7 +804,7 @@ i370_elf_check_relocs (bfd *abfd, const Elf_Internal_Rela *rel_end; asection *sreloc; - if (info->relocatable) + if (bfd_link_relocatable (info)) return TRUE; #ifdef DEBUG @@ -830,7 +839,7 @@ i370_elf_check_relocs (bfd *abfd, h->root.non_ir_ref = 1; } - if (info->shared) + if (bfd_link_pic (info)) { #ifdef DEBUG fprintf (stderr, @@ -910,13 +919,13 @@ i370_elf_finish_dynamic_sections (bfd *output_bfd, { asection *s; - s = bfd_get_section_by_name (output_bfd, name); + s = bfd_get_linker_section (dynobj, name); if (s == NULL) dyn.d_un.d_val = 0; else { if (! size) - dyn.d_un.d_ptr = s->vma; + dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; else dyn.d_un.d_val = s->size; } @@ -939,7 +948,7 @@ i370_elf_finish_dynamic_sections (bfd *output_bfd, elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4; } - if (info->shared) + if (bfd_link_pic (info)) { asection *sdynsym; asection *s; @@ -1040,7 +1049,7 @@ i370_elf_relocate_section (bfd *output_bfd, _bfd_error_handler ("i370_elf_relocate_section called for %B section %A, %ld relocations%s", input_bfd, input_section, (long) input_section->reloc_count, - (info->relocatable) ? " (relocatable)" : ""); + (bfd_link_relocatable (info)) ? " (relocatable)" : ""); #endif if (!i370_elf_howto_table[ R_I370_ADDR31 ]) @@ -1090,6 +1099,12 @@ i370_elf_relocate_section (bfd *output_bfd, else { h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + + if (info->wrap_hash != NULL + && (input_section->flags & SEC_DEBUGGING) != 0) + h = ((struct elf_link_hash_entry *) + unwrap_hash_lookup (info, input_bfd, &h->root)); + while (h->root.type == bfd_link_hash_indirect || h->root.type == bfd_link_hash_warning) h = (struct elf_link_hash_entry *) h->root.u.i.link; @@ -1098,7 +1113,7 @@ i370_elf_relocate_section (bfd *output_bfd, || h->root.type == bfd_link_hash_defweak) { sec = h->root.u.def.section; - if (info->shared + if (bfd_link_pic (info) && ((! info->symbolic && h->dynindx != -1) || !h->def_regular) && (input_section->flags & SEC_ALLOC) != 0 @@ -1120,17 +1135,15 @@ i370_elf_relocate_section (bfd *output_bfd, else if (info->unresolved_syms_in_objects == RM_IGNORE && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) ; - else if (!info->relocatable) + else if (!bfd_link_relocatable (info)) { - if ((*info->callbacks->undefined_symbol) - (info, h->root.root.string, input_bfd, - input_section, rel->r_offset, - (info->unresolved_syms_in_objects == RM_GENERATE_ERROR - || ELF_ST_VISIBILITY (h->other)))) - { - ret = FALSE; - continue; - } + (*info->callbacks->undefined_symbol) + (info, h->root.root.string, input_bfd, + input_section, rel->r_offset, + (info->unresolved_syms_in_objects == RM_GENERATE_ERROR + || ELF_ST_VISIBILITY (h->other))); + ret = FALSE; + continue; } } @@ -1138,7 +1151,7 @@ i370_elf_relocate_section (bfd *output_bfd, RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, rel, 1, relend, howto, 0, contents); - if (info->relocatable) + if (bfd_link_relocatable (info)) continue; switch ((int) r_type) @@ -1169,7 +1182,7 @@ i370_elf_relocate_section (bfd *output_bfd, object. */ case (int) R_I370_ADDR31: case (int) R_I370_ADDR16: - if (info->shared + if (bfd_link_pic (info) && r_symndx != STN_UNDEF) { Elf_Internal_Rela outrel;