Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp122086rwb; Tue, 27 Sep 2022 23:45:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4unEJp9HX+5COjAALkpgPQfZIzI/loteQmg5T1R4O9DL3qYku3nzlkdSuBElFNwHHYl6uI X-Received: by 2002:a17:907:3e85:b0:73d:60cc:5d06 with SMTP id hs5-20020a1709073e8500b0073d60cc5d06mr26907356ejc.722.1664347554537; Tue, 27 Sep 2022 23:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664347554; cv=none; d=google.com; s=arc-20160816; b=RLw2EJSegLAqOeyVjVVMyiEWG2nSqYZF63SyUcV8AU1BgWvSsLG0doPKcQRXxcnVQf TSTG2l0MEJ3cX546/9S86lZYQfD6kOTzRRbaOagQgBIlG+Q7fzJQc7Wzsit3xoqNFllp KEJJ/ePowjb4pu1eyl6ZxoTsGo96h0UlnRCFAFubki8ygXfgO91Wvkwq2XvEBNT5NEKw AqzewDVJvHdnRttsAFJOrhjSsJ2RL7wACT31VrHAluPy8OovKi5FCUUsEUmMKUidJP2j LStLUyydQAbVA8OmhsfgnQQtHCgB05YurqpO/UcAx+8MdDS1p+bC89ugb6FbnxgZHzVP mXFw== 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:dkim-filter; bh=5aYc69QpW6nhNbvRlVUs8p1oo1ZG3mtyqAcjgjlEHS4=; b=Y7kqSdEYzqG6Ul7I9d/nNNAyuzkyZKEPPhiZ3Kw7n976bCCIpsPOcQiPBvxVqgzm5h YyRrLcnFdfLc41OHuLYj3wK5zS7+2gdUo6XCIKGJySKZ6y5TVUbBHUAGO6b16Cr2FrzH Kj8eQqSrg8Fwx59Fi/atul5tSVXbVgtrsCRhzoqL61aeVUY623Tve0JBemOVB7IwZUd6 vddWXkqCd77GYp1XjoTGyLpIkACtHHbMb2v+3ngojf3x4OCmnohPKxHLPDzdETmKWeOj OButrTT8PyHxhwtpwZoij6hhFKqhC+IdY5zR/MShEy4S586EtzrMygbwmGp8KBjmwNP7 hbLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=BMYrLrCp; 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 gn19-20020a1709070d1300b0078786e168fcsi1693421ejc.452.2022.09.27.23.45.28; Tue, 27 Sep 2022 23:45:54 -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=@nifty.com header.s=dec2015msa header.b=BMYrLrCp; 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 S232974AbiI1GnI (ORCPT + 99 others); Wed, 28 Sep 2022 02:43:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233204AbiI1Gl4 (ORCPT ); Wed, 28 Sep 2022 02:41:56 -0400 Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E51973718E; Tue, 27 Sep 2022 23:41:42 -0700 (PDT) Received: from zoe.. (133-32-182-133.west.xps.vectant.ne.jp [133.32.182.133]) (authenticated) by conuserg-08.nifty.com with ESMTP id 28S6e0G8004120; Wed, 28 Sep 2022 15:40:07 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com 28S6e0G8004120 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1664347208; bh=5aYc69QpW6nhNbvRlVUs8p1oo1ZG3mtyqAcjgjlEHS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BMYrLrCp7B/y6UWo8uz7r4Jb7xL5og70/qXMKphIAXU6tWYk0ngVD2u3PlA8QKneB ZOz+s+HjEjOc3e4UAq9E0XmmH9VclUQubtykYl4FUpjj5kiM0/fIy5glik8QNephsv Gbttsi+Bf309s+l7En+wJAB0AhlrO0GNiBwOOdea9F/1Ar2UkGA95Vq8gfkO7CHbyb a+ULeoLdO7WADaGuImI13pKp/Fhp2lJxoLILAq9mZNsp2V5PtWkF/hzwSicRgo1lOf bzTS73c6Jt5st2ZY2DKZZ4Hts9vIYweWULkwJZOT/f1gRDPAQtNln+EjgPO2o6jGlS 9sgfm274mO6Jg== X-Nifty-SrcIP: [133.32.182.133] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, Al Viro , Ard Biesheuvel , Nicolas Pitre , Masahiro Yamada , Michal Marek , Nick Desaulniers Subject: [PATCH v3 7/8] modpost: squash report_sec_mismatch() and remove enum mismatch Date: Wed, 28 Sep 2022 15:39:46 +0900 Message-Id: <20220928063947.299333-8-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220928063947.299333-1-masahiroy@kernel.org> References: <20220928063947.299333-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_VALIDITY_RPBL,SPF_HELO_NONE, SPF_SOFTFAIL autolearn=no 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 Now report_sec_mismatch() prints the same warning message for all possible cases. (fatal() is just a sanity check for unreachable code.) Squash it into default_mismatch_handler(). enum mismatch is no longer used. Remove it as well. Signed-off-by: Masahiro Yamada --- (no changes since v2) Changes in v2: - New patch scripts/mod/modpost.c | 61 +++---------------------------------------- 1 file changed, 4 insertions(+), 57 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 29f30558a398..90733664a602 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -847,18 +847,6 @@ static const char *const linker_symbols[] = { "__init_begin", "_sinittext", "_einittext", NULL }; static const char *const optim_symbols[] = { "*.constprop.*", NULL }; -enum mismatch { - TEXT_TO_ANY_INIT, - DATA_TO_ANY_INIT, - TEXT_TO_ANY_EXIT, - DATA_TO_ANY_EXIT, - XXXINIT_TO_SOME_INIT, - XXXEXIT_TO_SOME_EXIT, - ANY_INIT_TO_ANY_EXIT, - ANY_EXIT_TO_ANY_INIT, - EXTABLE_TO_NON_TEXT, -}; - /** * Describe how to match sections on different criteria: * @@ -880,7 +868,6 @@ struct sectioncheck { const char *fromsec[20]; const char *bad_tosec[20]; const char *good_tosec[20]; - enum mismatch mismatch; void (*handler)(const char *modname, struct elf_info *elf, const struct sectioncheck* const mismatch, Elf_Rela *r, Elf_Sym *sym, const char *fromsec); @@ -899,56 +886,46 @@ static const struct sectioncheck sectioncheck[] = { { .fromsec = { TEXT_SECTIONS, NULL }, .bad_tosec = { ALL_INIT_SECTIONS, NULL }, - .mismatch = TEXT_TO_ANY_INIT, }, { .fromsec = { DATA_SECTIONS, NULL }, .bad_tosec = { ALL_XXXINIT_SECTIONS, NULL }, - .mismatch = DATA_TO_ANY_INIT, }, { .fromsec = { DATA_SECTIONS, NULL }, .bad_tosec = { INIT_SECTIONS, NULL }, - .mismatch = DATA_TO_ANY_INIT, }, { .fromsec = { TEXT_SECTIONS, NULL }, .bad_tosec = { ALL_EXIT_SECTIONS, NULL }, - .mismatch = TEXT_TO_ANY_EXIT, }, { .fromsec = { DATA_SECTIONS, NULL }, .bad_tosec = { ALL_EXIT_SECTIONS, NULL }, - .mismatch = DATA_TO_ANY_EXIT, }, /* Do not reference init code/data from meminit code/data */ { .fromsec = { ALL_XXXINIT_SECTIONS, NULL }, .bad_tosec = { INIT_SECTIONS, NULL }, - .mismatch = XXXINIT_TO_SOME_INIT, }, /* Do not reference exit code/data from memexit code/data */ { .fromsec = { ALL_XXXEXIT_SECTIONS, NULL }, .bad_tosec = { EXIT_SECTIONS, NULL }, - .mismatch = XXXEXIT_TO_SOME_EXIT, }, /* Do not use exit code/data from init code */ { .fromsec = { ALL_INIT_SECTIONS, NULL }, .bad_tosec = { ALL_EXIT_SECTIONS, NULL }, - .mismatch = ANY_INIT_TO_ANY_EXIT, }, /* Do not use init code/data from exit code */ { .fromsec = { ALL_EXIT_SECTIONS, NULL }, .bad_tosec = { ALL_INIT_SECTIONS, NULL }, - .mismatch = ANY_EXIT_TO_ANY_INIT, }, { .fromsec = { ALL_PCI_INIT_SECTIONS, NULL }, .bad_tosec = { INIT_SECTIONS, NULL }, - .mismatch = ANY_INIT_TO_ANY_EXIT, }, { .fromsec = { "__ex_table", NULL }, @@ -957,7 +934,6 @@ static const struct sectioncheck sectioncheck[] = { */ .bad_tosec = { ".altinstr_replacement", NULL }, .good_tosec = {ALL_TEXT_SECTIONS , NULL}, - .mismatch = EXTABLE_TO_NON_TEXT, .handler = extable_mismatch_handler, } }; @@ -1215,37 +1191,6 @@ static inline void get_pretty_name(int is_func, const char** name, const char** } } -/* - * 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) -{ - sec_mismatch_count++; - - switch (mismatch->mismatch) { - case TEXT_TO_ANY_INIT: - case DATA_TO_ANY_INIT: - case TEXT_TO_ANY_EXIT: - case DATA_TO_ANY_EXIT: - case XXXINIT_TO_SOME_INIT: - case XXXEXIT_TO_SOME_EXIT: - case ANY_INIT_TO_ANY_EXIT: - case ANY_EXIT_TO_ANY_INIT: - warn("%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n", - modname, fromsym, fromsec, tosym, tosec); - break; - case EXTABLE_TO_NON_TEXT: - fatal("There's a special handler for this mismatch type, we should never get here.\n"); - break; - } -} - 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) @@ -1266,8 +1211,10 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf, /* check whitelist - we may ignore it */ if (secref_whitelist(mismatch, fromsec, fromsym, tosec, tosym)) { - report_sec_mismatch(modname, mismatch, - fromsec, fromsym, tosec, tosym); + sec_mismatch_count++; + + warn("%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n", + modname, fromsym, fromsec, tosym, tosec); } } -- 2.34.1