Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp688908iob; Wed, 18 May 2022 10:38:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfXAfudzRh/w4BwD63csOQxeE+v4H8QvZqEqLwMXUtntzPFwOtO9HiCUiO8mxhJe6GXnN1 X-Received: by 2002:a63:1645:0:b0:3c5:f0c2:b9c with SMTP id 5-20020a631645000000b003c5f0c20b9cmr460286pgw.484.1652895534242; Wed, 18 May 2022 10:38:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652895534; cv=none; d=google.com; s=arc-20160816; b=tPcnQBlpOKaL8BQyOmHdaDs8NEcDSV/A77xbzbBlVsngtTAJMZ8807KKHNlWdpnVEy Uqb1q7nFhRKBuqnxvN6fa9/Y1yVLhFf87by2xBKEfx274VOY90CmW/JG12N4nwh9yfVF YF6LXQEyfII5TFgJhnEV9qirR2yZdLDBsPaV6Id+f/L+xgd9qteMRiMLq/wDTUHr61GW FwE6/ZA+eC0BuWMVSXqHQM5qoxHZEwZLzksh8s5OYtxlHVTar0NyFpxUms26/pxBKCA6 ZtpD9vufJLCq3YxeKCVSp5CTXTXIJcaF3FxefBB+LFMWZntMutTIVK2gT1xhh/A7LZBJ gbng== 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=gPoro/Lzx0t0O03C6+f+LNbsi9Gj9UgbL0r5VXsgoZQ=; b=lR1BnZaMbMlCYM0GoQ0LcctoDBFCZs85M30jBXXcbRSdGy9S3paen/UWTtJ2EIj3l4 /hII/lsmnvnx46CyR/00SGscwOoZM5fI+Kgux8vVh70eIxLoNn1Ev12DEKpq4h5Faj8D kFUqxhUe6NVKLyrMDBLsw7ItUTuevVTv8KCCOw0I+8tscYRueMjxLFejLj9eJxl/vlaZ 21a7jxMHygweCnl5fVQXLCgTT1k/c/VcHwy/fJwyJwFbOaZCG7XPMXg2Q4wlNjj2aavD hjQbpOV55qbd0cFXj/phr1lN8E36uFB2voMfQFkoPiffqbcPCf/g1wUE0nNkYgAJ9tvT f3hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gcq+AsyW; 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 m14-20020a056a00080e00b005104c426c76si4063244pfk.167.2022.05.18.10.38.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 10:38:54 -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=gcq+AsyW; 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 725125E753; Wed, 18 May 2022 10:36:28 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240950AbiERRgQ (ORCPT + 99 others); Wed, 18 May 2022 13:36:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240955AbiERRgL (ORCPT ); Wed, 18 May 2022 13:36:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A4472C138 for ; Wed, 18 May 2022 10:36:09 -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 ams.source.kernel.org (Postfix) with ESMTPS id 1B831B81EBF for ; Wed, 18 May 2022 17:36:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82D27C385A9; Wed, 18 May 2022 17:36:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652895366; bh=0dwfVWukexxHxku7pFl5/kJsgPAuwTnKAQ2sO8fT70s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gcq+AsyWRlWY6EkOaKJm5ct5ucagrpx08LO98QYPxM4b/OdgeY4MkEPKMwOhlX7Hd oRbZf2bQr1fyZ1JnZuDJx5ialOCjDdsEJkvcXvF6Zsw366nZbtRU4yMzhAAfGC6Mqu BtMNO5WAxb8F8shhwfEDgohge8+HEey2PE6OY1JZhTgnxs89hMj1khLC57Wd8dtgVH ZNrE4VUzmRngyxPUiz5lKMIsmeQqtmBZr2OHHLrFdthvwzf3zB9kTohn5Oob+LHVNW VidV5CAB/vnph4yO0RbTtnUtCtUQGOHkByP0RadqTLQ970si7uWZtPSqbbPBtDWRjd tuDtKmcVnynPQ== Date: Wed, 18 May 2022 10:36:04 -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: [PATCH] objtool: Fix symbol creation Message-ID: <20220518173604.7gcrjjum6fo2m2ub@treble> References: <20220516214005.GQ76023@worktop.programming.kicks-ass.net> <20220518012429.4zqzarvwsraxivux@treble> <20220518074152.GB10117@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220518074152.GB10117@worktop.programming.kicks-ass.net> 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:41:52AM +0200, Peter Zijlstra wrote: > +static int elf_update_symbol(struct elf *elf, struct section *symtab, > + struct section *symtab_shndx, struct symbol *sym) > { > - Elf_Data *data, *shndx_data = NULL; > - Elf32_Word first_non_local; > - struct symbol *sym; > - Elf_Scn *s; > - > - first_non_local = symtab->sh.sh_info; > - > - sym = find_symbol_by_index(elf, first_non_local); > - if (!sym) { > - WARN("no non-local symbols !?"); > - return first_non_local; > - } > + Elf_Data *symtab_data = NULL, *shndx_data = NULL; > + Elf64_Xword entsize = symtab->sh.sh_entsize; > + Elf32_Word shndx = sym->sec->idx; So if it's a global UNDEF symbol then I think 'sym->sec' can be NULL and this blows up? > + for (;;) { > + /* get next data descriptor for the relevant sections */ > + symtab_data = elf_getdata(s, symtab_data); > + if (t) > + shndx_data = elf_getdata(t, shndx_data); > + > + /* end-of-list */ > + if (!symtab_data) { > + /* if @idx == 0, it's the next contiguous entry, create it */ > + if (!idx) { > + void *buf; Could just do the "index out of range warning" here to reduce the indentation level. > + /* setup extended section index magic and write the symbol */ > + if (shndx >= SHN_UNDEF && shndx < SHN_LORESERVE) { > + sym->sym.st_shndx = shndx; > + if (!shndx_data) > + shndx = 0; I think this '0' is SHN_UNDEF? Also shouldn't 'sym->sym.st_shndx' get the same value? -- Josh