From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from albireo.enyo.de (albireo.enyo.de [37.24.231.21]) by server2.sourceware.org (Postfix) with ESMTPS id 761D13861C30 for ; Mon, 9 Mar 2020 08:14:55 +0000 (GMT) Received: from [172.17.203.2] (helo=deneb.enyo.de) by albireo.enyo.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) id 1jBDYr-0003g7-BC; Mon, 09 Mar 2020 08:14:53 +0000 Received: from fw by deneb.enyo.de with local (Exim 4.92) (envelope-from ) id 1jBDXI-0000zs-FZ; Mon, 09 Mar 2020 09:13:16 +0100 From: Florian Weimer To: "H.J. Lu" Cc: binutils@sourceware.org, Kaylee Blake Subject: Re: RFC: [PATCH] ELF: Don't require section header on ELF objects References: <20200308175947.GA911529@gmail.com> Date: Mon, 09 Mar 2020 09:13:16 +0100 In-Reply-To: <20200308175947.GA911529@gmail.com> (H. J. Lu's message of "Sun, 8 Mar 2020 10:59:47 -0700") Message-ID: <87y2sac5er.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, GIT_PATCH_1, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Mar 2020 08:14:57 -0000 * H. J. Lu: > Section header isn't mandatory on ELF executable nor shared library. > This patch adds a new linker option, -z nosectionheader, to omit ELF > section header when building an executable or shared library, adds > an objcopy and strip option, --remove-section-header, to remove ELF > section header from an executable or shared library. > > The PT_DYNAMIC segment contains DT_HASH/DT_GNU_HASH/DT_MIPS_XHASH, > DT_STRTAB, DT_SYMTAB, DT_STRSZ and DT_SYMENT, which can be used to > reconstruct dynamic symbol table when section header isn't available. > For DT_HASH, the number of dynamic symbol table entries equals the > number of chains. For DT_GNU_HASH/DT_MIPS_XHASH, only defined symbols > with non-STB_LOCAL indings are in hash table. Since in dynamic symbol > table, all symbols with STB_LOCAL binding are placed before symbols with > other bindings and all defined symbols are placed before undefined ones, > the highest symbol index in DT_GNU_HASH/DT_MIPS_XHASH is the highest > dynamic symbol table index. Does this patch enable ld to use shared objects without a section header for linking? I think the NEWS and manual update should clarify this. In my opinion, it should NOT be possible to link against objects without section headers. Lack of section headers clearly marks the object as a run-time only object. This is useful if you want to prevent developers to create DT_NEEDED dependencies on internal libraries, for example.