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: Faraz Shahbazker <faraz dot shahbazker at imgtec dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Sat, 23 Apr 2016 18:42:58 -0700
- Subject: Re: [committed, PATCH] Always create dynsym section with dynamic sections
- Authentication-results: sourceware.org; auth=none
- References: <20160223003208 dot GA30022 at intel dot com> <571A59A8 dot 4000700 at imgtec dot com> <CAMe9rOqr+E11vmpMV4Fo8Js_nCdsrcKpWKXQCUy+qSjjod=_hg at mail dot gmail dot com> <571A73BE dot 4000709 at imgtec dot com> <CAMe9rOp4nZHfL2=st5-fap84C7zOnnyjrU7e0_+QWe1jYhK6cw at mail dot gmail dot com> <DCB1C42372B1674B8F912A294CCB775A92D4E930 at BADAG02 dot ba dot imgtec dot org> <CAMe9rOpZECsq2U4Gb5CJw=y-vhmd_kDmTa0nZf+eqqTRUqDBKw at mail dot gmail dot com> <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>
On Sat, Apr 23, 2016 at 12:25 PM, Faraz Shahbazker
<faraz.shahbazker@imgtec.com> wrote:
>>>> You said dynsym should be treated treated the same for static and
>>>> dynamic executables. dynsymcount is number of dynsym + 1 in
>>>> dynamic executable. Why isn't it true for static executable?
>>>
>>> It is, or at least used to be, before this patch. It still is for both,
>>> before renumbering. But now the +1 only happens for dynamic executables
>>> when renumbering.
>>
>> Then what is wrong to always +1 for both dynamic and static
>> executables?
>
> Aah, now I see! Ever since the table was created, the count was at least 1.
> You are saying it should always remain at least 1 no matter what. Had a quick
> look through other uses of the field and it looks safe enough to me.
>
Here is a patch. Does it work for you?
--
H.J.
From f54270fc5a342ed8ead17e95731c3b0c2e7a1ecc 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.
* 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 | 2 +-
bfd/elflink.c | 8 +++-----
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 5dce70e..de721f0 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -520,7 +520,7 @@ 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 number of symbols found in the link which is intended for
the .dynsym section. */
bfd_size_type dynsymcount;
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 6f67266..17751cf 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -905,11 +905,9 @@ _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. */
+ 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
- Re: [committed, PATCH] Always create dynsym section with dynamic sections
- Re: [committed, PATCH] Always create dynsym section with dynamic sections