Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp119492iob; Tue, 17 May 2022 20:52:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9l+0k1eN5KAEDcVnGdMFKyap7FA3DAkG7GljaQEMCNDHLXg0SdrFyDRtnI3UozxKrQ0jg X-Received: by 2002:a17:90b:3908:b0:1df:56a8:aa with SMTP id ob8-20020a17090b390800b001df56a800aamr13841896pjb.28.1652845933264; Tue, 17 May 2022 20:52:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652845933; cv=none; d=google.com; s=arc-20160816; b=i3MbVvaaim6H16spPN1IKddtZUGYKrXDLJa/5DK9wNyXUegMpEbgG0PPBes0HF+mAk /ihm6XvLXOs4ggOT2Af8ebPKSOdPEmSr2SHG9V3orfpbd8o0+qWHbFUtHsqOrHxNqN2a KKxKwuIkdR4oX4hSie64QUXl/aX2VovzapJKxjs1jyqsYZIbexlmD7GinksEEL/rh4C2 Q1gked1mjlS7m4lHSSJJo8ZXj+/AcLCmHot43+ojlx90iMik9uxy2zjITYjFZflK1gHN 0C+57vYypA2vzXQ20uiAZCBLdE3ozApEpKfSLSMQNhfFZDfXcSRlwlm4kLLzGUKfFbET xuew== 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=DIaqC3CYuJoRP7b4v1Khxj9y1BHqTNwvRtrDpyOc5V8=; b=MAJsGhEqYTez89EO0KzLKvPqbYh9TDmH97K62sxBJNprRMbaSa2WZqcpMsEYbTB+rN 34Mf+kE/qRRQSQUmeDNpGFfm0mIUEWUp7ebW8eJNFulaWrsqFKhsZUVhNaiCkuTuvyaW WCc1C5hSdSg9n2VhEyjiL9EvlneoJlqrlWR8bROosSpUx/zhdbpEgAKWbOWRcRIEYpJ+ lbH5RexZb3hyrPYRPTdbWjBXlP+Kt2qmESCeRrgD4aHota4VYLvCm0Ghx2+LtEa9toeF 3Sb3hEL4VrjYqctGJOvT9O3UnzrIvFqIlFLA39T7g3W8B7rPVj+i7mOGXU6irNECSps1 mbUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=i1QiMPVK; 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 e18-20020a63d952000000b003ab41b3da66si995119pgj.825.2022.05.17.20.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 20:52:13 -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=i1QiMPVK; 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 7D34A91569; Tue, 17 May 2022 20:34:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233563AbiERBYe (ORCPT + 99 others); Tue, 17 May 2022 21:24:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232630AbiERBYd (ORCPT ); Tue, 17 May 2022 21:24:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE30F54681 for ; Tue, 17 May 2022 18:24:32 -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 747AD61594 for ; Wed, 18 May 2022 01:24:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84F43C385B8; Wed, 18 May 2022 01:24:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652837071; bh=cZ2O9NOlY984cGIAsEwAguwouqwzPyw0CuWZHAKHjZg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=i1QiMPVKBFCZ8e3aj6D0tG8+xMSDHs8voek5NGNvS5iDpQFufmL2/XBeI3qikGA2H WYwHdHlKjwt3Gw+u22lUw1v3lRtmTa/UMyewtlNG8Wn7Vt2z8HKHpLDYJi15mdypDM lgchQPCnn5VJ0CJ7gILieyU/OWyKc5OgYGAtNNAmP1+g1nhyM2RrE7/Iu/k+jkBM/E 0DdXysnwAy1do6ZHkLAWvgUlCg2OzgyntMhD0Bp2oHvda37FUkZDOELljZkhTLgqu/ g3856uLAF6pa8yoR83/FpcRP3KIcxxv0qWNJj/RYoR6Lmyuym0JGb3ViqzDyn5JzxK ZGXIvcUJvJjbA== Date: Tue, 17 May 2022 18:24:29 -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: <20220518012429.4zqzarvwsraxivux@treble> References: <20220516214005.GQ76023@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.4 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 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); > > - sym->idx = symtab->sh.sh_size / sizeof(sym->sym); > - elf_dirty_reloc_sym(elf, sym); > + 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_create_section_symbol(struct elf *elf, struct section *sec) > { > struct section *symtab, *symtab_shndx; > - Elf_Data *shndx_data = NULL; > - struct symbol *sym; > - Elf32_Word shndx; > + Elf32_Word first_non_local, new; > + struct symbol *sym, *old; > + int size; > + > + if (elf->ehdr.e_ident[EI_CLASS] == ELFCLASS32) > + size = sizeof(Elf32_Sym); > + else > + size = sizeof(Elf64_Sym); This should probably be called 'entsize' and I think you can just get it from symtab->sh.sh_entsize. > + /* > + * Either way, we added a LOCAL symbol. > + */ > + symtab->sh.sh_info += 1; > + > elf_add_symbol(elf, sym); Not sure if it matters here, but elf_add_symbol() doesn't set sym->alias and sym->pv_target, and both of those are unconditionally initialized in read_symbols(). Should elf_add_symbol() be changed to initialize them? -- Josh