From 8d941b3f99a57f89f564ed16f94d5cdcad6fede3 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sat, 23 Apr 2016 18:37:59 -0700 Subject: [PATCH] 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-bfd.h | 4 ++-- bfd/elflink.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 5dce70e..7447629 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -520,8 +520,8 @@ struct elf_link_hash_table union gotplt_union init_got_offset; union gotplt_union init_plt_offset; - /* The number of symbols found in the link which must be put into - the .dynsym section. */ + /* The number of symbols found in the link which is intended for the + mandatory DT_SYMTAB tag (.dynsym section) in .dynamic section. */ bfd_size_type dynsymcount; /* The string table of dynamic symbols, which becomes the .dynstr diff --git a/bfd/elflink.c b/bfd/elflink.c index 6f67266..7babfb9 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -905,11 +905,11 @@ _bfd_elf_link_renumber_dynsyms (bfd *output_bfd, elf_link_renumber_hash_table_dynsyms, &dynsymcount); - /* There is an unused NULL entry at the head of the table which - we must account for in our count. We always create the dynsym - section, even if it is empty, with dynamic sections. */ - if (elf_hash_table (info)->dynamic_sections_created) - ++dynsymcount; + /* There is an unused NULL entry at the head of the table which we + must account for in our count even if the table is empty since it + is intended for the mandatory DT_SYMTAB tag (.dynsym section) in + .dynamic section. */ + dynsymcount++; elf_hash_table (info)->dynsymcount = dynsymcount; return dynsymcount; -- 2.5.5