Skip to content

Commit 6d48ad0

Browse files
xry111tsbogend
authored andcommitted
MIPS: Ignore relocs against __ex_table for relocatable kernel
Since commit 6f2c2f9 ("scripts/sorttable: Remove unneeded Elf_Rel"), sorttable no longer clears relocs against __ex_table, claiming "it was never used." But in fact MIPS relocatable kernel had been implicitly depending on this behavior, so after this commit the MIPS relocatable kernel has started to spit oops like: CPU 1 Unable to handle kernel paging request at virtual address 000000fffbbdbff8, epc == ffffffff818f9a6c, ra == ffffffff813ad7d0 ... ... Call Trace: [<ffffffff818f9a6c>] __raw_copy_from_user+0x48/0x2fc [<ffffffff813ad7d0>] cp_statx+0x1a0/0x1e0 [<ffffffff813ae528>] do_statx_fd+0xa8/0x118 [<ffffffff813ae670>] sys_statx+0xd8/0xf8 [<ffffffff81156cc8>] syscall_common+0x34/0x58 So ignore those relocs on our own to fix the issue. Fixes: 6f2c2f9 ("scripts/sorttable: Remove unneeded Elf_Rel") Signed-off-by: Xi Ruoyao <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 0ad2507 commit 6d48ad0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

arch/mips/boot/tools/relocs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,8 @@ static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
468468
Elf_Sym *sym, const char *symname))
469469
{
470470
int i;
471+
struct section *extab_sec = sec_lookup("__ex_table");
472+
int extab_index = extab_sec ? extab_sec - secs : -1;
471473

472474
/* Walk through the relocations */
473475
for (i = 0; i < ehdr.e_shnum; i++) {
@@ -480,6 +482,9 @@ static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
480482
if (sec->shdr.sh_type != SHT_REL_TYPE)
481483
continue;
482484

485+
if (sec->shdr.sh_info == extab_index)
486+
continue;
487+
483488
sec_symtab = sec->link;
484489
sec_applies = &secs[sec->shdr.sh_info];
485490
if (!(sec_applies->shdr.sh_flags & SHF_ALLOC))

0 commit comments

Comments
 (0)