From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78585 invoked by alias); 23 Apr 2016 19:26:02 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 78571 invoked by uid 89); 23 Apr 2016 19:26:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=Had X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 23 Apr 2016 19:25:52 +0000 Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Websense Email with ESMTPS id 4C3BE7AFCE9D1; Sat, 23 Apr 2016 20:25:45 +0100 (IST) Received: from BAMAIL02.ba.imgtec.org (10.20.40.28) by HHMAIL01.hh.imgtec.org (10.100.10.19) with Microsoft SMTP Server (TLS) id 14.3.266.1; Sat, 23 Apr 2016 20:25:49 +0100 Received: from ubuntu-frs.ba.imgtec.org (10.20.2.68) by bamail02.ba.imgtec.org (10.20.40.28) with Microsoft SMTP Server (TLS) id 14.3.266.1; Sat, 23 Apr 2016 12:25:46 -0700 Message-ID: <571BCC3A.6090700@imgtec.com> Date: Sat, 23 Apr 2016 19:26:00 -0000 From: Faraz Shahbazker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: "H.J. Lu" CC: Binutils Subject: Re: [committed, PATCH] Always create dynsym section with dynamic sections References: <20160223003208.GA30022@intel.com> <571A59A8.4000700@imgtec.com> <571A73BE.4000709@imgtec.com> <571AD1EE.1040005@imgtec.com> <571ADE8F.9000000@imgtec.com> <571B93C6.5030007@imgtec.com> In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-SW-Source: 2016-04/txt/msg00397.txt.bz2 On 04/23/16 08:36, H.J. Lu wrote: > On Sat, Apr 23, 2016 at 8:24 AM, Faraz Shahbazker > wrote: >> On 04/23/16 05:27, H.J. Lu wrote: >>> On Fri, Apr 22, 2016 at 7:31 PM, Faraz Shahbazker >>> wrote: >>>> On 04/22/16 19:05, H.J. Lu wrote: >>>>> On Fri, Apr 22, 2016 at 6:37 PM, Faraz Shahbazker >>>>> wrote: >>>>>> On 04/22/16 16:24, H.J. Lu wrote: >>>>>>> On Fri, Apr 22, 2016 at 2:49 PM, Faraz Shahbazker >>>>>>> wrote: >>>>>>>> On 04/22/2016 12:28 PM, H.J. Lu wrote: >>>>>>>>> On Fri, Apr 22, 2016 at 11:55 AM, Faraz Shahbazker >>>>>>>>>> + if (dynsymcount != 0 || elf_hash_table (info)->dynamic_sections_created) >>>>>>>>>> + ++dynsymcount; >>>>>>>>> >>>>>>>>> Are you saying dynamic_sections_created is 0 for MIPS here >>>>>>>>> and will become 1 later? >>>>>>>> >>>>>>>> No, it will remain 0. The link is static, but the hash_table is still used to >>>>>>>> record global symbols that have GOT relocations against them. Ofc, this >>>>>>>> hash_table does not result in creation of a dynsym section, because well, >>>>>>>> dynamic_sections_created is 0. >>>>>>>> >>>>>>>> Check the list of callers to bfd_elf_link_record_dynamic_symbol(), a number of >>>>>>>> architectures use the link_hash_table in situations where it is not clear whether it is >>>>>>>> being used to track dynamic symbols for a dynamic executable, as it is for x86. >>>>>>>> >>>>>>> >>>>>>> So MIPS doesn't have dynamic symbols in this case. It just borrows >>>>>>> dynsymcount for different purpose. Is this correct? >>>>>> >>>>>> Not quite! MIPS is expecting dynsymcount to count the number of symbols >>>>>> that would have gone in to the .dynsym, even for a static executable. That way >>>>>> parts of the arch-specific code can remain agnostic to the static/dynamic nature >>>>>> of the link. It may not be used exactly as documented, but its not being used >>>>>> for what one would call a different purpose. >>>>>> >>>>>> All we need is for handling of dynsymcount when renumbering to be consistent with >>>>>> its initialization. If the initial increment for a NULL symbol was not gated by >>>>>> dynamic_sections_created, then the increment when renumbering should also not. >>>>>> If the increment when renumbering has to be gated by dynamic_sections_created, >>>>>> then the initial increment must also be so. >>>>> >>>>> From what you are saying, shouldn't dynsymcount be incremented >>>>> unconditionally? >>>> No. Always, when the table is non-empty + whatever else you need. >>>> >>> >>> 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. Regards, Faraz Shahbazker