Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3358766pxj; Mon, 7 Jun 2021 08:43:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhO4J3jcEo0es3LMLZpyJkAU+XRUHe2wqup8Af5P+dKn4fxsmaA8wL9mKPt/ow194VLtZ2 X-Received: by 2002:aa7:d305:: with SMTP id p5mr14885757edq.167.1623080633999; Mon, 07 Jun 2021 08:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623080633; cv=none; d=google.com; s=arc-20160816; b=F4OBhwE/YHVCEDH9cByGY9qAqR+OTFSVvpyZdOh/XSaDnZpyYC+Tl1zOOn7Pb15b6I 1agVkAQygWNBcT1bm01bau01KBSGRlxTsGcptjPj7OSgdCxCZMv1CvUYmDxLjrBEuTOc xofl2MfZ3L8EYmQ3Kf5dFvX3orxKGGVdGoKGNTAkYb8g4UNc6n4gLiOQr4sqVF0yDvni +xmpWEEAjj3qg9TcokzwVma63RtlDiTo9Vh44n/xldvcuImElH0O+2Q/snQc7NXPw/sE UNYY5N6Hqp+LWItD/MWupsuilOTrJfb6aOHU84PToKGH1ppH3LwnHkIgFnMfI2SLYNOj rpiw== 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=F13xOnM5F0Ufs2TOCg78ImeKaTi/MppD+Ee/8+ZOVI8=; b=mJYxegrt2HnM0Y0TC4wKR8Prvuy1MK6Ct5uv/s8aFdqYkPMud+k5gmqtFnXyCH+OvE HUZmqSgahoYJrSfyC15ONKcWDkrru836jXabcU6R5YW8JwGXARMJSiCjLJIZVKf9Nl8/ jpZjzf6sXT0ut+cH7v4b6K/buSkzi1YIStJVPupP4w9uM6IBu8DhEbBhqw/cTAxZMjJ4 LPN9EiP9aEZu0ALDVacbpBmRTAuHdIM1KWRfK4n1oIdKCivym2dosW0HbYAZbqzhzwln By5vtU/ZWW7ivVMUpRnZMy+QGAoqiHJwe0q0UnEgQzpG3ou0gQZwXJdqV/uGgp49Wb7e F9Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="P529/dNw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jv22si12822839ejc.723.2021.06.07.08.43.31; Mon, 07 Jun 2021 08:43:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="P529/dNw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231490AbhFGPnU (ORCPT + 99 others); Mon, 7 Jun 2021 11:43:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231624AbhFGPnJ (ORCPT ); Mon, 7 Jun 2021 11:43:09 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17F7CC061766; Mon, 7 Jun 2021 08:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=F13xOnM5F0Ufs2TOCg78ImeKaTi/MppD+Ee/8+ZOVI8=; b=P529/dNw+gMsYw/hfuMVAoBCZp ROKU97uFOlzFU6oKNahA9xz/5nFZSMQP5EHsm5/e22V+QmLx57Y4AobtI/h3WFwElZfw/N8ITwxhl t5jabZ/6vbWvAvEb3x48iqorZj9Fhvc+D//RL/1vah+pZ8bxlZ43SJrCQKlNNsCl1LMWbaPr6MSzb ux5T/zJULURJ5LWCjiB0eZwU4fP3XSK30JwHeOCXT5DJlrB0+2lH8JdXZKRVEYgNyDFoONRWNiGFY uJvDzD7E3dSz3VF5dMKzVcP8pg34INJdmmI2uLDRGkPTWUccRVFc0MCDR+5M0FknIUxy5iFDyxoP/ AVwrnxEA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lqHMK-00FxAA-6M; Mon, 07 Jun 2021 15:40:16 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 8A91E3001E3; Mon, 7 Jun 2021 17:40:11 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 774F82D6A737A; Mon, 7 Jun 2021 17:40:11 +0200 (CEST) Date: Mon, 7 Jun 2021 17:40:11 +0200 From: Peter Zijlstra To: Ard Biesheuvel Cc: Mark-PK Tsai , Linux Kbuild mailing list , linux-toolchains@vger.kernel.org, Linux ARM , Linux Kernel Mailing List , linux-mediatek@lists.infradead.org, Matthias Brugger , Matt Helsley , "Steven Rostedt (VMware)" , Sami Tolvanen , yj.chiang@mediatek.com Subject: Re: [PATCH] recordmcount: avoid using ABS symbol as reference Message-ID: References: <20210607074258.32322-1-mark-pk.tsai@mediatek.com> <20210607080626.32612-1-mark-pk.tsai@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 07, 2021 at 01:44:21PM +0200, Peter Zijlstra wrote: > One should only use st_shndx when >SHN_UDEF and SHN_XINDEX, then use .symtab_shndx. > > Apparently you've found a case where neither is true? In that case > objtool seems to use shndx 0. A matching recordmcount patch would be > something like this. > Apparently I'm consistently bad at spelling SHM_UNDEF today.. > diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h > index f9b19524da11..d99cc0aed6fe 100644 > --- a/scripts/recordmcount.h > +++ b/scripts/recordmcount.h > @@ -194,13 +194,18 @@ static unsigned int get_symindex(Elf_Sym const *sym, Elf32_Word const *symtab, > unsigned long offset; > int index; > > - if (sym->st_shndx != SHN_XINDEX) > + if (sym->st_shndx > SHN_UDEF && > + sym->st_shndx < SHN_LORESERVE) > return w2(sym->st_shndx); > > - offset = (unsigned long)sym - (unsigned long)symtab; > - index = offset / sizeof(*sym); > + if (sym->st_shndx == SHN_XINDEX) { > + offset = (unsigned long)sym - (unsigned long)symtab; > + index = offset / sizeof(*sym); > > - return w(symtab_shndx[index]); > + return w(symtab_shndx[index]); > + } > + > + return 0; > } > > static unsigned int get_shnum(Elf_Ehdr const *ehdr, Elf_Shdr const *shdr0)