Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3697716pxj; Mon, 7 Jun 2021 18:17:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2PEFL95I60W9h9OsnW94nr7L8q0U5tlp0EGzD+LLfeCQvRLMTwezyBLKQb8oUkwikqvcx X-Received: by 2002:a17:906:d297:: with SMTP id ay23mr20744902ejb.418.1623115062544; Mon, 07 Jun 2021 18:17:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623115062; cv=none; d=google.com; s=arc-20160816; b=kBtWKvJwTM8GU0FKJHyp5/azGvhFR4at8rzEyFwWa8rTyh5TzLN3uIl71/DcneRdZp YFAw3PwrnMumJw35HWgsI9L5/vVHY0z7qqjXDou/wq0WRy7zu763wwbeOu0JjPaE+5sh H7hiKrjsnmeElDvhMgPVeeeJys5y5QDimv+6lCHbAWYaC/14/fW8x4NkzYJzxSE+mHs5 GUhUsuPuw/JhfKEa8GSRuM3guId4R/zO8s+OZZnqY+6462xrj7SoQFhowxWzDa1HGCIM HTSjuxznBkv7iPGIxsOJAaOY4Qi5p9Zg+pl2dkuLhX3Ds+Ev6iYYBtwxBfuBjIXhlyXZ i4Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=qxymvfT0llYCodh+4+ROLDOo/8Z1Zus3rY+mxJkYihY=; b=NOCx/fKhy9KCMlTRKOOVYkovq3UOEm2Vl0YyJGnwZ7IHFtdEkQwPF9KVDtRuSxKjUM 2BSYy6YRl0iP66TfRHeJ8kuSWtkE15XFNNsZA6D9ObKS9kQWmNqWMdBre2BPEVNR2pS1 7toaE/o5jwHyq2rP4kDWXbOdi+3s9txHP2kB5idIxi8PI3CGJV5BTY6zDkzsqPEDoOIH nR8nGu5hTPA6eBtseS7hjPVVRKjKM8LmpDKQW8ZOPMj6OCdjQyLmfDEFJ64LKm90A794 JfK+sOrhbXS/Chzf+YYsNMRZUiv4pCObU+K42O4y5xDwtsmbGwpSEpx9LXGnfplRGJ5V kztg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g11si13425739eje.65.2021.06.07.18.17.18; Mon, 07 Jun 2021 18:17:42 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230351AbhFHBRs (ORCPT + 99 others); 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)