Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp670179iob; Wed, 18 May 2022 10:15:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuhBkkN2EOL2edUqjp18n8PDppCED51zhko5BKU7imcqLLl1oaeRIW+RwLsA4GAY41wIuD X-Received: by 2002:a17:902:cec7:b0:161:cfc9:45f6 with SMTP id d7-20020a170902cec700b00161cfc945f6mr590122plg.136.1652894110212; Wed, 18 May 2022 10:15:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652894110; cv=none; d=google.com; s=arc-20160816; b=GQ+LsmJHn7mHkSBNUN8Z6kV78+YylE0tb1q/JzidFnEKefhwl3NhzruLhuw1wf1R0S AI59ue15hdfLKQnq4El0drWytF0wF2GzZ0eHhi6++Nxp5wtSjm1m4YFJijS/BLw1LWxW mLuF4VgXO5jqFlIHNd85XOuiNpwZOePPVVduOgl74gLvbTf0Gvn+0dIZdI807LlOQHLt 7RUM4tAkE5K/LhCprr/e0BvY+Jj/kIQSITMwbL8+RBy90Lx56H9Im/1aS6Fpi5YLlAY+ nG+I7kIfLvLKz81nqHtvCPnDJaq9OllIz/CoJjmygwAtdSTYg+5E1wuAJO4mNvGqzrhq qs9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=x3Yu2Yfw0npu/c4m8Sy6+SrTpuSt8SigyBVYXq4HYd0=; b=DvLm7a8Wq/nCbl55j4bhpmPyZ/xIdwMkhHlsKFs6TgQ1FHq/YYUiJpbncxndJxr6Ir OQ8hTZsJ7I5KDBBX99RTQDu3w8hiECVtQy31QUAGPoh0Q86lF48f+Zt+U5YmWexbDTrO RtQ1KQ/SCwB0v5Q+Z0Clryp86OXt638k7EJwz1iF+artUCTi7Mmzlzw9eiGQ2qDV3QFy 5Tp/qBkKZWFV7piiY8kSTea/fhMpKAA/fF9fTkw+TmtCKcyvOLBntnMePlCQcFRet6jx UWWN0sRIuLQwWvh+JZaCCYTZ0laBPa9lQPD9N9TwOyaO3nMxrLbiWZ8o6Zq5HksHU5DL 5zJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="S/QHbpzT"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y20-20020a17090aa41400b001d28dc3d94asi3192440pjp.26.2022.05.18.10.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 10:15:10 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="S/QHbpzT"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E8FB020D258; Wed, 18 May 2022 10:15:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240737AbiERRPD (ORCPT + 99 others); Wed, 18 May 2022 13:15:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240720AbiERRPC (ORCPT ); Wed, 18 May 2022 13:15:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7AA417EC24 for ; Wed, 18 May 2022 10:14:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 735606176F for ; Wed, 18 May 2022 17:14:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F1A0C385A5; Wed, 18 May 2022 17:14:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652894098; bh=DjL0pfE9hgVf4gbXU7TI41U63++YFNAG705cDBjMhVA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=S/QHbpzTZGX2r3peroCT3HOUPOoMZhrTllorZ+Uqd06sQzWrcCnIDBK5RWaZTQiPq dPpLRMS8IsS/i4v3OkUhqvqX1HlsSdQcEDXC/ApxMDewBBR0AORrtdGHKBsjTXEERD vSWbXVMule11lVtFKgyGqwGW3YOQHD4DX0tkXcoIzPcGFqdpXBW/XGrjP9tWPtGOpk Fc7NuYCRlhCKex4/773E6+RYwF7qTA0LcRIrccqdFCljruCYD1YyFHAYIaugNwjTQe Q+7fx72jGlBq6BCR9Ev5RC+0j26ga7J/STURMmNoUFv7gkzFY29EBY+YWQdGgnCmr6 hdZkOMCk25KqQ== Date: Wed, 18 May 2022 10:14:56 -0700 From: Josh Poimboeuf To: Peter Zijlstra Cc: Nathan Chancellor , Nick Desaulniers , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com Subject: Re: objtool "no non-local symbols" error with tip of tree LLVM Message-ID: <20220518171456.tao6lmum4a2cpvs5@treble> References: <20220516214005.GQ76023@worktop.programming.kicks-ass.net> <20220518012429.4zqzarvwsraxivux@treble> <20220518161725.2bkzavre2bg4xu72@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220518161725.2bkzavre2bg4xu72@treble> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 18, 2022 at 09:17:27AM -0700, Josh Poimboeuf wrote: > On Wed, May 18, 2022 at 07:30:06AM +0200, Peter Zijlstra wrote: > > On Tue, May 17, 2022 at 06:24:29PM -0700, Josh Poimboeuf wrote: > > > On Tue, May 17, 2022 at 05:42:04PM +0200, Peter Zijlstra wrote: > > > > + for (;;) { > > > > + symtab_data = elf_getdata(s, symtab_data); > > > > + if (t) > > > > + shndx_data = elf_getdata(t, shndx_data); > > > > > > > > + if (!symtab_data) { > > > > + if (!idx) { > > > > + void *buf; > > > > > > I'm confused by whatever this is doing, how is !symtab_data possible, > > > i.e. why would symtab not have data? > > > > Elf_Data *elf_getdata(Elf_Scn *scn, Elf_Data *data); > > > > is an iterator, if @data is null it will return the first element, which > > you then feed into @data the next time to get the next element, once it > > returns NULL, you've found the end. > > > > In our specific case, we iterate the data sections, if idx fits inside > > the current section, we good, otherwise we lower idx by however many did > > fit and try the next. > > Ok, I think I see. But why are there multiple data blocks to begin > with? It's because of a previous call to elf_newdata() right? > > If so then I don't see how it would "fit" in an existing data block, > since each block should already be full. Or... is the hole the one you > just made, by moving the old symbol out? > > If so, the function seems weirdly generalized for the two distinct cases > and the loop seems unnecessary. When adding a symbol at the end, just > use elf_newdata(). When adding a symbol in the middle, the hole should > be in the first data block. Then I went for a bike ride and realized that if adding enough section symbols to a file which didn't have very many non-locals, the hole might occur in a later data block. So yeah, this looks fine :-) Another idea I had was to forego elf_newdata() entirely in favor of just rewriting the original data block every time. But this is also fine. -- Josh