[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230514152739.962109-5-masahiroy@kernel.org>
Date: Mon, 15 May 2023 00:27:22 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: linux-kbuild@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Nicolas Pitre <npitre@...libre.com>,
Nicolas Schier <nicolas@...sle.eu>,
Masahiro Yamada <masahiroy@...nel.org>
Subject: [PATCH v5 04/21] modpost: squash report_extable_warnings() into extable_mismatch_handler()
Collect relevant code into one place to clarify all the cases are
covered by 'if () ... else if ... else ...'.
Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>
---
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
Powered by blists - more mailing lists