From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24EE9C47094 for ; Tue, 8 Jun 2021 01:15:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 010FF61263 for ; Tue, 8 Jun 2021 01:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230440AbhFHBRs (ORCPT ); Mon, 7 Jun 2021 21:17:48 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:34301 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230209AbhFHBRr (ORCPT ); Mon, 7 Jun 2021 21:17:47 -0400 X-UUID: 4623f96bb4ca4325b53853285eb3af65-20210608 X-UUID: 4623f96bb4ca4325b53853285eb3af65-20210608 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1768396892; Tue, 08 Jun 2021 09:15:50 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Jun 2021 09:15:48 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Jun 2021 09:15:48 +0800 From: Mark-PK Tsai To: CC: , , , , , , , , , , , Subject: Re: [PATCH] recordmcount: avoid using ABS symbol as reference Date: Tue, 8 Jun 2021 09:15:48 +0800 Message-ID: <20210608011548.5008-1-mark-pk.tsai@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-MTK: N 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.. I test the below patch and it work for me. I only correct the UNDEF typo without any other modification. Could I push this patch or you will push it? I guess I have to add your signed-off-by. > > > 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)