X-Git-Url: http://drtracing.org/?a=blobdiff_plain;ds=sidebyside;f=bfd%2Felf32-bfin.c;h=d7d096af1c8146690434abac0a80a3c5b3eea1a2;hb=b5966800eaa13f4b886f94fed01a7fdfac2b3965;hp=d3d0f1c86ddfd25eb7e0fa52ee65b69d2605db70;hpb=81fbe831fe0239501808446529614a07449695e3;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c index d3d0f1c86d..d7d096af1c 100644 --- a/bfd/elf32-bfin.c +++ b/bfd/elf32-bfin.c @@ -1,6 +1,5 @@ /* ADI Blackfin BFD support for 32-bit ELF. - Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 - Free Software Foundation, Inc. + Copyright (C) 2005-2016 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -424,11 +423,11 @@ static reloc_howto_type bfin_howto_table [] = /* This reloc does nothing. . */ HOWTO (R_BFIN_UNUSED0, /* 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_BFIN_UNUSED0", /* name. */ FALSE, /* partial_inplace. */ @@ -452,11 +451,11 @@ static reloc_howto_type bfin_howto_table [] = HOWTO (R_BFIN_UNUSED1, /* 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_BFIN_UNUSED1", /* name. */ FALSE, /* partial_inplace. */ @@ -582,8 +581,8 @@ static reloc_howto_type bfin_howto_table [] = HOWTO (R_BFIN_UNUSEDB, /* 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_dont, /* complain_on_overflow. */ @@ -596,8 +595,8 @@ static reloc_howto_type bfin_howto_table [] = HOWTO (R_BFIN_UNUSEDC, /* 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_dont, /* complain_on_overflow. */ @@ -1066,13 +1065,13 @@ bfin_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, bfd_reloc_code_real_type code) { unsigned int i; - unsigned int r_type = BFIN_RELOC_MIN; + unsigned int r_type = (unsigned int) -1; - for (i = sizeof (bfin_reloc_map) / sizeof (bfin_reloc_map[0]); --i;) + for (i = sizeof (bfin_reloc_map) / sizeof (bfin_reloc_map[0]); i--;) if (bfin_reloc_map[i].bfd_reloc_val == code) r_type = bfin_reloc_map[i].bfin_reloc_val; - if (r_type <= BFIN_RELOC_MAX && r_type > BFIN_RELOC_MIN) + if (r_type <= BFIN_RELOC_MAX) return &bfin_howto_table [r_type]; else if (r_type >= BFIN_GNUEXT_RELOC_MIN && r_type <= BFIN_GNUEXT_RELOC_MAX) @@ -1166,7 +1165,7 @@ bfin_check_relocs (bfd * abfd, asection *sgot; asection *srelgot; - if (info->relocatable) + if (bfd_link_relocatable (info)) return TRUE; dynobj = elf_hash_table (info)->dynobj; @@ -1233,7 +1232,7 @@ bfin_check_relocs (bfd * abfd, BFD_ASSERT (sgot != NULL); } - if (srelgot == NULL && (h != NULL || info->shared)) + if (srelgot == NULL && (h != NULL || bfd_link_pic (info))) { srelgot = bfd_get_linker_section (dynobj, ".rela.got"); if (srelgot == NULL) @@ -1286,7 +1285,7 @@ bfin_check_relocs (bfd * abfd, if (local_got_refcounts[r_symndx] == 0) { sgot->size += 4; - if (info->shared) + if (bfd_link_pic (info)) { /* If we are generating a shared object, we need to output a R_68K_RELATIVE reloc so that the dynamic @@ -1444,19 +1443,19 @@ bfin_relocate_section (bfd * output_bfd, } else { - bfd_boolean warned; + bfd_boolean warned, ignored; RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, r_symndx, symtab_hdr, sym_hashes, h, sec, relocation, - unresolved_reloc, warned); + unresolved_reloc, warned, ignored); } if (sec != NULL && discarded_section (sec)) RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, rel, 1, relend, howto, 0, contents); - if (info->relocatable) + if (bfd_link_relocatable (info)) continue; address = rel->r_offset; @@ -1503,8 +1502,10 @@ bfin_relocate_section (bfd * output_bfd, BFD_ASSERT (off != (bfd_vma) - 1); dyn = elf_hash_table (info)->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) @@ -1549,7 +1550,7 @@ bfin_relocate_section (bfd * output_bfd, { bfd_put_32 (output_bfd, relocation, sgot->contents + off); - if (info->shared) + if (bfd_link_pic (info)) { asection *s; Elf_Internal_Rela outrel; @@ -1622,12 +1623,9 @@ bfin_relocate_section (bfd * output_bfd, } if (r == bfd_reloc_overflow) - { - if (!(info->callbacks->reloc_overflow - (info, (h ? &h->root : NULL), name, howto->name, - (bfd_vma) 0, input_bfd, input_section, rel->r_offset))) - return FALSE; - } + (*info->callbacks->reloc_overflow) + (info, (h ? &h->root : NULL), name, howto->name, + (bfd_vma) 0, input_bfd, input_section, rel->r_offset); else { (*_bfd_error_handler) @@ -1720,7 +1718,7 @@ bfin_gc_sweep_hook (bfd * abfd, { /* We don't need the .got entry any more. */ sgot->size -= 4; - if (info->shared) + if (bfd_link_pic (info)) srelgot->size -= sizeof (Elf32_External_Rela); } } @@ -1733,8 +1731,8 @@ bfin_gc_sweep_hook (bfd * abfd, return TRUE; } -extern const bfd_target bfd_elf32_bfinfdpic_vec; -#define IS_FDPIC(bfd) ((bfd)->xvec == &bfd_elf32_bfinfdpic_vec) +extern const bfd_target bfin_elf32_fdpic_vec; +#define IS_FDPIC(bfd) ((bfd)->xvec == &bfin_elf32_fdpic_vec) /* An extension of the elf hash table data structure, containing some additional Blackfin-specific data. */ @@ -2214,7 +2212,7 @@ _bfinfdpic_emit_got_relocs_plt_entries (struct bfinfdpic_relocs_info *entry, /* If we're linking an executable at a fixed address, we can omit the dynamic relocation as long as the symbol is local to this module. */ - if (info->executable && !info->pie + if (bfd_link_pde (info) && (entry->symndx != -1 || BFINFDPIC_SYM_LOCAL (info, entry->d.h))) { @@ -2269,7 +2267,7 @@ _bfinfdpic_emit_got_relocs_plt_entries (struct bfinfdpic_relocs_info *entry, if (entry->symndx == -1 && ! BFINFDPIC_FUNCDESC_LOCAL (info, entry->d.h) && BFINFDPIC_SYM_LOCAL (info, entry->d.h) - && !(info->executable && !info->pie)) + && !bfd_link_pde (info)) { reloc = R_BFIN_FUNCDESC; idx = elf_section_data (entry->d.h->root.u.def.section @@ -2305,7 +2303,7 @@ _bfinfdpic_emit_got_relocs_plt_entries (struct bfinfdpic_relocs_info *entry, dynamic symbol entry for the got section, so idx will be zero, which means we can and should compute the address of the private descriptor ourselves. */ - if (info->executable && !info->pie + if (bfd_link_pde (info) && (entry->symndx != -1 || BFINFDPIC_FUNCDESC_LOCAL (info, entry->d.h))) { @@ -2368,7 +2366,7 @@ _bfinfdpic_emit_got_relocs_plt_entries (struct bfinfdpic_relocs_info *entry, /* If we're linking an executable at a fixed address, we can omit the dynamic relocation as long as the symbol is local to this module. */ - if (info->executable && !info->pie + if (bfd_link_pde (info) && (entry->symndx != -1 || BFINFDPIC_SYM_LOCAL (info, entry->d.h))) { if (sec) @@ -2416,7 +2414,9 @@ _bfinfdpic_emit_got_relocs_plt_entries (struct bfinfdpic_relocs_info *entry, /* If we've omitted the dynamic relocation, just emit the fixed addresses of the symbol and of the local GOT base offset. */ - if (info->executable && !info->pie && sec && sec->output_section) + if (bfd_link_pde (info) + && sec + && sec->output_section) { lowword = ad; highword = bfinfdpic_got_section (info)->output_section->vma @@ -2596,7 +2596,7 @@ bfinfdpic_relocate_section (bfd * output_bfd, Elf_Internal_Rela *relend; unsigned isec_segment, got_segment, plt_segment, check_segment[2]; - int silence_segment_error = !(info->shared || info->pie); + int silence_segment_error = !bfd_link_pic (info); symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); @@ -2662,13 +2662,13 @@ bfinfdpic_relocate_section (bfd * output_bfd, } else { - bfd_boolean warned; + bfd_boolean warned, ignored; bfd_boolean unresolved_reloc; RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, r_symndx, symtab_hdr, sym_hashes, h, sec, relocation, - unresolved_reloc, warned); + unresolved_reloc, warned, ignored); osec = sec; } @@ -2676,7 +2676,7 @@ bfinfdpic_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; if (h != NULL @@ -2830,7 +2830,7 @@ bfinfdpic_relocate_section (bfd * output_bfd, section+offset. */ if (h && ! BFINFDPIC_FUNCDESC_LOCAL (info, h) && BFINFDPIC_SYM_LOCAL (info, h) - && !(info->executable && !info->pie)) + && !bfd_link_pde (info)) { dynindx = elf_section_data (h->root.u.def.section ->output_section)->dynindx; @@ -2867,7 +2867,7 @@ bfinfdpic_relocate_section (bfd * output_bfd, dynamic symbol entry for the got section, so idx will be zero, which means we can and should compute the address of the private descriptor ourselves. */ - if (info->executable && !info->pie + if (bfd_link_pde (info) && (!h || BFINFDPIC_FUNCDESC_LOCAL (info, h))) { bfd_vma offset; @@ -2990,7 +2990,7 @@ bfinfdpic_relocate_section (bfd * output_bfd, can omit the dynamic relocation as long as the symbol is defined in the current link unit (which is implied by its output section not being NULL). */ - if (info->executable && !info->pie + if (bfd_link_pde (info) && (!h || BFINFDPIC_SYM_LOCAL (info, h))) { if (osec) @@ -3070,7 +3070,7 @@ bfinfdpic_relocate_section (bfd * output_bfd, /* If we've omitted the dynamic relocation, just emit the fixed addresses of the symbol and of the local GOT base offset. */ - if (info->executable && !info->pie + if (bfd_link_pde (info) && (!h || BFINFDPIC_SYM_LOCAL (info, h))) bfd_put_32 (output_bfd, bfinfdpic_got_section (info)->output_section->vma @@ -3128,11 +3128,11 @@ bfinfdpic_relocate_section (bfd * output_bfd, && picrel->d.h->root.type == bfd_link_hash_undefined)) info->callbacks->warning (info, - (info->shared || info->pie) + bfd_link_pic (info) ? _("relocations between different segments are not supported") : _("warning: relocation references a different segment"), name, input_bfd, input_section, rel->r_offset); - if (!silence_segment_error && (info->shared || info->pie)) + if (!silence_segment_error && bfd_link_pic (info)) return FALSE; elf_elfheader (output_bfd)->e_flags |= EF_BFIN_PIC; } @@ -3206,13 +3206,13 @@ bfinfdpic_relocate_section (bfd * output_bfd, switch (r) { case bfd_reloc_overflow: - r = info->callbacks->reloc_overflow + (*info->callbacks->reloc_overflow) (info, (h ? &h->root : NULL), name, howto->name, (bfd_vma) 0, input_bfd, input_section, rel->r_offset); break; case bfd_reloc_undefined: - r = info->callbacks->undefined_symbol + (*info->callbacks->undefined_symbol) (info, name, input_bfd, input_section, rel->r_offset, TRUE); break; @@ -3234,11 +3234,8 @@ bfinfdpic_relocate_section (bfd * output_bfd, } if (msg) - r = info->callbacks->warning - (info, msg, name, input_bfd, input_section, rel->r_offset); - - if (! r) - return FALSE; + (*info->callbacks->warning) (info, msg, name, input_bfd, + input_section, rel->r_offset); } } @@ -3498,7 +3495,7 @@ _bfin_create_got_section (bfd *abfd, struct bfd_link_info *info) h->def_regular = 1; h->type = STT_OBJECT; - if (! info->executable + if (! bfd_link_executable (info) && ! bfd_elf_link_record_dynamic_symbol (info, h)) return FALSE; } @@ -3567,7 +3564,7 @@ elf32_bfinfdpic_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_anyway_with_flags (abfd, ".rela.bss", @@ -3650,7 +3647,7 @@ _bfinfdpic_count_relocs_fixups (struct bfinfdpic_relocs_info *entry, { bfd_vma relocs = 0, fixups = 0; - if (!dinfo->info->executable || dinfo->info->pie) + if (!bfd_link_pde (dinfo->info)) relocs = entry->relocs32 + entry->relocsfd + entry->relocsfdv; else { @@ -4252,7 +4249,7 @@ elf32_bfinfdpic_size_dynamic_sections (bfd *output_bfd, if (htab->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); @@ -4319,7 +4316,7 @@ static bfd_boolean elf32_bfinfdpic_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) { - if (!info->relocatable + if (!bfd_link_relocatable (info) && !bfd_elf_stack_segment_size (output_bfd, info, "__stacksize", DEFAULT_STACK_SIZE)) return FALSE; @@ -4454,7 +4451,13 @@ elf32_bfinfdpic_finish_dynamic_sections (bfd *output_bfd, if (bfinfdpic_got_section (info)) { BFD_ASSERT (bfinfdpic_gotrel_section (info)->size - == (bfinfdpic_gotrel_section (info)->reloc_count + /* PR 17334: It appears that the GOT section can end up + being bigger than the number of relocs. Presumably + because some relocs have been deleted. A test case has + yet to be generated for verify this, but in the meantime + the test below has been changed from == to >= so that + applications can continue to be built. */ + >= (bfinfdpic_gotrel_section (info)->reloc_count * sizeof (Elf32_External_Rel))); if (bfinfdpic_gotfixup_section (info)) @@ -4736,7 +4739,7 @@ bfinfdpic_check_relocs (bfd *abfd, struct bfd_link_info *info, bfd *dynobj; struct bfinfdpic_relocs_info *picrel; - if (info->relocatable) + if (bfd_link_relocatable (info)) return TRUE; symtab_hdr = &elf_tdata (abfd)->symtab_hdr; @@ -4931,45 +4934,6 @@ elf32_bfin_set_private_flags (bfd * abfd, flagword flags) return TRUE; } -/* Copy backend specific data from one object module to another. */ - -static bfd_boolean -bfin_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd) -{ - if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour - || bfd_get_flavour (obfd) != bfd_target_elf_flavour) - return TRUE; - - BFD_ASSERT (!elf_flags_init (obfd) - || elf_elfheader (obfd)->e_flags == elf_elfheader (ibfd)->e_flags); - - elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags; - elf_flags_init (obfd) = TRUE; - - /* Copy object attributes. */ - _bfd_elf_copy_obj_attributes (ibfd, obfd); - - return TRUE; -} - -static bfd_boolean -elf32_bfinfdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd) -{ - if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour - || bfd_get_flavour (obfd) != bfd_target_elf_flavour) - return TRUE; - - if (! bfin_elf_copy_private_bfd_data (ibfd, obfd)) - return FALSE; - - if (! elf_tdata (ibfd) || ! elf_tdata (ibfd)->phdr - || ! elf_tdata (obfd) || ! elf_tdata (obfd)->phdr) - return TRUE; - - return TRUE; -} - - /* Display the flags field. */ static bfd_boolean elf32_bfin_print_private_bfd_data (bfd * abfd, void * ptr) @@ -5185,7 +5149,7 @@ bfin_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) && h->def_regular) { @@ -5272,7 +5236,7 @@ bfin_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 @@ -5402,7 +5366,7 @@ bfin_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, 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)) { s = bfd_get_linker_section (dynobj, ".interp"); BFD_ASSERT (s != NULL); @@ -5428,7 +5392,7 @@ bfin_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, against symbols that have become local due to visibility changes. We allocated space for them in the check_relocs routine, but we will not fill them in in the relocate_section routine. */ - if (info->shared) + if (bfd_link_pic (info)) elf_link_hash_traverse (elf_hash_table (info), bfin_discard_copies, info); @@ -5507,7 +5471,7 @@ bfin_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, #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; @@ -5555,7 +5519,7 @@ bfd_bfin_elf32_create_embedded_relocs (bfd *abfd, bfd_byte *p; bfd_size_type amt; - BFD_ASSERT (! info->relocatable); + BFD_ASSERT (! bfd_link_relocatable (info)); *errmsg = NULL; @@ -5664,7 +5628,7 @@ struct bfd_elf_special_section const elf32_bfin_special_sections[] = }; -#define TARGET_LITTLE_SYM bfd_elf32_bfin_vec +#define TARGET_LITTLE_SYM bfin_elf32_vec #define TARGET_LITTLE_NAME "elf32-bfin" #define ELF_ARCH bfd_arch_bfin #define ELF_TARGET_ID BFIN_ELF_DATA @@ -5726,7 +5690,7 @@ struct bfd_elf_special_section const elf32_bfin_special_sections[] = #include "elf32-target.h" #undef TARGET_LITTLE_SYM -#define TARGET_LITTLE_SYM bfd_elf32_bfinfdpic_vec +#define TARGET_LITTLE_SYM bfin_elf32_fdpic_vec #undef TARGET_LITTLE_NAME #define TARGET_LITTLE_NAME "elf32-bfinfdpic" #undef elf32_bed @@ -5749,9 +5713,6 @@ struct bfd_elf_special_section const elf32_bfin_special_sections[] = #undef elf_backend_always_size_sections #define elf_backend_always_size_sections \ elf32_bfinfdpic_always_size_sections -#undef bfd_elf32_bfd_copy_private_bfd_data -#define bfd_elf32_bfd_copy_private_bfd_data \ - elf32_bfinfdpic_copy_private_bfd_data #undef elf_backend_create_dynamic_sections #define elf_backend_create_dynamic_sections \