Always count the NULL entry in dynamic symbol table
There is an unused NULL entry at the head of dynamic symbol table which we must account for in our count even if the table is empty or unused since it is intended for the mandatory DT_SYMTAB tag (.dynsym section) in .dynamic section. * elf-bfd.h (elf_link_hash_table): Update comments for dynsymcount. * elflink.c (_bfd_elf_link_renumber_dynsyms): Always count for the unused NULL entry at the head of dynamic symbol table. (bfd_elf_size_dynsym_hash_dynstr): Remove dynsymcount != 0 checks.
This commit is contained in:
parent
3283f4fb4c
commit
d5486c4372
|
@ -1,3 +1,12 @@
|
||||||
|
2016-04-26 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
|
* elf-bfd.h (elf_link_hash_table): Update comments for
|
||||||
|
dynsymcount.
|
||||||
|
* elflink.c (_bfd_elf_link_renumber_dynsyms): Always count for
|
||||||
|
the unused NULL entry at the head of dynamic symbol table.
|
||||||
|
(bfd_elf_size_dynsym_hash_dynstr): Remove dynsymcount != 0
|
||||||
|
checks.
|
||||||
|
|
||||||
2016-04-21 H.J. Lu <hongjiu.lu@intel.com>
|
2016-04-21 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
* elflink.c (_bfd_elf_link_create_dynstrtab): Exclude linker
|
* elflink.c (_bfd_elf_link_create_dynstrtab): Exclude linker
|
||||||
|
|
|
@ -520,8 +520,8 @@ struct elf_link_hash_table
|
||||||
union gotplt_union init_got_offset;
|
union gotplt_union init_got_offset;
|
||||||
union gotplt_union init_plt_offset;
|
union gotplt_union init_plt_offset;
|
||||||
|
|
||||||
/* The number of symbols found in the link which must be put into
|
/* The number of symbols found in the link which is intended for the
|
||||||
the .dynsym section. */
|
mandatory DT_SYMTAB tag (.dynsym section) in .dynamic section. */
|
||||||
bfd_size_type dynsymcount;
|
bfd_size_type dynsymcount;
|
||||||
|
|
||||||
/* The string table of dynamic symbols, which becomes the .dynstr
|
/* The string table of dynamic symbols, which becomes the .dynstr
|
||||||
|
|
|
@ -905,11 +905,11 @@ _bfd_elf_link_renumber_dynsyms (bfd *output_bfd,
|
||||||
elf_link_renumber_hash_table_dynsyms,
|
elf_link_renumber_hash_table_dynsyms,
|
||||||
&dynsymcount);
|
&dynsymcount);
|
||||||
|
|
||||||
/* There is an unused NULL entry at the head of the table which
|
/* There is an unused NULL entry at the head of the table which we
|
||||||
we must account for in our count. We always create the dynsym
|
must account for in our count even if the table is empty since it
|
||||||
section, even if it is empty, with dynamic sections. */
|
is intended for the mandatory DT_SYMTAB tag (.dynsym section) in
|
||||||
if (elf_hash_table (info)->dynamic_sections_created)
|
.dynamic section. */
|
||||||
++dynsymcount;
|
dynsymcount++;
|
||||||
|
|
||||||
elf_hash_table (info)->dynsymcount = dynsymcount;
|
elf_hash_table (info)->dynsymcount = dynsymcount;
|
||||||
return dynsymcount;
|
return dynsymcount;
|
||||||
|
@ -6606,8 +6606,7 @@ bfd_elf_size_dynsym_hash_dynstr (bfd *output_bfd, struct bfd_link_info *info)
|
||||||
/* Work out the size of the symbol version section. */
|
/* Work out the size of the symbol version section. */
|
||||||
s = bfd_get_linker_section (dynobj, ".gnu.version");
|
s = bfd_get_linker_section (dynobj, ".gnu.version");
|
||||||
BFD_ASSERT (s != NULL);
|
BFD_ASSERT (s != NULL);
|
||||||
if (dynsymcount != 0
|
if ((s->flags & SEC_EXCLUDE) == 0)
|
||||||
&& (s->flags & SEC_EXCLUDE) == 0)
|
|
||||||
{
|
{
|
||||||
s->size = dynsymcount * sizeof (Elf_External_Versym);
|
s->size = dynsymcount * sizeof (Elf_External_Versym);
|
||||||
s->contents = (unsigned char *) bfd_zalloc (output_bfd, s->size);
|
s->contents = (unsigned char *) bfd_zalloc (output_bfd, s->size);
|
||||||
|
@ -6628,17 +6627,14 @@ bfd_elf_size_dynsym_hash_dynstr (bfd *output_bfd, struct bfd_link_info *info)
|
||||||
BFD_ASSERT (s != NULL);
|
BFD_ASSERT (s != NULL);
|
||||||
s->size = dynsymcount * bed->s->sizeof_sym;
|
s->size = dynsymcount * bed->s->sizeof_sym;
|
||||||
|
|
||||||
if (dynsymcount != 0)
|
s->contents = (unsigned char *) bfd_alloc (output_bfd, s->size);
|
||||||
{
|
if (s->contents == NULL)
|
||||||
s->contents = (unsigned char *) bfd_alloc (output_bfd, s->size);
|
return FALSE;
|
||||||
if (s->contents == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* The first entry in .dynsym is a dummy symbol.
|
/* The first entry in .dynsym is a dummy symbol. Clear all the
|
||||||
Clear all the section syms, in case we don't output them all. */
|
section syms, in case we don't output them all. */
|
||||||
++section_sym_count;
|
++section_sym_count;
|
||||||
memset (s->contents, 0, section_sym_count * bed->s->sizeof_sym);
|
memset (s->contents, 0, section_sym_count * bed->s->sizeof_sym);
|
||||||
}
|
|
||||||
|
|
||||||
elf_hash_table (info)->bucketcount = 0;
|
elf_hash_table (info)->bucketcount = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue