X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Felflink.c;h=be53ca3f9dedcc7cad373c8ea427c30d9dc6a645;hb=eed23bb4a19f8af428d2dea636dfe2c7fd12178e;hp=1a45110597ceee17f561e9f1a4394ea63de00bdd;hpb=313ed4a9b06a7080664ebe5ff040a6fd56c6d5d8;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elflink.c b/bfd/elflink.c index 1a45110597..be53ca3f9d 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -1262,9 +1262,6 @@ _bfd_elf_merge_symbol (bfd *abfd, return TRUE; } - if (bind == STB_GNU_UNIQUE) - h->unique_global = 1; - /* If a new weak symbol definition comes from a regular file and the old symbol comes from a dynamic library, we treat the new one as strong. Similarly, an old weak symbol definition from a regular @@ -2494,7 +2491,7 @@ _bfd_elf_fix_symbol_flags (struct elf_link_hash_entry *h, && !h->def_regular && h->ref_regular && !h->def_dynamic - && (h->root.u.def.section->owner->flags & DYNAMIC) == 0) + && (h->root.u.def.section->owner->flags & (DYNAMIC | BFD_PLUGIN)) == 0) h->def_regular = 1; /* If -Bsymbolic was used (which means to bind references to global @@ -4197,8 +4194,6 @@ error_free_dyn: h = (struct elf_link_hash_entry *) h->root.u.i.link; *sym_hash = h; - if (is_elf_hash_table (htab)) - h->unique_global = (flags & BSF_GNU_UNIQUE) != 0; new_weak = (flags & BSF_WEAK) != 0; new_weakdef = FALSE; @@ -4366,7 +4361,12 @@ error_free_dyn: is one which is referenced or defined by both a regular object and a shared object. */ dynsym = FALSE; - if (! dynamic) + + /* Plugin symbols aren't normal. Don't set def_regular or + ref_regular for them, nor make them dynamic. */ + if ((abfd->flags & BFD_PLUGIN) != 0) + ; + else if (! dynamic) { if (! definition) { @@ -4420,12 +4420,11 @@ error_free_dyn: if (definition && (sec->flags & SEC_DEBUGGING) && !info->relocatable) dynsym = FALSE; - /* Nor should we make plugin symbols dynamic. */ - if ((abfd->flags & BFD_PLUGIN) != 0) - dynsym = FALSE; - if (definition) - h->target_internal = isym->st_target_internal; + { + h->target_internal = isym->st_target_internal; + h->unique_global = (flags & BSF_GNU_UNIQUE) != 0; + } /* Check to see if we need to add an indirect symbol for the default name. */ @@ -4480,11 +4479,14 @@ error_free_dyn: break; } + /* Don't add DT_NEEDED for references from the dummy bfd. */ if (!add_needed && definition && ((dynsym - && h->ref_regular) - || (h->ref_dynamic + && h->ref_regular_nonweak + && (undef_bfd == NULL + || (undef_bfd->flags & BFD_PLUGIN) == 0)) + || (h->ref_dynamic_nonweak && (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0 && !on_needed_list (elf_dt_name (abfd), htab->needed)))) { @@ -4497,6 +4499,7 @@ error_free_dyn: --no-add-needed is used and the reference was not a weak one. */ if (undef_bfd != NULL + && h->ref_regular_nonweak && (elf_dyn_lib_class (abfd) & DYN_NO_NEEDED) != 0) { (*_bfd_error_handler) @@ -4551,7 +4554,7 @@ error_free_dyn: memcpy (sym_hash, old_hash, hashsize); htab->root.undefs = old_undefs; htab->root.undefs_tail = old_undefs_tail; - _bfd_elf_strtab_clear_refs (htab->dynstr, old_dynstr_size); + _bfd_elf_strtab_restore_size (htab->dynstr, old_dynstr_size); for (i = 0; i < htab->root.table.size; i++) { struct bfd_hash_entry *p; @@ -5664,9 +5667,9 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, /* Determine any GNU_STACK segment requirements, after the backend has had a chance to set a default segment size. */ if (info->execstack) - elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X; + elf_stack_flags (output_bfd) = PF_R | PF_W | PF_X; else if (info->noexecstack) - elf_tdata (output_bfd)->stack_flags = PF_R | PF_W; + elf_stack_flags (output_bfd) = PF_R | PF_W; else { bfd *inputobj; @@ -5693,7 +5696,7 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, exec = PF_X; } if (notesec || info->stacksize > 0) - elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | exec; + elf_stack_flags (output_bfd) = PF_R | PF_W | exec; if (notesec && exec && info->relocatable && notesec->output_section != bfd_abs_section_ptr) notesec->output_section->flags |= SEC_CODE; @@ -10780,10 +10783,10 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) /* sh_offset is set just below. */ symtab_hdr->sh_addralign = (bfd_vma) 1 << bed->s->log_file_align; - off = elf_tdata (abfd)->next_file_pos; + off = elf_next_file_pos (abfd); off = _bfd_elf_assign_file_position_for_section (symtab_hdr, off, TRUE); - /* Note that at this point elf_tdata (abfd)->next_file_pos is + /* Note that at this point elf_next_file_pos (abfd) is incorrect. We do not yet know the size of the .symtab section. We correct next_file_pos below, after we do know the size. */ @@ -11239,7 +11242,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) symstrtab_hdr->sh_addralign = 1; off = _bfd_elf_assign_file_position_for_section (symstrtab_hdr, off, TRUE); - elf_tdata (abfd)->next_file_pos = off; + elf_next_file_pos (abfd) = off; if (bfd_get_symcount (abfd) > 0) { @@ -11535,7 +11538,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) elf_final_link_free (abfd, &flinfo); - elf_tdata (abfd)->linker = TRUE; + elf_linker (abfd) = TRUE; if (attr_section) { @@ -13024,6 +13027,11 @@ _bfd_elf_make_dynamic_reloc_section (asection * sec, reloc_sec = bfd_make_section_anyway_with_flags (dynobj, name, flags); if (reloc_sec != NULL) { + /* _bfd_elf_get_sec_type_attr chooses a section type by + name. Override as it may be wrong, eg. for a user + section named "auto" we'll get ".relauto" which is + seen to be a .rela section. */ + elf_section_type (reloc_sec) = is_rela ? SHT_RELA : SHT_REL; if (! bfd_set_section_alignment (dynobj, reloc_sec, alignment)) reloc_sec = NULL; }