This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [committed, PATCH] Always create dynsym section with dynamic sections
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: Faraz Shahbazker <faraz dot shahbazker at imgtec dot com>, Binutils <binutils at sourceware dot org>
- Date: Mon, 25 Apr 2016 09:03:06 -0700
- Subject: Re: [committed, PATCH] Always create dynsym section with dynamic sections
- Authentication-results: sourceware.org; auth=none
- References: <571AD1EE dot 1040005 at imgtec dot com> <CAMe9rOrcnGADH4w=-Zv8A7iXj9SjKzb5yGVcqeaLh60-tgjRtA at mail dot gmail dot com> <571ADE8F dot 9000000 at imgtec dot com> <CAMe9rOqs5bCUX7O7k3Wp7mLmSfS5mCdDRT_g8XbhQ3LDJ1wQgg at mail dot gmail dot com> <571B93C6 dot 5030007 at imgtec dot com> <CAMe9rOrTtaCdebLXVWWFoMcSBiF34rRmjRBY9kzo7tHwuU9r2Q at mail dot gmail dot com> <571BCC3A dot 6090700 at imgtec dot com> <CAMe9rOpuLNQT-m5ym56FOeCDUJWcBB2fkB-okvu96MX7pn83nA at mail dot gmail dot com> <571D7E59 dot 4040802 at imgtec dot com> <CAMe9rOoau_6NMbaiScJJnnWY-vYNpX4KPvakS3-h0QGzp98u9Q at mail dot gmail dot com> <20160425134106 dot GI27353 at bubble dot grove dot modra dot org>
On Mon, Apr 25, 2016 at 6:41 AM, Alan Modra <amodra@gmail.com> wrote:
> On Mon, Apr 25, 2016 at 05:47:15AM -0700, H.J. Lu wrote:
>> On Sun, Apr 24, 2016 at 7:18 PM, Faraz Shahbazker
>> <faraz.shahbazker@imgtec.com> wrote:
>> > On 04/23/16 18:42, H.J. Lu wrote:
>> >> Here is a patch. Does it work for you?
>> > Yes, this works.
>> >
>>
>> Any other comments, feedbacks for my patch?
>
> I think you'd better look at all places that test dynsymcount. For
> instance, bfd_elf_size_dynsym_hash_dynstr.
I checked. They look OK.
> This should really have been done when you committed
> https://sourceware.org/ml/binutils/2016-02/msg00326.html and that
> patch should have explained why the change was made. "We should
> always create the dynsym section, even if it is empty, with dynamic
> sections" doesn't explain anything about why the change was made. In
> fact, the explanation for the patch was no better than "We should do
> what this patch does".
The issue is some dynamic tags (sections) are mandatory in .dynamic
section even if they are empty. MIPS backend use dynsymcount, which
is intended for the mandatory DT_SYMTAB (.dynsym section), to build
static executable, which doesn't have dynamic section. Here is the
updated patch. Is it OK for master?
--
H.J.
From 8d941b3f99a57f89f564ed16f94d5cdcad6fede3 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
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
- References:
- Re: [committed, PATCH] Always create dynsym section with dynamic sections
- Re: [committed, PATCH] Always create dynsym section with dynamic sections
- Re: [committed, PATCH] Always create dynsym section with dynamic sections
- Re: [committed, PATCH] Always create dynsym section with dynamic sections
- Re: [committed, PATCH] Always create dynsym section with dynamic sections
- Re: [committed, PATCH] Always create dynsym section with dynamic sections
- Re: [committed, PATCH] Always create dynsym section with dynamic sections
- Re: [committed, PATCH] Always create dynsym section with dynamic sections
- Re: [committed, PATCH] Always create dynsym section with dynamic sections
- Re: [committed, PATCH] Always create dynsym section with dynamic sections
- Re: [committed, PATCH] Always create dynsym section with dynamic sections