Skip to contentSkip to conversation

modpost: error out if addend_*_rel() is not implemented for REL arch

PATCH In review Masahiro Yamada 1 participant 2 messages May 11, 2023 – May 21, 2023 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 modpost: error out if addend_*_rel() is not implemented for REL arch

The section mismatch check relies on the relocation entries.

For REL, the addend value is implicit, so we need some code to compute it. Currently, EM_386, EM_ARM, and EM_MIPS are supported. This commit makes sure we covered all the cases.

I believe the other architectures use RELA, where the explicit r_addend field exists.

---

 scripts/mod/modpost.c | 2 ++
 1 file changed, 2 insertions(+)
scripts/mod/modpost.c +2 -0
index 95da374cc534..44309d463a49 100644
@@ -1442,6 +1442,8 @@ static void section_rel(const char *modname, struct elf_info *elf,
 			if (addend_mips_rel(elf, sechdr, &r))
 				continue;
 			break;
+		default:
+			fatal("Please add code to calculate addend for this architecture\n");
 		}
 		sym = elf->symtab_start + r_sym;
 		/* Skip special sections */
Signature · 1 line
2.39.2
#1 lore raw
Quoted 7 lines · Masahiro Yamada

The section mismatch check relies on the relocation entries.

For REL, the addend value is implicit, so we need some code to compute it. Currently, EM_386, EM_ARM, and EM_MIPS are supported. This commit makes sure we covered all the cases.

Quoted 5 lines

I believe the other architectures use RELA, where the explicit r_addend field exists.

---

Applied to linux-kbuild.

Quoted 20 lines
 scripts/mod/modpost.c | 2 ++
 1 file changed, 2 insertions(+)
scripts/mod/modpost.c +2 -1
index 95da374cc534..44309d463a49 100644
@@ -1442,6 +1442,8 @@ static void section_rel(const char *modname, struct elf_info *elf,
                        if (addend_mips_rel(elf, sechdr, &r))
                                continue;
                        break;
+               default:
+                       fatal("Please add code to calculate addend for this architecture\n");
                }
                sym = elf->symtab_start + r_sym;
                /* Skip special sections */
--

2.39.2

Signature · 2 lines
Best Regards
Masahiro Yamada