Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp924476rwd; Sun, 14 May 2023 08:59:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ70N1g/ej1jBPsC/E2bmi8sfu6eOJ74TsEaRBolpoEolI+vC6wJ2Po2cLaq6VXKxczzbFSg X-Received: by 2002:a17:90a:8a8d:b0:24e:69e:71f with SMTP id x13-20020a17090a8a8d00b0024e069e071fmr29669706pjn.7.1684079950308; Sun, 14 May 2023 08:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684079950; cv=none; d=google.com; s=arc-20160816; b=0uzUGLC0smzcNJatZSdh/Ol/0DYSRkLK3Bdo2IQ/seEIVMgIWjiuXO6hf/Q1FVmtpM yIMNx0BHvo7s1DlWA1aKXKwdiUd2qK6aAM6AyNUZHW/DgMjwrF1XuBil12A4alpLfJ0l vm87Rmez8/dzK3CkTxDT1EVj+DwDP6URbHeE6AdMPly6k0pbcJEC0cYhskbo0oM7ZClm sZ+INykfx9BQiw1q6OTa8gQx90cLbTBdilb/0ytzZ3SA9ulbud2c26NsQBBDReooMi27 CDxUqKz/jb2YNY5AIXus/J5QXmhh/EzYOO0zICUQGsFZ4JrmeGYPVj7NJDB55rpmHBc0 BAVw== 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=P0242EPJHZHkLIkT9qiSce4LpfWgdmusptR1C9Hw0Q0=; b=DX8AMOW9IFVzFHkK6Ugjyr8NHp1C7gUkyu+WQfUiy/ubaV86Sb6CG37Q1ZrwQmKj94 ry3qhKmpwNos9i/l27MNpOVM6g7/LgxFboh0HflWh2PUVURbEjClMJuZf6iH91LUspgR 1CjUvwSoYkcVRs8Mr0cJTijBU/UHczI3/+UpXP9r7KLI8072HYzMD2CCirlwJ9FlyNLQ 2dcU1Ci91rNktgrEB5ARTNShSDHAGX+3giZXBOWEqxK/qVDk/c1loXZj9jV5rOB5IGEe g+yIk5BFUem3A9E+bj1oBmjDyse0NHh401n1YVXPNcPhkiJqDuJ6U0UXuUolnrcvunxE JjHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LyOKbocg; 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 l20-20020a170903005400b001add2b13fb4si7342896pla.620.2023.05.14.08.58.54; Sun, 14 May 2023 08:59:10 -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=LyOKbocg; 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 S237762AbjENP2D (ORCPT + 99 others); Sun, 14 May 2023 11:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237280AbjENP15 (ORCPT ); Sun, 14 May 2023 11:27:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E8F12699; Sun, 14 May 2023 08:27:56 -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 E8CC360C13; Sun, 14 May 2023 15:27:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8438FC4339B; Sun, 14 May 2023 15:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684078075; bh=MgXAugWg05JpajxGCkES+KuPc7L8WPiutMpYWSE6mLs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LyOKbocgjhgQArA7TMLiRD7kcV1GFtfwYotJK3pbrGbhhBlg9ssXlcvkuwp+j5rPE y0wLLuUaHHhVni+ax1IvB/8LIzOBeOT4B8L+TBClBaFRIlBmH0keevQ+KsDC+zYm8t TdX9AQmVbBU7qME7C/SXBE8bXWN/6uIIp+4JG3y7sC4BeA6r90eTz4+YxJr+0aw3+k 1aSkWzV5iOu61c2QwkG4DdizYuFw9Nnl5ATb21MumCELBtqOzFjpEE/1NfciybLGYP LJC1NXHXk0XBpMBjIXdLF5/dZ6WjUoee3EgBGrwNQCmT0NlW806HrChhGAnTN0KvxI r5llPFNy0ChoQ== 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 04/21] modpost: squash report_extable_warnings() into extable_mismatch_handler() Date: Mon, 15 May 2023 00:27:22 +0900 Message-Id: <20230514152739.962109-5-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=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 Collect relevant code into one place to clarify all the cases are covered by 'if () ... else if ... else ...'. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 371891d67175..7a9a3ef8ca0d 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1275,40 +1275,19 @@ static int is_executable_section(struct elf_info* elf, unsigned int section_inde return ((elf->sechdrs[section_index].sh_flags & SHF_EXECINSTR) == SHF_EXECINSTR); } -static void report_extable_warnings(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* tosym = find_elf_symbol(elf, r->r_addend, sym); - const char* tosym_name = sym_name(elf, tosym); - - warn("%s(%s+0x%lx): Section mismatch in reference to the %s:%s\n", - modname, fromsec, (long)r->r_offset, tosec, tosym_name); - - if (!match(tosec, mismatch->bad_tosec) && - is_executable_section(elf, get_secindex(elf, sym))) - fprintf(stderr, - "The relocation at %s+0x%lx references\n" - "section \"%s\" which is not in the list of\n" - "authorized sections. If you're adding a new section\n" - "and/or if this reference is valid, add \"%s\" to the\n" - "list of authorized sections to jump to on fault.\n" - "This can be achieved by adding \"%s\" to \n" - "OTHER_TEXT_SECTIONS in scripts/mod/modpost.c.\n", - fromsec, (long)r->r_offset, tosec, tosec, tosec); -} - static void extable_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 = sec_name(elf, get_secindex(elf, sym)); + Elf_Sym *tosym = find_elf_symbol(elf, r->r_addend, sym); + const char *tosym_name = sym_name(elf, tosym); sec_mismatch_count++; - report_extable_warnings(modname, elf, mismatch, r, sym, fromsec, tosec); + warn("%s(%s+0x%lx): Section mismatch in reference to the %s:%s\n", + modname, fromsec, (long)r->r_offset, tosec, tosym_name); if (match(tosec, mismatch->bad_tosec)) fatal("The relocation at %s+0x%lx references\n" @@ -1317,7 +1296,16 @@ static void extable_mismatch_handler(const char* modname, struct elf_info *elf, "You might get more information about where this is\n" "coming from by using scripts/check_extable.sh %s\n", fromsec, (long)r->r_offset, tosec, modname); - else if (!is_executable_section(elf, get_secindex(elf, sym))) + else if (is_executable_section(elf, get_secindex(elf, sym))) + warn("The relocation at %s+0x%lx references\n" + "section \"%s\" which is not in the list of\n" + "authorized sections. If you're adding a new section\n" + "and/or if this reference is valid, add \"%s\" to the\n" + "list of authorized sections to jump to on fault.\n" + "This can be achieved by adding \"%s\" to\n" + "OTHER_TEXT_SECTIONS in scripts/mod/modpost.c.\n", + fromsec, (long)r->r_offset, tosec, tosec, tosec); + else error("%s+0x%lx references non-executable section '%s'\n", fromsec, (long)r->r_offset, tosec); } -- 2.39.2