diff options
Diffstat (limited to 'bfd/elflink.h')
-rw-r--r-- | bfd/elflink.h | 112 |
1 files changed, 53 insertions, 59 deletions
diff --git a/bfd/elflink.h b/bfd/elflink.h index 48b86cf..04df5d6 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -20,6 +20,8 @@ /* ELF linker code. */ +#include "safe-ctype.h" + static bfd_boolean elf_link_add_object_symbols (bfd *, struct bfd_link_info *); static bfd_boolean elf_link_add_archive_symbols (bfd *, struct bfd_link_info *); @@ -1259,6 +1261,10 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) /* If st_other has a processor-specific meaning, specific code might be needed here. We never merge the visibility attribute with the one from a dynamic object. */ + if (bed->elf_backend_merge_symbol_attribute) + (*bed->elf_backend_merge_symbol_attribute) (h, isym, definition, + dynamic); + if (isym->st_other != 0 && !dynamic) { unsigned char hvis, symvis, other, nvis; @@ -1607,27 +1613,32 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) && is_elf_hash_table (info) && (info->strip != strip_all && info->strip != strip_debugger)) { - asection *stab, *stabstr; - - stab = bfd_get_section_by_name (abfd, ".stab"); - if (stab != NULL - && (stab->flags & SEC_MERGE) == 0 - && !bfd_is_abs_section (stab->output_section)) + asection *stabstr; + + stabstr = bfd_get_section_by_name (abfd, ".stabstr"); + if (stabstr != NULL) { - stabstr = bfd_get_section_by_name (abfd, ".stabstr"); - - if (stabstr != NULL) - { - struct bfd_elf_section_data *secdata; - - secdata = elf_section_data (stab); - if (! _bfd_link_section_stabs (abfd, - & hash_table->stab_info, - stab, stabstr, - &secdata->sec_info)) - goto error_return; - if (secdata->sec_info) - stab->sec_info_type = ELF_INFO_TYPE_STABS; + bfd_size_type string_offset = 0; + asection *stab; + + for (stab = abfd->sections; stab; stab = stab->next) + if (strncmp (".stab", stab->name, 5) == 0 + && (!stab->name[5] || + (stab->name[5] == '.' && ISDIGIT (stab->name[6]))) + && (stab->flags & SEC_MERGE) == 0 + && !bfd_is_abs_section (stab->output_section)) + { + struct bfd_elf_section_data *secdata; + + secdata = elf_section_data (stab); + if (! _bfd_link_section_stabs (abfd, + & hash_table->stab_info, + stab, stabstr, + &secdata->sec_info, + &string_offset)) + goto error_return; + if (secdata->sec_info) + stab->sec_info_type = ELF_INFO_TYPE_STABS; } } } @@ -1970,7 +1981,7 @@ NAME(bfd_elf,size_dynamic_sections) (bfd *output_bfd, bfd_boolean all_defined; *sinterpptr = bfd_get_section_by_name (dynobj, ".interp"); - BFD_ASSERT (*sinterpptr != NULL || info->shared); + BFD_ASSERT (*sinterpptr != NULL || !info->executable); if (soname != NULL) { @@ -2047,15 +2058,15 @@ NAME(bfd_elf,size_dynamic_sections) (bfd *output_bfd, /* Make all global versions with definiton. */ for (t = verdefs; t != NULL; t = t->next) - for (d = t->globals; d != NULL; d = d->next) - if (!d->symver && strchr (d->pattern, '*') == NULL) + for (d = t->globals.list; d != NULL; d = d->next) + if (!d->symver && d->symbol) { const char *verstr, *name; size_t namelen, verlen, newlen; char *newname, *p; struct elf_link_hash_entry *newh; - name = d->pattern; + name = d->symbol; namelen = strlen (name); verstr = t->name; verlen = strlen (verstr); @@ -2113,9 +2124,8 @@ NAME(bfd_elf,size_dynamic_sections) (bfd *output_bfd, /* Check if all global versions have a definiton. */ all_defined = TRUE; for (t = verdefs; t != NULL; t = t->next) - for (d = t->globals; d != NULL; d = d->next) - if (!d->symver && !d->script - && strchr (d->pattern, '*') == NULL) + for (d = t->globals.list; d != NULL; d = d->next) + if (!d->symver && !d->script) { (*_bfd_error_handler) (_("%s: undefined version: %s"), @@ -2362,7 +2372,7 @@ NAME(bfd_elf,size_dynamic_sections) (bfd *output_bfd, def.vd_version = VER_DEF_CURRENT; def.vd_flags = 0; - if (t->globals == NULL && t->locals == NULL && ! t->used) + if (t->globals.list == NULL && t->locals.list == NULL && ! t->used) def.vd_flags |= VER_FLG_WEAK; def.vd_ndx = t->vernum + 1; def.vd_cnt = cdeps + 1; @@ -2794,8 +2804,6 @@ struct elf_final_link_info asection *hash_sec; /* symbol version section (.gnu.version). */ asection *symver_sec; - /* first SHF_TLS section (if any). */ - asection *first_tls_sec; /* Buffer large enough to hold contents of any section. */ bfd_byte *contents; /* Buffer large enough to hold external relocs of any section. */ @@ -3150,14 +3158,6 @@ elf_bfd_final_link (bfd *abfd, struct bfd_link_info *info) finfo.symshndxbuf = NULL; finfo.symbuf_count = 0; finfo.shndxbuf_size = 0; - finfo.first_tls_sec = NULL; - for (o = abfd->sections; o != NULL; o = o->next) - if ((o->flags & SEC_THREAD_LOCAL) != 0 - && (o->flags & SEC_LOAD) != 0) - { - finfo.first_tls_sec = o; - break; - } /* Count up the number of relocations we will output for each output section, so that we know the sizes of the reloc sections. We @@ -3515,38 +3515,30 @@ elf_bfd_final_link (bfd *abfd, struct bfd_link_info *info) goto error_return; } - if (finfo.first_tls_sec) + if (elf_hash_table (info)->tls_sec) { - unsigned int align = 0; - bfd_vma base = finfo.first_tls_sec->vma, end = 0; + bfd_vma base, end = 0; asection *sec; - for (sec = finfo.first_tls_sec; + for (sec = elf_hash_table (info)->tls_sec; sec && (sec->flags & SEC_THREAD_LOCAL); sec = sec->next) { bfd_vma size = sec->_raw_size; - if (bfd_get_section_alignment (abfd, sec) > align) - align = bfd_get_section_alignment (abfd, sec); - if (sec->_raw_size == 0 && (sec->flags & SEC_HAS_CONTENTS) == 0) + if (size == 0 && (sec->flags & SEC_HAS_CONTENTS) == 0) { struct bfd_link_order *o; - size = 0; for (o = sec->link_order_head; o != NULL; o = o->next) if (size < o->offset + o->size) size = o->offset + o->size; } end = sec->vma + size; } - elf_hash_table (info)->tls_segment - = bfd_zalloc (abfd, sizeof (struct elf_link_tls_segment)); - if (elf_hash_table (info)->tls_segment == NULL) - goto error_return; - elf_hash_table (info)->tls_segment->start = base; - elf_hash_table (info)->tls_segment->size = end - base; - elf_hash_table (info)->tls_segment->align = align; + base = elf_hash_table (info)->tls_sec->vma; + end = align_power (end, elf_hash_table (info)->tls_sec->alignment_power); + elf_hash_table (info)->tls_size = end - base; } /* Since ELF permits relocations to be against local symbols, we @@ -4493,8 +4485,8 @@ elf_link_output_extsym (struct elf_link_hash_entry *h, void *data) { /* STT_TLS symbols are relative to PT_TLS segment base. */ - BFD_ASSERT (finfo->first_tls_sec != NULL); - sym.st_value -= finfo->first_tls_sec->vma; + BFD_ASSERT (elf_hash_table (finfo->info)->tls_sec != NULL); + sym.st_value -= elf_hash_table (finfo->info)->tls_sec->vma; } } } @@ -4852,8 +4844,8 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd) if (ELF_ST_TYPE (osym.st_info) == STT_TLS) { /* STT_TLS symbols are relative to PT_TLS segment base. */ - BFD_ASSERT (finfo->first_tls_sec != NULL); - osym.st_value -= finfo->first_tls_sec->vma; + BFD_ASSERT (elf_hash_table (finfo->info)->tls_sec != NULL); + osym.st_value -= elf_hash_table (finfo->info)->tls_sec->vma; } } @@ -5209,8 +5201,10 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd) { /* STT_TLS symbols are relative to PT_TLS segment base. */ - BFD_ASSERT (finfo->first_tls_sec != NULL); - sym.st_value -= finfo->first_tls_sec->vma; + BFD_ASSERT (elf_hash_table (finfo->info) + ->tls_sec != NULL); + sym.st_value -= (elf_hash_table (finfo->info) + ->tls_sec->vma); } } |