Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp924823rwd; Sun, 14 May 2023 08:59:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ70+QgbxN2Pi3xz6ebS9QrRImnYf/gmgUw8Oah3yPLjdRN7wcbrUkFQDCbw7/aG3aj9Q+Jj X-Received: by 2002:a05:6a20:4321:b0:105:b75e:9df6 with SMTP id h33-20020a056a20432100b00105b75e9df6mr2422884pzk.26.1684079983314; Sun, 14 May 2023 08:59:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684079983; cv=none; d=google.com; s=arc-20160816; b=TBQ4gDUz/0SHnn3L94p7ZpvymfnfNb82WmloIWyWZ4z5TRhgrnMBnJOW/NEcRIJ+7r rwxIX91cvVYe3cfHjrcnQqhNM+UKHtd+0zOu4mJA0kTYddHZeTo/swGa+1+fUio9pGP6 YfJmpJ+ZY6xf24OaMWXj28BTXlmI2y/j4uHPiDN3Wg8eNGNe0duwiMunYe20TU9KOm0b V+N8+dpRDbxSMajMy4wNviT6h8mtsyEq3ezJyKx3cbONwIxONRWL1YJO7K/k6+CHpPk9 U05OYn3dcT4BoNhgh1HkVohmXHSSytfTrrILHYfInC07s2pr84v7noxYzTNz8uPStQBr Kq5Q== 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=nDZiaSD8KYoqqE5i1pM9Jn/YogMLY/cdtsxwF6A7GZE=; b=bIZ5QB10HVcymi26lJsu/ZXj1NHVrlptD6jwEtoxzf7yB3ouxz3RjvEF7BLfx/n6W3 p54BNZpyTTMvWqk4EUJemF7yrNXEIxhdhy6b20CN0h7bN2DhOvPHKbW6ENxfmY59S7XV lgC2dFLqMcouUXKpnOR+EAa3XW+2w3qBg9rv7IpW/1SvipbZ9DDHEHszhsYA9PnEOXVm 3WPOyQ7aKzxnRH2HyND0UOy6BoYN7HJJUIj/DZlnr423GgskudBHiPieHfB3jM88xqmw oRc2OpV2gWVD3m/jyMOiKqlzMSWhKOzWPTLDHiDTiNonwTerYOjfrhCl4ThUKAboBEhS GRdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IfeAeRGH; 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 x21-20020aa78f15000000b00622ae306420si14844433pfr.279.2023.05.14.08.59.29; Sun, 14 May 2023 08:59:43 -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=IfeAeRGH; 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 S237765AbjENP2J (ORCPT + 99 others); Sun, 14 May 2023 11:28:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237537AbjENP17 (ORCPT ); Sun, 14 May 2023 11:27:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D78030D7; Sun, 14 May 2023 08:27:58 -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 1854860B77; Sun, 14 May 2023 15:27:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C20FCC433EF; Sun, 14 May 2023 15:27:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684078077; bh=ldB1zuIjVJbUZHmq+luLZNk89A0RkfSMZ4+S70RhR7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IfeAeRGHdsW3UCXNbCbvVIZHS6YsfCK+NkrCEtpHksYfIzniK4JxyxdqHJUZhtSS8 3iGO0Bxg9e6hlcmXR8mwNAAXV5lB3v+6ukcqcqrDMryzRn9JjJ3szjQFocfG00CFiY b30mGkKp69ZHEmeE6TnLSEJJXLm1ZtIvrR1JyzCMplFeoHZ9fQjX7ycf05gDZwmKRa GfeSZDLa9m5sojC5aCRI81oct+dHouvhhz+3AkIEAw0p2WP3YvgGdVugGIbAEdKv6x +wBgPbordX2+n1QLfvbRJX68Bp8/6irbdSvV4ZgHbRBSBpHh4eCYiIYjAbo3XRl+th rR9S6mBiIUWxA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Pitre , Nicolas Schier , Masahiro Yamada Subject: [PATCH v5 05/21] modpost: squash report_sec_mismatch() into default_mismatch_handler() Date: Mon, 15 May 2023 00:27:23 +0900 Message-Id: <20230514152739.962109-6-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230514152739.962109-1-masahiroy@kernel.org> References: <20230514152739.962109-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 report_sec_mismatch() and default_mismatch_handler() are small enough to be merged together. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 55 ++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 35 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 7a9a3ef8ca0d..bb7d1d87bae7 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1207,17 +1207,27 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, return near; } -/* - * Print a warning about a section mismatch. - * Try to find symbols near it so user can find it. - * Check whitelist before warning - it may be a false positive. - */ -static void report_sec_mismatch(const char *modname, - const struct sectioncheck *mismatch, - const char *fromsec, - const char *fromsym, - const char *tosec, const char *tosym) +static void default_mismatch_handler(const char *modname, struct elf_info *elf, + const struct sectioncheck* const mismatch, + Elf_Rela *r, Elf_Sym *sym, const char *fromsec) { + const char *tosec; + Elf_Sym *to; + Elf_Sym *from; + const char *tosym; + const char *fromsym; + + from = find_elf_symbol2(elf, r->r_offset, fromsec); + fromsym = sym_name(elf, from); + + tosec = sec_name(elf, get_secindex(elf, sym)); + to = find_elf_symbol(elf, r->r_addend, sym); + tosym = sym_name(elf, to); + + /* check whitelist - we may ignore it */ + if (!secref_whitelist(mismatch, fromsec, fromsym, tosec, tosym)) + return; + sec_mismatch_count++; switch (mismatch->mismatch) { @@ -1242,31 +1252,6 @@ static void report_sec_mismatch(const char *modname, } } -static void default_mismatch_handler(const char *modname, struct elf_info *elf, - const struct sectioncheck* const mismatch, - Elf_Rela *r, Elf_Sym *sym, const char *fromsec) -{ - const char *tosec; - Elf_Sym *to; - Elf_Sym *from; - const char *tosym; - const char *fromsym; - - from = find_elf_symbol2(elf, r->r_offset, fromsec); - fromsym = sym_name(elf, from); - - tosec = sec_name(elf, get_secindex(elf, sym)); - to = find_elf_symbol(elf, r->r_addend, sym); - tosym = sym_name(elf, to); - - /* check whitelist - we may ignore it */ - if (secref_whitelist(mismatch, - fromsec, fromsym, tosec, tosym)) { - report_sec_mismatch(modname, mismatch, - fromsec, fromsym, tosec, tosym); - } -} - static int is_executable_section(struct elf_info* elf, unsigned int section_index) { if (section_index > elf->num_sections) -- 2.39.2