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 3/3] modpost: continue even with unknown relocation type
Date: Tue, 20 Jun 2023 21:05:21 +0900 [thread overview]
Message-ID: <20230620120521.688124-3-masahiroy@kernel.org> (raw)
In-Reply-To: <20230620120521.688124-1-masahiroy@kernel.org>
Currently, unknown relocation types are just skipped.
The value of r_addend is only needed to get the symbol name in case
is_valid_name(elf, sym) returns false.
Even if we do not know how to calculate r_addend, we should continue.
At worst, we will get "(unknown)" as the symbol name, but it is better
than failing to detect section mismatches.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/mod/modpost.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index ffe45c54f024..7e92380d4f1f 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1267,6 +1267,8 @@ static int addend_386_rel(uint32_t *location, Elf_Rela *r)
case R_386_PC32:
r->r_addend = TO_NATIVE(*location) + 4;
break;
+ default:
+ r->r_addend = (Elf_Addr)(-1);
}
return 0;
}
@@ -1382,7 +1384,7 @@ static int addend_arm_rel(void *loc, Elf_Sym *sym, Elf_Rela *r)
r->r_addend = offset + sym->st_value + 4;
break;
default:
- return 1;
+ r->r_addend = (Elf_Addr)(-1);
}
return 0;
}
@@ -1392,8 +1394,6 @@ static int addend_mips_rel(uint32_t *location, Elf_Rela *r)
unsigned int r_typ = ELF_R_TYPE(r->r_info);
uint32_t inst;
- if (r_typ == R_MIPS_HI16)
- return 1; /* skip this */
inst = TO_NATIVE(*location);
switch (r_typ) {
case R_MIPS_LO16:
@@ -1405,6 +1405,8 @@ static int addend_mips_rel(uint32_t *location, Elf_Rela *r)
case R_MIPS_32:
r->r_addend = inst;
break;
+ default:
+ r->r_addend = (Elf_Addr)(-1);
}
return 0;
}
@@ -1514,20 +1516,17 @@ static void section_rel(struct module *mod, struct elf_info *elf,
r.r_addend = 0;
loc = sym_get_data_by_offset(elf, fsecndx, r.r_offset);
- tsym = elf->symtab_start + ELF_R_SYM(r.r_info);
+ tsym = elf->symtab_start + r_sym;
switch (elf->hdr->e_machine) {
case EM_386:
- if (addend_386_rel(loc, &r))
- continue;
+ addend_386_rel(loc, &r);
break;
case EM_ARM:
- if (addend_arm_rel(loc, tsym, &r))
- continue;
+ addend_arm_rel(loc, tsym, &r);
break;
case EM_MIPS:
- if (addend_mips_rel(loc, &r))
- continue;
+ addend_mips_rel(loc, &r);
break;
default:
fatal("Please add code to calculate addend for this architecture\n");
--
2.39.2
next prev parent reply other threads:[~2023-06-20 12:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 12:05 [PATCH 1/3] modpost: factor out inst location calculation to section_rel() Masahiro Yamada
2023-06-20 12:05 ` [PATCH 2/3] modpost: factor out Elf_Sym pointer " Masahiro Yamada
2023-06-22 19:01 ` Nick Desaulniers
2023-06-20 12:05 ` Masahiro Yamada [this message]
2023-06-22 18:25 ` [PATCH 1/3] modpost: factor out inst location " Nick Desaulniers
2023-06-23 5:37 ` Masahiro Yamada
2023-06-23 17:00 ` Nick Desaulniers
2023-06-24 8:55 ` 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=20230620120521.688124-3-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