From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Masahiro Yamada <masahiroy@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Nicolas Schier <nicolas@fjasle.eu>
Subject: [PATCH 4/4] modpost: remove ElF_Rela variables from for-loop in section_rel(a)
Date: Sun, 23 Jul 2023 19:04:46 +0900 [thread overview]
Message-ID: <20230723100446.3062358-4-masahiroy@kernel.org> (raw)
In-Reply-To: <20230723100446.3062358-1-masahiroy@kernel.org>
Remove the Elf_Rela variables used in the for-loop in section_rel().
This makes the code consistent; section_rel() only uses Elf_Rel,
section_rela() only uses Elf_Rela.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/mod/modpost.c | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index ca04b87c1679..9761f9d0eec0 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1465,8 +1465,6 @@ static void section_rela(struct module *mod, struct elf_info *elf,
Elf_Shdr *sechdr)
{
Elf_Rela *rela;
- Elf_Rela r;
- unsigned int r_sym;
unsigned int fsecndx = sechdr->sh_info;
const char *fromsec = sec_name(elf, fsecndx);
Elf_Rela *start = (void *)elf->hdr + sechdr->sh_offset;
@@ -1477,12 +1475,14 @@ static void section_rela(struct module *mod, struct elf_info *elf,
return;
for (rela = start; rela < stop; rela++) {
- unsigned int r_type;
+ Elf_Addr taddr, r_offset;
+ unsigned int r_type, r_sym;
- r.r_offset = TO_NATIVE(rela->r_offset);
+ r_offset = TO_NATIVE(rela->r_offset);
get_rel_type_and_sym(elf, rela->r_info, &r_type, &r_sym);
- r.r_addend = TO_NATIVE(rela->r_addend);
+ taddr = TO_NATIVE(rela->r_addend);
+
switch (elf->hdr->e_machine) {
case EM_RISCV:
if (!strcmp("__ex_table", fromsec) &&
@@ -1497,7 +1497,7 @@ static void section_rela(struct module *mod, struct elf_info *elf,
}
check_section_mismatch(mod, elf, elf->symtab_start + r_sym,
- fsecndx, fromsec, r.r_offset, r.r_addend);
+ fsecndx, fromsec, r_offset, taddr);
}
}
@@ -1505,8 +1505,6 @@ static void section_rel(struct module *mod, struct elf_info *elf,
Elf_Shdr *sechdr)
{
Elf_Rel *rel;
- Elf_Rela r;
- unsigned int r_sym;
unsigned int fsecndx = sechdr->sh_info;
const char *fromsec = sec_name(elf, fsecndx);
Elf_Rel *start = (void *)elf->hdr + sechdr->sh_offset;
@@ -1518,15 +1516,14 @@ static void section_rel(struct module *mod, struct elf_info *elf,
for (rel = start; rel < stop; rel++) {
Elf_Sym *tsym;
- Elf_Addr taddr = 0;
+ Elf_Addr taddr = 0, r_offset;
+ unsigned int r_type, r_sym;
void *loc;
- unsigned int r_type;
-
- r.r_offset = TO_NATIVE(rel->r_offset);
+ r_offset = TO_NATIVE(rel->r_offset);
get_rel_type_and_sym(elf, rel->r_info, &r_type, &r_sym);
- loc = sym_get_data_by_offset(elf, fsecndx, r.r_offset);
+ loc = sym_get_data_by_offset(elf, fsecndx, r_offset);
tsym = elf->symtab_start + r_sym;
switch (elf->hdr->e_machine) {
@@ -1544,7 +1541,7 @@ static void section_rel(struct module *mod, struct elf_info *elf,
}
check_section_mismatch(mod, elf, tsym,
- fsecndx, fromsec, r.r_offset, taddr);
+ fsecndx, fromsec, r_offset, taddr);
}
}
--
2.39.2
prev parent reply other threads:[~2023-07-23 10:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-23 10:04 [PATCH 1/4] modpost: change return type of addend_*_rel() Masahiro Yamada
2023-07-23 10:04 ` [PATCH 2/4] modpost: pass r_type to addend_*_rel() Masahiro Yamada
2023-07-23 10:04 ` [PATCH 3/4] modpost: clean up MIPS64 little endian relocation code Masahiro Yamada
2023-07-23 10:04 ` Masahiro Yamada [this message]
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=20230723100446.3062358-4-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 \
/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