mirror of
https://gitee.com/open-loongarch/linux-6.12.git
synced 2026-10-28 05:57:12 +08:00
objtool: Handle unsorted table offset of rodata
When compiling with Clang on LoongArch, there are unsorted table offset of rodata if there exist many jump tables, it will get the wrong table end and find the wrong jump destination instructions in add_jump_table(), so it needs to check the table size of rodata to break the process 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:
committed by
maoxiaochuan
parent
c0551198ca
commit
2f6c22f3e3
@@ -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)
|
||||
|
||||
@@ -46,6 +46,7 @@ struct instruction {
|
||||
struct section *sec;
|
||||
unsigned long offset;
|
||||
unsigned long immediate;
|
||||
unsigned long table_size;
|
||||
|
||||
u8 len;
|
||||
u8 prev_len;
|
||||
|
||||
Reference in New Issue
Block a user