diff --git a/tools/objtool/check.c b/tools/objtool/check.c index b21e47d8d..3b2d94c90 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2101,6 +2101,7 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn, struct alternative *alt; unsigned long offset; unsigned long rodata_entry_size; + unsigned long rodata_table_size = insn->table_size; /* * Each @reloc is a switch table relocation which points to the target @@ -2112,6 +2113,12 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn, if (reloc != table && reloc == next_table) break; + /* Handle the special cases compiled with Clang on LoongArch */ + if (file->elf->ehdr.e_machine == EM_LOONGARCH && + reloc->sym->type == STT_SECTION && reloc != table && + reloc_offset(reloc) == reloc_offset(table) + rodata_table_size) + break; + /* Handle the special cases compiled with Clang on LoongArch */ if (file->elf->ehdr.e_machine == EM_LOONGARCH && reloc_type(reloc) == R_LARCH_32_PCREL) diff --git a/tools/objtool/include/objtool/check.h b/tools/objtool/include/objtool/check.h index daa46f1f0..11aafcc7b 100644 --- a/tools/objtool/include/objtool/check.h +++ b/tools/objtool/include/objtool/check.h @@ -46,6 +46,7 @@ struct instruction { struct section *sec; unsigned long offset; unsigned long immediate; + unsigned long table_size; u8 len; u8 prev_len;