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=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham 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 E2E45C48BDF for ; Tue, 15 Jun 2021 20:38:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 99864611C0 for ; Tue, 15 Jun 2021 20:38:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 99864611C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=LLEAmVOliEStauUXJx2xsDqoUhOpEYkLH/DbRLQconQ=; b=2oK0o/rouPHvlr WQOj9BAla5ZYvuts0d/ue4gOz39B4ozEiRREPXry8ZuBAw18x4pqYeGQ5enwY0RkIadxwoRQifG69 Gs755EtWNfEN2ny3JVljDbV06cFD78GACcyLjIb/xR9XA9msnOI2a9v+7J6yjgqdjpR/xKZ6Rwvak aFWXeZERXC6Qfvq01los//K7V8srStHehaCLekTAQ/WMbf16YoxKsyVN9LqBThGrSDPh9SNAurqh6 76JgNzhz6fGRfxL2k2fF6DplSbuiewt+H1zI00YENYuff/GnXqKwUR7rou0x/14VesTY6hA/JLA3r PGi3a5xXfqxok+G7jrBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltFn9-002qNS-Ug; Tue, 15 Jun 2021 20:36:12 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltBuW-001LkC-3z; Tue, 15 Jun 2021 16:27:37 +0000 X-UUID: 38123c3acaf04d7da0331bb26d940b76-20210615 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=/g9c4wKYBovjewkHG4QG13BfUSKK2Ym4ipYWz8pxeFg=; b=BkdqhOLv+JQYwjqgKYSMWR2l5A6HpjSdMdwP7vF4Q/HOjpgBPxp4PJVkkafAfEn791x7uqOh3TIswTqVwPFTMpYwOz6fWE8Zj2hoU+sR5313iYMlZP3DI6lLlNTHjFNtRBa/qTp/2iLO92mq+XyJEGEOhV/1nhZmPtjRc4/AxHs=; X-UUID: 38123c3acaf04d7da0331bb26d940b76-20210615 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1274491061; Tue, 15 Jun 2021 09:23:18 -0700 Received: from mtkmbs05n2.mediatek.inc (172.21.101.140) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 15 Jun 2021 09:23:17 -0700 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs05n2.mediatek.inc (172.21.101.140) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 16 Jun 2021 00:23:15 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 16 Jun 2021 00:23:15 +0800 From: Mark-PK Tsai To: CC: , , , , , , , , Subject: [PATCH v3] recordmcount: Correct st_shndx handling Date: Wed, 16 Jun 2021 00:23:13 +0800 Message-ID: <20210615162313.26081-1-mark-pk.tsai@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210615_092732_331016_0E4F9D23 X-CRM114-Status: GOOD ( 11.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peter Zijlstra One should only use st_shndx when >SHN_UNDEF and = SHN_LORESERVE && st_shndx != SHN_XINDEX. Reported-by: Mark-PK Tsai Signed-off-by: Peter Zijlstra (Intel) Tested-by: Mark-PK Tsai [handle endianness of sym->st_shndx] Signed-off-by: Mark-PK Tsai --- scripts/recordmcount.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h index f9b19524da11..ef9c3425f86b 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 (w2(sym->st_shndx) > SHN_UNDEF && + w2(sym->st_shndx) < SHN_LORESERVE) return w2(sym->st_shndx); - offset = (unsigned long)sym - (unsigned long)symtab; - index = offset / sizeof(*sym); + if (w2(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) -- 2.18.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel