objtool: Handle unreachable entry of rodata

When compiling with Clang on LoongArch, there exists unreachable entry of
rodata which points to a position after the function return instruction,
this is generated by compiler to fill the non-existent switch case, just
skip the entry when parsing the relocation section of rodata.

This is preparation for later patch on LoongArch, there is no effect for
the other archs with this patch.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: michael <michael5hzg@gmail.com>
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn>
This commit is contained in:
Tiezhu Yang
2025-02-13 14:26:41 +08:00
committed by maoxiaochuan
parent e5a48eeb78
commit c0551198ca
+7
View File
@@ -2144,6 +2144,13 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
if (!dest_insn)
break;
/* Handle the special cases compiled with Clang on LoongArch */
if (file->elf->ehdr.e_machine == EM_LOONGARCH && reloc->sym->type == STT_SECTION &&
(!insn_func(dest_insn) || insn_func(dest_insn)->pfunc != pfunc)) {
prev_offset = reloc_offset(reloc);
continue;
}
/* Make sure the destination is in the same function: */
if (!insn_func(dest_insn) || insn_func(dest_insn)->pfunc != pfunc)
break;