From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86587C433EF for ; Sat, 16 Apr 2022 18:06:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232745AbiDPSJ2 (ORCPT ); Sat, 16 Apr 2022 14:09:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232742AbiDPSJ2 (ORCPT ); Sat, 16 Apr 2022 14:09:28 -0400 Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4384448331 for ; Sat, 16 Apr 2022 11:06:54 -0700 (PDT) Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 23GHxF0L019986; Sat, 16 Apr 2022 12:59:15 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 23GHxEEp019985; Sat, 16 Apr 2022 12:59:14 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Sat, 16 Apr 2022 12:59:14 -0500 From: Segher Boessenkool To: Peter Zijlstra Cc: x86@kernel.org, Josh Poimboeuf , hjl.tools@gmail.com, ndesaulniers@google.com, mbenes@suse.cz, rostedt@goodmis.org, linux-toolchains@vger.kernel.org Subject: Re: The trouble with __weak and objtool got worse Message-ID: <20220416175914.GF25951@gate.crashing.org> References: <20220415182229.GB25951@gate.crashing.org> <20220416105905.GE2731@worktop.programming.kicks-ass.net> <20220416132005.GE25951@gate.crashing.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220416132005.GE25951@gate.crashing.org> User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-toolchains@vger.kernel.org On Sat, Apr 16, 2022 at 08:20:06AM -0500, Segher Boessenkool wrote: > On Sat, Apr 16, 2022 at 12:59:05PM +0200, Peter Zijlstra wrote: > > On Fri, Apr 15, 2022 at 01:22:29PM -0500, Segher Boessenkool wrote: > > > On Fri, Apr 15, 2022 at 01:19:04PM +0200, Peter Zijlstra wrote: > > > > The other option seems to be to have objtool add section symbols it > > > > needs, however due to ELF being a total PITA and requiring all LOCAL > > > > symbols to be before GLOBAL symbols, this would mean re-ordering the > > > > whole symbol table (I have the code somewhere :-/). > > > > > > ELF requires no such thing? Where do you see this? > > > > The first google hit: > > > > https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-79797.html > > > > which has: > > > > "In each symbol table, all symbols with STB_LOCAL binding precede the > > weak symbols and global symbols. As Sections describes, a symbol table > > section's sh_info section header member holds the symbol table index for > > the first non-local symbol." > > That is not the ELF spec, and it is incorrect afaics. Do you have any > authorative reference? It is on page 1-18 of the ELF specification version 1.1, at the bottom of the page. How unfortunate. It says: In each symbol table, all symbols with STB_LOCAL binding preced the weak and global symbols. As ``Sections'' above describes, a symbol table section's sh_info section header member holds the symbol table index for the first non-local symbol. so it is an optimisation, assuming that there are significantly fewer local than global symbols. Segher