Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp483814ybh; Wed, 18 Mar 2020 03:40:53 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsGIaPdoKgwKFqYYabOcD5fi1xR077avw30jFeg+OuOrhSHTT2ITV0zLLDe2h6Qh7PhbZxd X-Received: by 2002:a54:4e13:: with SMTP id a19mr2663555oiy.108.1584528053167; Wed, 18 Mar 2020 03:40:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584528053; cv=none; d=google.com; s=arc-20160816; b=CCxtWV83tE27mps5W0vNSz/z2A3m1pFoPZSlIjnz21lIeYb2gHLeDR8/cC9JCYd3do BzVke2dHcUqyvmbA3DDDsl9kSUshnki+YHNLuxu2gvK0orMSYqSKuQcbKsxrWnhRO43D MJV0DDUpv127TKrU2pnjgI6wBLtQFVAztShai6Sx/jg5zWprrSqxTF8l7z1sehIgko+9 DWr8q60m4o2xzoSaJvOD7Ymeb575lbBNChwbkvIdTYYNcB4h5h3OAt+O7G1CLYZn4ONy f0wtSRhL/k7qZKKCbEofUr0zWrHXe4WRJMRjBcIyENlzNIMJxdO6HzIKDnHNpI8EQGw3 Hcgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=sUuWobnvKkTEgJz2GmRhAsCFuiR9B/stBFlgvkoyeZM=; b=R3ON7/tNBcWWOC3CZhKUS0pV5zQVMVDyc2DA0IVD6+Sxo8f/rBYJpjDFKGCzlm7paM ek21eAa4GNZOdP+KORcFYFLTHQMEF+yiW+q80JDvAo/x94NlDJkO4l203F9H0bBsv4od BB48a5OKt827q1gqhyWHo2Hw1tnxWQY3hnHGiDOZEUS1c62ZC06ugdZCjhO6ZDwda4/n 2yX4nLfAE87u8hY/Kb3FwYQ5Tj8Qwgr7U1jtczpZS990JQ183BG68W3XqmCGZLS/CYZT GH3YlKZjPsK2dPKC+Y6RTtgi4dXF8BNlnH24uGxKn2jYVSps9wIYZLOQoW0Mm2hSkTuT DJig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1si3133012oic.245.2020.03.18.03.40.41; Wed, 18 Mar 2020 03:40:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727415AbgCRKj1 (ORCPT + 99 others); Wed, 18 Mar 2020 06:39:27 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:59251 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726486AbgCRKj1 (ORCPT ); Wed, 18 Mar 2020 06:39:27 -0400 X-IronPort-AV: E=Sophos;i="5.70,566,1574092800"; d="scan'208";a="86539283" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 Mar 2020 18:39:22 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id 4F58D49DF126; Wed, 18 Mar 2020 18:29:17 +0800 (CST) Received: from G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.85) by G08CNEXMBPEKD06.g08.fujitsu.local (10.167.33.206) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 18 Mar 2020 18:39:22 +0800 Received: from Fedora-30.g08.fujitsu.local (10.167.220.106) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.439.0; Wed, 18 Mar 2020 18:39:22 +0800 From: Xiao Yang To: CC: , , , Xiao Yang Subject: [PATCH v2] modpost: Get proper section index by get_secindex() instead of st_shndx Date: Wed, 18 Mar 2020 18:34:16 +0800 Message-ID: <20200318103416.29067-1-yangx.jy@cn.fujitsu.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-yoursite-MailScanner-ID: 4F58D49DF126.AB52A X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: yangx.jy@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (uint16_t) st_shndx is limited to 65535(i.e. SHN_XINDEX) so sym_get_data() gets wrong section index by st_shndx if requested symbol contains extended section index that is more than 65535. In this case, we need to get proper section index by .symtab_shndx section. Module.symvers generated by building kernel with "-ffunction-sections -fdata-sections" shows the issue. Fixes: 56067812d5b0 ("kbuild: modversions: add infrastructure for emitting relative CRCs") Fixes: e84f9fbbece1 ("modpost: refactor namespace_from_kstrtabns() to not hard-code section name") Reviewed-by: Masahiro Yamada Signed-off-by: Xiao Yang --- scripts/mod/modpost.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 7edfdb2f4497..1ce22896f3d8 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -308,7 +308,8 @@ static const char *sec_name(struct elf_info *elf, int secindex) static void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym) { - Elf_Shdr *sechdr = &info->sechdrs[sym->st_shndx]; + unsigned int secindex = get_secindex(info, sym); + Elf_Shdr *sechdr = &info->sechdrs[secindex]; unsigned long offset; offset = sym->st_value; -- 2.21.0