diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 9601235e9..191950551 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -22,6 +22,10 @@ #include #include +#ifndef EM_LOONGARCH +#define EM_LOONGARCH 258 +#endif + struct alternative { struct alternative *next; struct instruction *insn; @@ -711,6 +715,18 @@ reachable: } insn->dead_end = false; + + /* Handle the special cases compiled with Clang on LoongArch */ + if (file->elf->ehdr.e_machine == EM_LOONGARCH && + reloc->sym->type == STT_SECTION) { + while (insn && insn_func(insn)) { + insn = prev_insn_same_sym(file, insn); + if (insn && insn->dead_end) { + insn->dead_end = false; + break; + } + } + } } return 0;