Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1943528rwd; Sun, 21 May 2023 09:18:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7WTiXwHN9M3PA+XDwy9XAcRl8mMUmeZqKXJgU2zMV2ISKOFN6wWpgJSp9PFPYf7n8L7upr X-Received: by 2002:a05:6a20:9185:b0:101:41f8:7a17 with SMTP id v5-20020a056a20918500b0010141f87a17mr9598650pzd.20.1684685925446; Sun, 21 May 2023 09:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684685925; cv=none; d=google.com; s=arc-20160816; b=kNour3iWP1psjXhCzP7hTF3d8M49g+eGgMqRa+6+YqhUOROH9sTGqmnoh9DOQZ+xl7 iV87M5MRpuNsiEsE3ZyvLSKKuk+Kdlf6kC6630xIWYSc0/FWB/c2MtG4MbM5zoehjoDY Pggxs1KesMfFlS0//5duuQBY9dubL92rfFuQIyweL/XM5a3tgs3lDoYgrf5si7DUtXh0 CFnN6jA9eo/dxYE5ZJT2i3r8VH/xV2auzOyliwpjsb0EmgRWf/yfU12w/o1vnfJUdmEh Xxb63vG6USBuBqDeuBTT/kUHeZu18/n0t1OT6HCluoEQoVPn4XBEDXE9dAByntuStXFl Nv8Q== 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:date:subject:cc:to:from :dkim-signature; bh=czK0gSz3I6tE6esquJpyb86lQQ7nJcfVlU9y8dpbJ4s=; b=oNvmp+aw/XT2rGaBGn/k+8Aq4r7aHBcx/IMwO2RMMw1LdHQOK5InC6NTvc9WBUZ5M5 yG45MS2iAg3jpYD2xpXmTcj5MyB1UXpwJiN/CfTGo+NGAlRW40SK5Zh+RmeBIKsdcQAc 254JaIJGWCmUYQP6vwkdYSGNpAQigyZ9rEFmHxrGhmv4vsFrwPhHKV9gcQUwa0SgMpVN Aigm4aP7+R1rvOZYW8HlcFFDr5yVNKwsih/jGj3Iyqn98GXm52YamQXDdaouGChk2cJ0 X+Wmc4ISQIPMtPZUlEnm/QRrOQgTR/QftmFAM5+N2ryqWtV0K5cOp9SIE1aISbHU1PXK jhjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dv23FCUu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g10-20020a636b0a000000b005348954e079si3418676pgc.95.2023.05.21.09.18.31; Sun, 21 May 2023 09:18:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dv23FCUu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230311AbjEUQFo (ORCPT + 99 others); Sun, 21 May 2023 12:05:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230317AbjEUQFf (ORCPT ); Sun, 21 May 2023 12:05:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1459118; Sun, 21 May 2023 09:05:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6AE3D60F9D; Sun, 21 May 2023 16:05:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63CCCC433A0; Sun, 21 May 2023 16:05:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684685128; bh=zRzYFZ5lz7mHPL94B6DS35Xto1/srS4BQ/bsgLZFHtc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dv23FCUuRpa+ZEAYxnbcBXiZtmulasqyIrSh8r9/2+5am8ohuf6zVRSwxHaxNCfYb LBB8YG3NeWJnXaHLCc6TejAnMgRV1sUtv8so12TbAgLtIzst4SBrW0CZISIl2lDmXY ZnFYRh1fkJHDOAVuFdk7Y88Fn2nCLjqCQuSjY5bBdx+SSe/JfjLO+DVYdSQzs1mc/l XXUyTIYKapKFM0kWcmeMyiOhxRjtaPKKJSLCTTKAuYPukwEndFB917bfiU27rbX+Fz zi6LuZbk/dq2n8zX/40hartEu++K5PNXlWATifFDKSOjC0pRTT+Afi0HlbEaa8FXxt MUuCLR3zeilDg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Masahiro Yamada Subject: [PATCH v6 08/20] modpost: remove is_shndx_special() check from section_rel(a) Date: Mon, 22 May 2023 01:04:13 +0900 Message-Id: <20230521160426.1881124-9-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230521160426.1881124-1-masahiroy@kernel.org> References: <20230521160426.1881124-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This check is unneeded. Without it, sec_name() will returns the null string "", then section_mismatch() will return immediately. Anyway, special section indices rarely appear in these loops. Signed-off-by: Masahiro Yamada --- Changes in v6: - Remove is_shndx_special() definition scripts/mod/modpost.c | 16 ++++------------ scripts/mod/modpost.h | 5 ----- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index f364738a236e..40fac4f64fcd 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1361,7 +1361,6 @@ static int addend_mips_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) static void section_rela(const char *modname, struct elf_info *elf, Elf_Shdr *sechdr) { - Elf_Sym *sym; Elf_Rela *rela; Elf_Rela r; unsigned int r_sym; @@ -1404,11 +1403,8 @@ static void section_rela(const char *modname, struct elf_info *elf, continue; break; } - sym = elf->symtab_start + r_sym; - /* Skip special sections */ - if (is_shndx_special(sym->st_shndx)) - continue; - check_section_mismatch(modname, elf, sym, + + check_section_mismatch(modname, elf, elf->symtab_start + r_sym, fsecndx, fromsec, r.r_offset, r.r_addend); } } @@ -1416,7 +1412,6 @@ static void section_rela(const char *modname, struct elf_info *elf, static void section_rel(const char *modname, struct elf_info *elf, Elf_Shdr *sechdr) { - Elf_Sym *sym; Elf_Rel *rel; Elf_Rela r; unsigned int r_sym; @@ -1463,11 +1458,8 @@ static void section_rel(const char *modname, struct elf_info *elf, default: fatal("Please add code to calculate addend for this architecture\n"); } - sym = elf->symtab_start + r_sym; - /* Skip special sections */ - if (is_shndx_special(sym->st_shndx)) - continue; - check_section_mismatch(modname, elf, sym, + + check_section_mismatch(modname, elf, elf->symtab_start + r_sym, fsecndx, fromsec, r.r_offset, r.r_addend); } } diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 1178f40a73f3..b1e2d95f8047 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -151,11 +151,6 @@ struct elf_info { Elf32_Word *symtab_shndx_stop; }; -static inline int is_shndx_special(unsigned int i) -{ - return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE; -} - /* Accessor for sym->st_shndx, hides ugliness of "64k sections" */ static inline unsigned int get_secindex(const struct elf_info *info, const Elf_Sym *sym) -- 2.39.2