Skip to content

Commit 8e86ebe

Browse files
committed
modpost: continue even with unknown relocation type
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>
1 parent 8aa00e2 commit 8e86ebe

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

scripts/mod/modpost.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,8 @@ static int addend_386_rel(uint32_t *location, Elf_Rela *r)
12671267
case R_386_PC32:
12681268
r->r_addend = TO_NATIVE(*location) + 4;
12691269
break;
1270+
default:
1271+
r->r_addend = (Elf_Addr)(-1);
12701272
}
12711273
return 0;
12721274
}
@@ -1382,7 +1384,7 @@ static int addend_arm_rel(void *loc, Elf_Sym *sym, Elf_Rela *r)
13821384
r->r_addend = offset + sym->st_value + 4;
13831385
break;
13841386
default:
1385-
return 1;
1387+
r->r_addend = (Elf_Addr)(-1);
13861388
}
13871389
return 0;
13881390
}
@@ -1392,8 +1394,6 @@ static int addend_mips_rel(uint32_t *location, Elf_Rela *r)
13921394
unsigned int r_typ = ELF_R_TYPE(r->r_info);
13931395
uint32_t inst;
13941396

1395-
if (r_typ == R_MIPS_HI16)
1396-
return 1; /* skip this */
13971397
inst = TO_NATIVE(*location);
13981398
switch (r_typ) {
13991399
case R_MIPS_LO16:
@@ -1405,6 +1405,8 @@ static int addend_mips_rel(uint32_t *location, Elf_Rela *r)
14051405
case R_MIPS_32:
14061406
r->r_addend = inst;
14071407
break;
1408+
default:
1409+
r->r_addend = (Elf_Addr)(-1);
14081410
}
14091411
return 0;
14101412
}
@@ -1514,20 +1516,17 @@ static void section_rel(struct module *mod, struct elf_info *elf,
15141516
r.r_addend = 0;
15151517

15161518
loc = sym_get_data_by_offset(elf, fsecndx, r.r_offset);
1517-
tsym = elf->symtab_start + ELF_R_SYM(r.r_info);
1519+
tsym = elf->symtab_start + r_sym;
15181520

15191521
switch (elf->hdr->e_machine) {
15201522
case EM_386:
1521-
if (addend_386_rel(loc, &r))
1522-
continue;
1523+
addend_386_rel(loc, &r);
15231524
break;
15241525
case EM_ARM:
1525-
if (addend_arm_rel(loc, tsym, &r))
1526-
continue;
1526+
addend_arm_rel(loc, tsym, &r);
15271527
break;
15281528
case EM_MIPS:
1529-
if (addend_mips_rel(loc, &r))
1530-
continue;
1529+
addend_mips_rel(loc, &r);
15311530
break;
15321531
default:
15331532
fatal("Please add code to calculate addend for this architecture\n");

0 commit comments

Comments
 (0)