X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Felf32-m32r.c;h=7ecf95fb03ebd20eab8da55e41b11e5e2e3eb57f;hb=63a5468afa8e2cf8843d87b99e780e9266b31014;hp=51ef61e6b4980b1165628a3e747ada923a2692c2;hpb=7686d77de353217f4a1d50e07ccb5aecd2579e67;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index 51ef61e6b4..7ecf95fb03 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -1,6 +1,5 @@ /* M32R-specific support for 32-bit ELF. - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 1996-2017 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -475,11 +474,11 @@ static reloc_howto_type m32r_elf_howto_table[] = /* This reloc does nothing. */ HOWTO (R_M32R_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_M32R_NONE", /* name */ FALSE, /* partial_inplace */ @@ -1281,7 +1280,12 @@ m32r_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, unsigned int r_type; r_type = ELF32_R_TYPE (dst->r_info); - BFD_ASSERT (ELF32_R_TYPE(dst->r_info) <= (unsigned int) R_M32R_GNU_VTENTRY); + if (r_type > (unsigned int) R_M32R_GNU_VTENTRY) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%B: invalid M32R reloc number: %d"), abfd, r_type); + r_type = 0; + } cache_ptr->howto = &m32r_elf_howto_table[r_type]; } @@ -1366,7 +1370,7 @@ m32r_elf_add_symbol_hook (bfd *abfd, asection **secp, bfd_vma *valp) { - if (! info->relocatable + if (! bfd_link_relocatable (info) && (*namep)[0] == '_' && (*namep)[1] == 'S' && strcmp (*namep, "_SDA_BASE_") == 0 && is_elf_hash_table (info->hash)) @@ -1390,7 +1394,8 @@ m32r_elf_add_symbol_hook (bfd *abfd, flags); if (s == NULL) return FALSE; - bfd_set_section_alignment (abfd, s, 2); + if (! bfd_set_section_alignment (abfd, s, 2)) + return FALSE; } bh = bfd_link_hash_lookup (info->hash, "_SDA_BASE_", @@ -1518,11 +1523,6 @@ struct elf_m32r_link_hash_table struct elf_link_hash_table root; /* Short-cuts to get to dynamic linker sections. */ - asection *sgot; - asection *sgotplt; - asection *srelgot; - asection *splt; - asection *srelplt; asection *sdynbss; asection *srelbss; @@ -1585,7 +1585,7 @@ m32r_elf_link_hash_table_create (bfd *abfd) struct elf_m32r_link_hash_table *ret; bfd_size_type amt = sizeof (struct elf_m32r_link_hash_table); - ret = bfd_malloc (amt); + ret = bfd_zmalloc (amt); if (ret == NULL) return NULL; @@ -1598,42 +1598,9 @@ m32r_elf_link_hash_table_create (bfd *abfd) return NULL; } - ret->sgot = NULL; - ret->sgotplt = NULL; - ret->srelgot = NULL; - ret->splt = NULL; - ret->srelplt = NULL; - ret->sdynbss = NULL; - ret->srelbss = NULL; - ret->sym_cache.abfd = NULL; - return &ret->root.root; } -/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up - shortcuts to them in our hash table. */ - -static bfd_boolean -create_got_section (bfd *dynobj, struct bfd_link_info *info) -{ - struct elf_m32r_link_hash_table *htab; - - if (! _bfd_elf_create_got_section (dynobj, info)) - return FALSE; - - htab = m32r_elf_hash_table (info); - if (htab == NULL) - return FALSE; - - htab->sgot = bfd_get_section_by_name (dynobj, ".got"); - htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt"); - htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); - if (! htab->sgot || ! htab->sgotplt || ! htab->srelgot) - abort (); - - return TRUE; -} - /* Create dynamic sections when linking against a dynamic object. */ static bfd_boolean @@ -1661,8 +1628,8 @@ m32r_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) if (bed->plt_readonly) pltflags |= SEC_READONLY; - s = bfd_make_section_with_flags (abfd, ".plt", pltflags); - htab->splt = s; + s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags); + htab->root.splt = s; if (s == NULL || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment)) return FALSE; @@ -1684,49 +1651,24 @@ m32r_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) h->type = STT_OBJECT; htab->root.hplt = h; - if (info->shared + if (bfd_link_pic (info) && ! bfd_elf_link_record_dynamic_symbol (info, h)) return FALSE; } - s = bfd_make_section_with_flags (abfd, - bed->default_use_rela_p ? ".rela.plt" : ".rel.plt", - flags | SEC_READONLY); - htab->srelplt = s; + s = bfd_make_section_anyway_with_flags (abfd, + bed->default_use_rela_p + ? ".rela.plt" : ".rel.plt", + flags | SEC_READONLY); + htab->root.srelplt = s; if (s == NULL || ! bfd_set_section_alignment (abfd, s, ptralign)) return FALSE; - if (htab->sgot == NULL - && ! create_got_section (abfd, info)) + if (htab->root.sgot == NULL + && !_bfd_elf_create_got_section (abfd, info)) return FALSE; - { - const char *secname; - char *relname; - flagword secflags; - asection *sec; - - for (sec = abfd->sections; sec; sec = sec->next) - { - secflags = bfd_get_section_flags (abfd, sec); - if ((secflags & (SEC_DATA | SEC_LINKER_CREATED)) - || ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS)) - continue; - secname = bfd_get_section_name (abfd, sec); - relname = bfd_malloc ((bfd_size_type) strlen (secname) + 6); - strcpy (relname, ".rela"); - strcat (relname, secname); - if (bfd_get_section_by_name (abfd, secname)) - continue; - s = bfd_make_section_with_flags (abfd, relname, - flags | SEC_READONLY); - if (s == NULL - || ! bfd_set_section_alignment (abfd, s, ptralign)) - return FALSE; - } - } - if (bed->want_dynbss) { /* The .dynbss section is a place to put symbols which are defined @@ -1735,8 +1677,8 @@ m32r_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) image and use a R_*_COPY reloc to tell the dynamic linker to initialize them at run time. The linker script puts the .dynbss section into the .bss section of the final image. */ - s = bfd_make_section_with_flags (abfd, ".dynbss", - SEC_ALLOC | SEC_LINKER_CREATED); + s = bfd_make_section_anyway_with_flags (abfd, ".dynbss", + SEC_ALLOC | SEC_LINKER_CREATED); htab->sdynbss = s; if (s == NULL) return FALSE; @@ -1751,12 +1693,12 @@ m32r_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) be needed, we can discard it later. We will never need this section when generating a shared object, since they do not use copy relocs. */ - if (! info->shared) + if (! bfd_link_pic (info)) { - s = bfd_make_section_with_flags (abfd, - (bed->default_use_rela_p - ? ".rela.bss" : ".rel.bss"), - flags | SEC_READONLY); + s = bfd_make_section_anyway_with_flags (abfd, + (bed->default_use_rela_p + ? ".rela.bss" : ".rel.bss"), + flags | SEC_READONLY); htab->srelbss = s; if (s == NULL || ! bfd_set_section_alignment (abfd, s, ptralign)) @@ -1851,7 +1793,7 @@ m32r_elf_adjust_dynamic_symbol (struct bfd_link_info *info, if (h->type == STT_FUNC || h->needs_plt) { - if (! info->shared + if (! bfd_link_pic (info) && !h->def_dynamic && !h->ref_dynamic && h->root.type != bfd_link_hash_undefweak @@ -1890,7 +1832,7 @@ m32r_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; /* If there are no references to this symbol that do not use the @@ -1922,13 +1864,6 @@ m32r_elf_adjust_dynamic_symbol (struct bfd_link_info *info, return TRUE; } - if (h->size == 0) - { - (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"), - h->root.root.string); - return TRUE; - } - /* We must allocate the symbol in our .dynbss section, which will become part of the .bss section of the executable. There will be an entry for this symbol in the .dynsym section. The dynamic @@ -1950,7 +1885,7 @@ m32r_elf_adjust_dynamic_symbol (struct bfd_link_info *info, to copy the initial value out of the dynamic object and into the runtime process image. We need to remember the offset into the .rela.bss section we are going to use. */ - if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) + if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0) { asection *srel; @@ -1960,7 +1895,7 @@ m32r_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); } /* Allocate space in .plt, .got and associated reloc sections for @@ -1996,9 +1931,9 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) return FALSE; } - if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h)) + if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, bfd_link_pic (info), h)) { - asection *s = htab->splt; + asection *s = htab->root.splt; /* If this is the first .plt entry, make room for the special first entry. */ @@ -2012,7 +1947,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) location in the .plt. This is required to make function pointers compare as equal between the normal executable and the shared library. */ - if (! info->shared + if (! bfd_link_pic (info) && !h->def_regular) { h->root.u.def.section = s; @@ -2024,10 +1959,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ - htab->sgotplt->size += 4; + htab->root.sgotplt->size += 4; /* We also need to make an entry in the .rel.plt section. */ - htab->srelplt->size += sizeof (Elf32_External_Rela); + htab->root.srelplt->size += sizeof (Elf32_External_Rela); } else { @@ -2055,13 +1990,13 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) return FALSE; } - s = htab->sgot; + s = htab->root.sgot; h->got.offset = s->size; s->size += 4; dyn = htab->root.dynamic_sections_created; - if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)) - htab->srelgot->size += sizeof (Elf32_External_Rela); + if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h)) + htab->root.srelgot->size += sizeof (Elf32_External_Rela); } else h->got.offset = (bfd_vma) -1; @@ -2075,7 +2010,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) space for pc-relative relocs that have become local due to symbol visibility changes. */ - if (info->shared) + if (bfd_link_pic (info)) { if (h->def_regular && (h->forced_local @@ -2207,9 +2142,9 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, if (htab->root.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_section_by_name (dynobj, ".interp"); + s = bfd_get_linker_section (dynobj, ".interp"); BFD_ASSERT (s != NULL); s->size = sizeof ELF_DYNAMIC_INTERPRETER; s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; @@ -2218,7 +2153,7 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* Set up .got offsets for local syms, and space for local dynamic relocs. */ - for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) + for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next) { bfd_signed_vma *local_got; bfd_signed_vma *end_local_got; @@ -2263,15 +2198,15 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, symtab_hdr = &elf_tdata (ibfd)->symtab_hdr; locsymcount = symtab_hdr->sh_info; end_local_got = local_got + locsymcount; - s = htab->sgot; - srel = htab->srelgot; + s = htab->root.sgot; + srel = htab->root.srelgot; for (; local_got < end_local_got; ++local_got) { if (*local_got > 0) { *local_got = s->size; s->size += 4; - if (info->shared) + if (bfd_link_pic (info)) srel->size += sizeof (Elf32_External_Rela); } else @@ -2291,9 +2226,9 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, if ((s->flags & SEC_LINKER_CREATED) == 0) continue; - if (s == htab->splt - || s == htab->sgot - || s == htab->sgotplt + if (s == htab->root.splt + || s == htab->root.sgot + || s == htab->root.sgotplt || s == htab->sdynbss) { /* Strip this section if we don't need it; see the @@ -2301,7 +2236,7 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, } else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela")) { - if (s->size != 0 && s != htab->srelplt) + if (s->size != 0 && s != htab->root.srelplt) relocs = TRUE; /* We use the reloc_count field as a counter if we need @@ -2350,13 +2285,13 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, #define add_dynamic_entry(TAG, VAL) \ _bfd_elf_add_dynamic_entry (info, TAG, VAL) - if (info->executable) + if (bfd_link_executable (info)) { if (! add_dynamic_entry (DT_DEBUG, 0)) return FALSE; } - if (htab->splt->size != 0) + if (htab->root.splt->size != 0) { if (! add_dynamic_entry (DT_PLTGOT, 0) || ! add_dynamic_entry (DT_PLTRELSZ, 0) @@ -2440,7 +2375,6 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, /* Assume success. */ bfd_boolean ret = TRUE; struct elf_m32r_link_hash_table *htab = m32r_elf_hash_table (info); - bfd *dynobj; bfd_vma *local_got_offsets; asection *sgot, *splt, *sreloc; bfd_vma high_address = bfd_get_section_limit (input_bfd, input_section); @@ -2448,11 +2382,10 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, if (htab == NULL) return FALSE; - dynobj = htab->root.dynobj; local_got_offsets = elf_local_got_offsets (input_bfd); - sgot = htab->sgot; - splt = htab->splt; + sgot = htab->root.sgot; + splt = htab->root.splt; sreloc = NULL; rel = relocs; @@ -2481,9 +2414,9 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, r_type = ELF32_R_TYPE (rel->r_info); if (r_type < 0 || r_type >= (int) R_M32R_max) { - (*_bfd_error_handler) (_("%B: unknown relocation type %d"), - input_bfd, - (int) r_type); + /* xgettext:c-format */ + _bfd_error_handler (_("%B: unknown relocation type %d"), + input_bfd, (int) r_type); bfd_set_error (bfd_error_bad_value); ret = FALSE; continue; @@ -2531,6 +2464,12 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, relocation = 0; 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; @@ -2555,11 +2494,12 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, || r_type == R_M32R_GOT16_HI_SLO || r_type == R_M32R_GOT16_LO) && WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, - info->shared, h) - && (! info->shared + bfd_link_pic (info), + h) + && (! bfd_link_pic (info) || (! info->symbolic && h->dynindx != -1) || !h->def_regular)) - || (info->shared + || (bfd_link_pic (info) && ((! info->symbolic && h->dynindx != -1) || !h->def_regular) && (((r_type == R_M32R_16_RELA @@ -2589,9 +2529,14 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, relocation = (h->root.u.def.value + sec->output_section->vma + sec->output_offset); - else if (!info->relocatable) + else if (!bfd_link_relocatable (info) + && (_bfd_elf_section_offset (output_bfd, info, + input_section, + rel->r_offset) + != (bfd_vma) -1)) { - (*_bfd_error_handler) + _bfd_error_handler + /* xgettext:c-format */ (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"), input_bfd, input_section, @@ -2605,22 +2550,19 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, else if (info->unresolved_syms_in_objects == RM_IGNORE && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) ; - else if (!info->relocatable) - { - if (! ((*info->callbacks->undefined_symbol) - (info, h->root.root.string, input_bfd, - input_section, offset, - (info->unresolved_syms_in_objects == RM_GENERATE_ERROR - || ELF_ST_VISIBILITY (h->other))))) - return FALSE; - } + else if (!bfd_link_relocatable (info)) + (*info->callbacks->undefined_symbol) + (info, h->root.root.string, input_bfd, + input_section, offset, + (info->unresolved_syms_in_objects == RM_GENERATE_ERROR + || ELF_ST_VISIBILITY (h->other))); } - if (sec != NULL && elf_discarded_section (sec)) + if (sec != NULL && discarded_section (sec)) RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, - rel, relend, howto, contents); + rel, 1, relend, howto, 0, contents); - if (info->relocatable && !use_rel) + if (bfd_link_relocatable (info) && !use_rel) { /* This is a relocatable link. We don't have to change anything, unless the reloc is against a section symbol, @@ -2631,7 +2573,7 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, continue; } - if (info->relocatable && use_rel) + if (bfd_link_relocatable (info) && use_rel) { /* This is a relocatable link. We don't have to change anything, unless the reloc is against a section symbol, @@ -2760,8 +2702,10 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, BFD_ASSERT (off != (bfd_vma) -1); dyn = htab->root.dynamic_sections_created; - if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h) - || (info->shared + if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, + bfd_link_pic (info), + h) + || (bfd_link_pic (info) && (info->symbolic || h->dynindx == -1 || h->forced_local) @@ -2810,14 +2754,14 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, { bfd_put_32 (output_bfd, relocation, sgot->contents + off); - if (info->shared) + if (bfd_link_pic (info)) { asection *srelgot; Elf_Internal_Rela outrel; /* We need to generate a R_M32R_RELATIVE reloc for the dynamic linker. */ - srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); + srelgot = htab->root.srelgot; BFD_ASSERT (srelgot != NULL); outrel.r_offset = (sgot->output_section->vma @@ -2880,7 +2824,7 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, case R_M32R_26_PCREL_RELA: case R_M32R_HI16_ULO_RELA: case R_M32R_LO16_RELA: - if (info->shared + if (bfd_link_pic (info) && r_symndx != STN_UNDEF && (input_section->flags & SEC_ALLOC) != 0 && (( r_type != R_M32R_10_PCREL_RELA @@ -3010,7 +2954,7 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, const char *name; BFD_ASSERT (sec != NULL); - name = bfd_get_section_name (abfd, sec); + name = bfd_get_section_name (sec->owner, sec); if ( strcmp (name, ".sdata") == 0 || strcmp (name, ".sbss") == 0 @@ -3035,12 +2979,13 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, } else { - (*_bfd_error_handler) + _bfd_error_handler + /* xgettext:c-format */ (_("%B: The target (%s) of an %s relocation is in the wrong section (%A)"), input_bfd, - sec, sym_name, - m32r_elf_howto_table[(int) r_type].name); + m32r_elf_howto_table[(int) r_type].name, + sec); /*bfd_set_error (bfd_error_bad_value); ??? why? */ ret = FALSE; continue; @@ -3085,17 +3030,14 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, switch (r) { case bfd_reloc_overflow: - if (! ((*info->callbacks->reloc_overflow) - (info, (h ? &h->root : NULL), name, howto->name, - (bfd_vma) 0, input_bfd, input_section, offset))) - return FALSE; + (*info->callbacks->reloc_overflow) + (info, (h ? &h->root : NULL), name, howto->name, + (bfd_vma) 0, input_bfd, input_section, offset); break; case bfd_reloc_undefined: - if (! ((*info->callbacks->undefined_symbol) - (info, name, input_bfd, input_section, - offset, TRUE))) - return FALSE; + (*info->callbacks->undefined_symbol) + (info, name, input_bfd, input_section, offset, TRUE); break; case bfd_reloc_outofrange: @@ -3115,10 +3057,8 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, /* fall through */ common_error: - if (!((*info->callbacks->warning) - (info, errmsg, name, input_bfd, input_section, - offset))) - return FALSE; + (*info->callbacks->warning) (info, errmsg, name, input_bfd, + input_section, offset); break; } } @@ -3162,9 +3102,9 @@ m32r_elf_finish_dynamic_symbol (bfd *output_bfd, BFD_ASSERT (h->dynindx != -1); - splt = htab->splt; - sgot = htab->sgotplt; - srela = htab->srelplt; + splt = htab->root.splt; + sgot = htab->root.sgotplt; + srela = htab->root.srelplt; BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL); /* Get the index in the procedure linkage table which @@ -3179,7 +3119,7 @@ m32r_elf_finish_dynamic_symbol (bfd *output_bfd, got_offset = (plt_index + 3) * 4; /* Fill in the entry in the procedure linkage table. */ - if (! info->shared) + if (! bfd_link_pic (info)) { bfd_put_32 (output_bfd, (PLT_ENTRY_WORD0b @@ -3258,8 +3198,8 @@ m32r_elf_finish_dynamic_symbol (bfd *output_bfd, /* This symbol has an entry in the global offset table. Set it up. */ - sgot = htab->sgot; - srela = htab->srelgot; + sgot = htab->root.sgot; + srela = htab->root.srelgot; BFD_ASSERT (sgot != NULL && srela != NULL); rela.r_offset = (sgot->output_section->vma @@ -3271,7 +3211,7 @@ m32r_elf_finish_dynamic_symbol (bfd *output_bfd, the symbol was forced to be local because of a version file. The entry in the global offset table will already have been initialized in the relocate_section function. */ - if (info->shared + if (bfd_link_pic (info) && (info->symbolic || h->dynindx == -1 || h->forced_local) @@ -3307,8 +3247,7 @@ m32r_elf_finish_dynamic_symbol (bfd *output_bfd, && (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak)); - s = bfd_get_section_by_name (h->root.u.def.section->owner, - ".rela.bss"); + s = bfd_get_linker_section (htab->root.dynobj, ".rela.bss"); BFD_ASSERT (s != NULL); rela.r_offset = (h->root.u.def.value @@ -3323,8 +3262,7 @@ m32r_elf_finish_dynamic_symbol (bfd *output_bfd, } /* Mark some specially defined symbols as absolute. */ - if (strcmp (h->root.root.string, "_DYNAMIC") == 0 - || h == htab->root.hgot) + if (h == htab->root.hdynamic || h == htab->root.hgot) sym->st_shndx = SHN_ABS; return TRUE; @@ -3352,8 +3290,8 @@ m32r_elf_finish_dynamic_sections (bfd *output_bfd, dynobj = htab->root.dynobj; - sgot = htab->sgotplt; - sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); + sgot = htab->root.sgotplt; + sdyn = bfd_get_linker_section (dynobj, ".dynamic"); if (htab->root.dynamic_sections_created) { @@ -3378,48 +3316,28 @@ m32r_elf_finish_dynamic_sections (bfd *output_bfd, break; case DT_PLTGOT: - s = htab->sgot->output_section; + s = htab->root.sgotplt; goto get_vma; case DT_JMPREL: - s = htab->srelplt->output_section; + s = htab->root.srelplt; get_vma: - BFD_ASSERT (s != NULL); - dyn.d_un.d_ptr = s->vma; + dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; case DT_PLTRELSZ: - s = htab->srelplt->output_section; - BFD_ASSERT (s != NULL); + s = htab->root.srelplt; dyn.d_un.d_val = s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; - - case DT_RELASZ: - /* My reading of the SVR4 ABI indicates that the - procedure linkage table relocs (DT_JMPREL) should be - included in the overall relocs (DT_RELA). This is - what Solaris does. However, UnixWare can not handle - that case. Therefore, we override the DT_RELASZ entry - here to make it not include the JMPREL relocs. Since - the linker script arranges for .rela.plt to follow all - other relocation sections, we don't have to worry - about changing the DT_RELA entry. */ - if (htab->srelplt != NULL) - { - s = htab->srelplt->output_section; - dyn.d_un.d_val -= s->size; - } - bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); - break; } } /* Fill in the first entry in the procedure linkage table. */ - splt = htab->splt; + splt = htab->root.splt; if (splt && splt->size > 0) { - if (info->shared) + if (bfd_link_pic (info)) { bfd_put_32 (output_bfd, PLT0_PIC_ENTRY_WORD0, splt->contents); bfd_put_32 (output_bfd, PLT0_PIC_ENTRY_WORD1, splt->contents + 4); @@ -3519,8 +3437,9 @@ m32r_elf_set_private_flags (bfd *abfd, flagword flags) object file when linking. */ static bfd_boolean -m32r_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) +m32r_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info) { + bfd *obfd = info->output_bfd; flagword out_flags; flagword in_flags; @@ -3563,7 +3482,7 @@ m32r_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) || ((out_flags & EF_M32R_ARCH) == E_M32R_ARCH) || ((in_flags & EF_M32R_ARCH) == E_M32R2_ARCH)) { - (*_bfd_error_handler) + _bfd_error_handler (_("%B: Instruction set mismatch with previous modules"), ibfd); bfd_set_error (bfd_error_bad_value); @@ -3632,7 +3551,7 @@ m32r_elf_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED, bfd_signed_vma *local_got_refcounts; const Elf_Internal_Rela *rel, *relend; - if (info->relocatable) + if (bfd_link_relocatable (info)) return TRUE; elf_section_data (sec)->local_dynrel = NULL; @@ -3699,7 +3618,7 @@ m32r_elf_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED, struct elf_m32r_dyn_relocs **pp; struct elf_m32r_dyn_relocs *p; - if (!info->shared && h->plt.refcount > 0) + if (!bfd_link_pic (info) && h->plt.refcount > 0) h->plt.refcount -= 1; eh = (struct elf_m32r_link_hash_entry *) h; @@ -3754,7 +3673,7 @@ m32r_elf_check_relocs (bfd *abfd, bfd *dynobj; asection *sreloc; - if (info->relocatable) + if (bfd_link_relocatable (info)) return TRUE; sreloc = NULL; @@ -3784,10 +3703,14 @@ m32r_elf_check_relocs (bfd *abfd, 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; + + /* PR15323, ref flags aren't set for references in the same + object. */ + h->root.non_ir_ref = 1; } /* Some relocs require a global offset table. */ - if (htab->sgot == NULL) + if (htab->root.sgot == NULL) { switch (r_type) { @@ -3805,7 +3728,7 @@ m32r_elf_check_relocs (bfd *abfd, case R_M32R_GOT24: if (dynobj == NULL) htab->root.dynobj = dynobj = abfd; - if (! create_got_section (dynobj, info)) + if (!_bfd_elf_create_got_section (dynobj, info)) return FALSE; break; @@ -3876,7 +3799,7 @@ m32r_elf_check_relocs (bfd *abfd, case R_M32R_18_PCREL_RELA: case R_M32R_26_PCREL_RELA: - if (h != NULL && !info->shared) + if (h != NULL && !bfd_link_pic (info)) { h->non_got_ref = 1; h->plt.refcount += 1; @@ -3901,7 +3824,7 @@ m32r_elf_check_relocs (bfd *abfd, may need to keep relocations for symbols satisfied by a dynamic library if we manage to avoid copy relocs for the symbol. */ - if ((info->shared + if ((bfd_link_pic (info) && (sec->flags & SEC_ALLOC) != 0 && (( r_type != R_M32R_26_PCREL_RELA && r_type != R_M32R_18_PCREL_RELA @@ -3911,7 +3834,7 @@ m32r_elf_check_relocs (bfd *abfd, && (! info->symbolic || h->root.type == bfd_link_hash_defweak || !h->def_regular)))) - || (!info->shared + || (!bfd_link_pic (info) && (sec->flags & SEC_ALLOC) != 0 && h != NULL && (h->root.type == bfd_link_hash_defweak @@ -4019,7 +3942,9 @@ static const struct bfd_elf_special_section m32r_elf_special_sections[] = }; static enum elf_reloc_type_class -m32r_elf_reloc_type_class (const Elf_Internal_Rela *rela) +m32r_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED, + const asection *rel_sec ATTRIBUTE_UNUSED, + const Elf_Internal_Rela *rela) { switch ((int) ELF32_R_TYPE (rela->r_info)) { @@ -4036,9 +3961,9 @@ m32r_elf_reloc_type_class (const Elf_Internal_Rela *rela) #define ELF_MACHINE_ALT1 EM_CYGNUS_M32R #define ELF_MAXPAGESIZE 0x1 /* Explicitly requested by Mitsubishi. */ -#define TARGET_BIG_SYM bfd_elf32_m32r_vec +#define TARGET_BIG_SYM m32r_elf32_vec #define TARGET_BIG_NAME "elf32-m32r" -#define TARGET_LITTLE_SYM bfd_elf32_m32rle_vec +#define TARGET_LITTLE_SYM m32r_elf32_le_vec #define TARGET_LITTLE_NAME "elf32-m32rle" #define elf_info_to_howto m32r_info_to_howto @@ -4071,6 +3996,7 @@ m32r_elf_reloc_type_class (const Elf_Internal_Rela *rela) #define elf_backend_plt_readonly 1 #define elf_backend_want_plt_sym 0 #define elf_backend_got_header_size 12 +#define elf_backend_dtrel_excludes_plt 1 #define elf_backend_may_use_rel_p 1 #ifdef USE_M32R_OLD_RELOC @@ -4094,15 +4020,14 @@ m32r_elf_reloc_type_class (const Elf_Internal_Rela *rela) #define ELF_MAXPAGESIZE 0x1000 #undef TARGET_BIG_SYM -#define TARGET_BIG_SYM bfd_elf32_m32rlin_vec +#define TARGET_BIG_SYM m32r_elf32_linux_vec #undef TARGET_BIG_NAME #define TARGET_BIG_NAME "elf32-m32r-linux" #undef TARGET_LITTLE_SYM -#define TARGET_LITTLE_SYM bfd_elf32_m32rlelin_vec +#define TARGET_LITTLE_SYM m32r_elf32_linux_le_vec #undef TARGET_LITTLE_NAME #define TARGET_LITTLE_NAME "elf32-m32rle-linux" #undef elf32_bed #define elf32_bed elf32_m32r_lin_bed #include "elf32-target.h" -