From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Nicolas Pitre <npitre@baylibre.com>,
Nicolas Schier <nicolas@fjasle.eu>,
Masahiro Yamada <masahiroy@kernel.org>
Subject: [PATCH v5 13/21] modpost: replace r->r_offset, r->r_addend with faddr, taddr
Date: Mon, 15 May 2023 00:27:31 +0900 [thread overview]
Message-ID: <20230514152739.962109-14-masahiroy@kernel.org> (raw)
In-Reply-To: <20230514152739.962109-1-masahiroy@kernel.org>
r_offset/r_addend holds the offset address from/to which a symbol is
referenced. It is unclear unless you are familiar with ELF.
Rename them to faddr, taddr, respectively. The prefix 'f' means 'from',
't' means 'to'.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/mod/modpost.c | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 7601f2ca28ed..0ef9d6964b6a 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1183,18 +1183,18 @@ static bool is_executable_section(struct elf_info *elf, unsigned int secndx)
static void default_mismatch_handler(const char *modname, struct elf_info *elf,
const struct sectioncheck* const mismatch,
- Elf_Rela *r, Elf_Sym *tsym,
- unsigned int fsecndx, const char *fromsec,
- const char *tosec)
+ Elf_Sym *tsym,
+ unsigned int fsecndx, const char *fromsec, Elf_Addr faddr,
+ const char *tosec, Elf_Addr taddr)
{
Elf_Sym *from;
const char *tosym;
const char *fromsym;
- from = find_fromsym(elf, r->r_offset, fsecndx);
+ from = find_fromsym(elf, faddr, fsecndx);
fromsym = sym_name(elf, from);
- tsym = find_tosym(elf, r->r_addend, tsym);
+ tsym = find_tosym(elf, taddr, tsym);
tosym = sym_name(elf, tsym);
/* check whitelist - we may ignore it */
@@ -1221,7 +1221,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
break;
case EXTABLE_TO_NON_TEXT:
warn("%s(%s+0x%lx): Section mismatch in reference to the %s:%s\n",
- modname, fromsec, (long)r->r_offset, tosec, tosym);
+ modname, fromsec, (long)faddr, tosec, tosym);
if (match(tosec, mismatch->bad_tosec))
fatal("The relocation at %s+0x%lx references\n"
@@ -1229,7 +1229,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
"Something is seriously wrong and should be fixed.\n"
"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);
+ fromsec, (long)faddr, tosec, modname);
else if (is_executable_section(elf, get_secindex(elf, tsym)))
warn("The relocation at %s+0x%lx references\n"
"section \"%s\" which is not in the list of\n"
@@ -1238,17 +1238,18 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
"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);
+ fromsec, (long)faddr, tosec, tosec, tosec);
else
error("%s+0x%lx references non-executable section '%s'\n",
- fromsec, (long)r->r_offset, tosec);
+ fromsec, (long)faddr, tosec);
break;
}
}
static void check_section_mismatch(const char *modname, struct elf_info *elf,
- Elf_Rela *r, Elf_Sym *sym,
- unsigned int fsecndx, const char *fromsec)
+ Elf_Sym *sym,
+ unsigned int fsecndx, const char *fromsec,
+ Elf_Addr faddr, Elf_Addr taddr)
{
const char *tosec = sec_name(elf, get_secindex(elf, sym));
const struct sectioncheck *mismatch = section_mismatch(fromsec, tosec);
@@ -1256,8 +1257,9 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf,
if (!mismatch)
return;
- default_mismatch_handler(modname, elf, mismatch, r, sym, fsecndx, fromsec,
- tosec);
+ default_mismatch_handler(modname, elf, mismatch, sym,
+ fsecndx, fromsec, faddr,
+ tosec, taddr);
}
static unsigned int *reloc_location(struct elf_info *elf,
@@ -1415,7 +1417,8 @@ static void section_rela(const char *modname, struct elf_info *elf,
/* Skip special sections */
if (is_shndx_special(sym->st_shndx))
continue;
- check_section_mismatch(modname, elf, &r, sym, fsecndx, fromsec);
+ check_section_mismatch(modname, elf, sym,
+ fsecndx, fromsec, r.r_offset, r.r_addend);
}
}
@@ -1473,7 +1476,8 @@ static void section_rel(const char *modname, struct elf_info *elf,
/* Skip special sections */
if (is_shndx_special(sym->st_shndx))
continue;
- check_section_mismatch(modname, elf, &r, sym, fsecndx, fromsec);
+ check_section_mismatch(modname, elf, sym,
+ fsecndx, fromsec, r.r_offset, r.r_addend);
}
}
--
2.39.2
next prev parent reply other threads:[~2023-05-14 15:29 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-14 15:27 [PATCH v5 00/21] Unify <linux/export.h> and <asm/export.h>, remove EXPORT_DATA_SYMBOL(), faster TRIM_UNUSED_KSYMS Masahiro Yamada
2023-05-14 15:27 ` [PATCH v5 01/21] modpost: remove broken calculation of exception_table_entry size Masahiro Yamada
2023-05-14 15:27 ` [PATCH v5 02/21] modpost: remove fromsym info in __ex_table section mismatch warning Masahiro Yamada
2023-05-17 18:53 ` Nick Desaulniers
2023-05-20 13:11 ` Masahiro Yamada
2023-05-14 15:27 ` [PATCH v5 03/21] modpost: remove get_prettyname() Masahiro Yamada
2023-05-17 21:44 ` Nick Desaulniers
2023-05-20 13:32 ` Masahiro Yamada
2023-05-14 15:27 ` [PATCH v5 04/21] modpost: squash report_extable_warnings() into extable_mismatch_handler() Masahiro Yamada
2023-05-17 21:27 ` Nick Desaulniers
2023-05-14 15:27 ` [PATCH v5 05/21] modpost: squash report_sec_mismatch() into default_mismatch_handler() Masahiro Yamada
2023-05-17 21:53 ` Nick Desaulniers
2023-05-14 15:27 ` [PATCH v5 06/21] modpost: clean up is_executable_section() Masahiro Yamada
2023-05-17 21:10 ` Nick Desaulniers
2023-05-20 13:19 ` Masahiro Yamada
2023-05-14 15:27 ` [PATCH v5 07/21] modpost: squash extable_mismatch_handler() into default_mismatch_handler() Masahiro Yamada
2023-05-17 20:55 ` Nick Desaulniers
2023-05-14 15:27 ` [PATCH v5 08/21] modpost: pass 'tosec' down to default_mismatch_handler() Masahiro Yamada
2023-05-17 20:58 ` Nick Desaulniers
2023-05-14 15:27 ` [PATCH v5 09/21] modpost: pass section index to find_elf_symbol2() Masahiro Yamada
2023-05-17 21:05 ` Nick Desaulniers
2023-05-14 15:27 ` [PATCH v5 10/21] modpost: rename find_elf_symbol() and find_elf_symbol2() Masahiro Yamada
2023-05-17 21:14 ` Nick Desaulniers
2023-05-20 13:27 ` Masahiro Yamada
2023-05-22 16:59 ` Nick Desaulniers
2023-05-23 12:04 ` Masahiro Yamada
2023-05-14 15:27 ` [PATCH v5 11/21] modpost: modpost: refactor find_fromsym() and find_tosym() Masahiro Yamada
2023-05-14 15:27 ` [PATCH v5 12/21] modpost: unify 'sym' and 'to' in default_mismatch_handler() Masahiro Yamada
2023-05-14 15:27 ` Masahiro Yamada [this message]
2023-05-14 15:27 ` [PATCH v5 14/21] modpost: remove is_shndx_special() check from section_rel(a) Masahiro Yamada
2023-05-17 21:23 ` Nick Desaulniers
2023-05-17 21:24 ` Nick Desaulniers
2023-05-20 13:45 ` Masahiro Yamada
2023-05-14 15:27 ` [PATCH v5 15/21] modpost: pass struct module pointer to check_section_mismatch() Masahiro Yamada
2023-05-14 15:27 ` [PATCH v5 16/21] kbuild: generate KSYMTAB entries by modpost Masahiro Yamada
2023-10-27 4:29 ` Greg Ungerer
2023-10-27 9:56 ` Masahiro Yamada
2023-05-14 15:27 ` [PATCH v5 17/21] ia64,export.h: replace EXPORT_DATA_SYMBOL* with EXPORT_SYMBOL* Masahiro Yamada
2023-05-14 15:27 ` [PATCH v5 18/21] modpost: check static EXPORT_SYMBOL* by modpost again Masahiro Yamada
2023-05-14 15:27 ` [PATCH v5 19/21] modpost: squash sym_update_namespace() into sym_add_exported() Masahiro Yamada
2023-05-14 15:27 ` [PATCH v5 20/21] modpost: use null string instead of NULL pointer for default namespace Masahiro Yamada
2023-05-14 15:27 ` [PATCH v5 21/21] kbuild: implement CONFIG_TRIM_UNUSED_KSYMS without recursion Masahiro Yamada
2023-05-15 21:31 ` Nicolas Pitre
2023-05-15 22:54 ` Sami Tolvanen
2023-05-16 2:16 ` Masahiro Yamada
2023-05-16 14:51 ` Sami Tolvanen
2023-05-16 1:41 ` Masahiro Yamada
2023-05-21 13:15 ` [PATCH v5 00/21] Unify <linux/export.h> and <asm/export.h>, remove EXPORT_DATA_SYMBOL(), faster TRIM_UNUSED_KSYMS Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230514152739.962109-14-masahiroy@kernel.org \
--to=masahiroy@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nicolas@fjasle.eu \
--cc=npitre@baylibre.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox