Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3272468pxj; Mon, 7 Jun 2021 06:46:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsGHy+fXHioloNkV2XK3hNDIWxzfssfQMNVmKmJnnweJDSaaT6jwE/FcSyyyXHsGavaQTM X-Received: by 2002:a17:906:e253:: with SMTP id gq19mr18404827ejb.138.1623073588359; Mon, 07 Jun 2021 06:46:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623073588; cv=none; d=google.com; s=arc-20160816; b=A8vLWFw6yx3OB740Tf6NHKHkZsJIJvXCkygomi3s3nLEiQKmljGgDdo2N555Rr8/3q WsupiFnmisqTBbYKPrvLk9jAtkFGuBIj4bZuJOMDpF/CvoO+lALPkIiYeOUf0pSEd2b/ R0NWPE3Gh0CXhkngJ6+aO2gG7nlnmXC0GDg1sULAceud5+A+H2z05vf1S51P96XIjLHe cWGs87W4pIBRIdAYOE0cFTnoh9v8mQrphro+7fDJZfYwFJqvHwQas40HX0rIppVykPM3 2bVuQv+9gfWAGoCN0u1PMGoJWIiRRR5BLpr5/eN6bMU9BOiJZDc8MLsZJJKxOqz8xAfR lCKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=yB+AygJzmlgwNw/hDF0wx5CrsUpuxa/2On1y4lYk878=; b=B6D7hk7FdCUu12X+4KsmAv//XO88pqcUgZOiUjJE0UScvgBL8j40O25EoQ7T4u330D 1j2GoR0RatZZJx5p/HllEkYUeG3YFrx6jv6yOMj1UgGm0U1V7FadS0Xo0dsyIm3z3TPQ LJgr3FGqmydGbSXxftXxaYvk02cspl8KczE/lJnJkultP47lLyDC2vHRv0uojPEDaP7A l52rgK1Ry6rsM9wFEGrMc+EEunL/EFXQDRSg6OXAM7fOQCJtppywlBd+6zjdXfG/yFQu JS0Yl7E5Msms1avKcART4ZgMiu8nEgd3txWMIA619CRvl6AmEpvpW6+kVpRr2AsoRg90 meTg== ARC-Authentication-Results: i=1; mx.google.com; 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 g4si12412381ejj.325.2021.06.07.06.46.05; Mon, 07 Jun 2021 06:46:28 -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; 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 S230341AbhFGNq2 (ORCPT + 99 others); Mon, 7 Jun 2021 09:46:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:57316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230217AbhFGNq1 (ORCPT ); Mon, 7 Jun 2021 09:46:27 -0400 Received: from oasis.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E2EBF61001; Mon, 7 Jun 2021 13:44:34 +0000 (UTC) Date: Mon, 7 Jun 2021 09:44:33 -0400 From: Steven Rostedt To: Peter Zijlstra Cc: Ard Biesheuvel , 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 , Sami Tolvanen , yj.chiang@mediatek.com Subject: Re: [PATCH] recordmcount: avoid using ABS symbol as reference Message-ID: <20210607094433.473100d9@oasis.local.home> In-Reply-To: References: <20210607074258.32322-1-mark-pk.tsai@mediatek.com> <20210607080626.32612-1-mark-pk.tsai@mediatek.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 7 Jun 2021 13:44:21 +0200 Peter Zijlstra wrote: > There's an extended section header index section for just that. And > recordmcount actually seems to use that as well. > > I can't seem to find enough of the thread to figure out what the actual > problem is though. The lore archive doesn't have anything prior to this > message. > > 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. Mark-PK, Does the below patch fix it for you too (if you backport it to your kernel). I much rather have recordmcount match objtool, as one day the two will hopefully merge to one executable. -- Steve > > > 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)