mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-30 02:21:15 +00:00
objtool: Cache instruction relocs
Track the reloc of instructions in the new instruction->reloc field to avoid having to look them up again later. ( Technically x86 instructions can have two relocations, but not jumps and calls, for which we're using this. ) Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Borislav Petkov <bp@suse.de> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Miroslav Benes <mbenes@suse.cz> Link: https://lkml.kernel.org/r/20210326151300.195441549@infradead.org
This commit is contained in:
parent
43d5430ad7
commit
7bd2a600f3
2 changed files with 23 additions and 6 deletions
|
@ -797,6 +797,25 @@ __weak bool arch_is_retpoline(struct symbol *sym)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define NEGATIVE_RELOC ((void *)-1L)
|
||||||
|
|
||||||
|
static struct reloc *insn_reloc(struct objtool_file *file, struct instruction *insn)
|
||||||
|
{
|
||||||
|
if (insn->reloc == NEGATIVE_RELOC)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!insn->reloc) {
|
||||||
|
insn->reloc = find_reloc_by_dest_range(file->elf, insn->sec,
|
||||||
|
insn->offset, insn->len);
|
||||||
|
if (!insn->reloc) {
|
||||||
|
insn->reloc = NEGATIVE_RELOC;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return insn->reloc;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the destination instructions for all jumps.
|
* Find the destination instructions for all jumps.
|
||||||
*/
|
*/
|
||||||
|
@ -811,8 +830,7 @@ static int add_jump_destinations(struct objtool_file *file)
|
||||||
if (!is_static_jump(insn))
|
if (!is_static_jump(insn))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
reloc = find_reloc_by_dest_range(file->elf, insn->sec,
|
reloc = insn_reloc(file, insn);
|
||||||
insn->offset, insn->len);
|
|
||||||
if (!reloc) {
|
if (!reloc) {
|
||||||
dest_sec = insn->sec;
|
dest_sec = insn->sec;
|
||||||
dest_off = arch_jump_destination(insn);
|
dest_off = arch_jump_destination(insn);
|
||||||
|
@ -944,8 +962,7 @@ static int add_call_destinations(struct objtool_file *file)
|
||||||
if (insn->type != INSN_CALL)
|
if (insn->type != INSN_CALL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
reloc = find_reloc_by_dest_range(file->elf, insn->sec,
|
reloc = insn_reloc(file, insn);
|
||||||
insn->offset, insn->len);
|
|
||||||
if (!reloc) {
|
if (!reloc) {
|
||||||
dest_off = arch_jump_destination(insn);
|
dest_off = arch_jump_destination(insn);
|
||||||
insn->call_dest = find_call_destination(insn->sec, dest_off);
|
insn->call_dest = find_call_destination(insn->sec, dest_off);
|
||||||
|
@ -1144,8 +1161,7 @@ static int handle_group_alt(struct objtool_file *file,
|
||||||
* alternatives code can adjust the relative offsets
|
* alternatives code can adjust the relative offsets
|
||||||
* accordingly.
|
* accordingly.
|
||||||
*/
|
*/
|
||||||
alt_reloc = find_reloc_by_dest_range(file->elf, insn->sec,
|
alt_reloc = insn_reloc(file, insn);
|
||||||
insn->offset, insn->len);
|
|
||||||
if (alt_reloc &&
|
if (alt_reloc &&
|
||||||
!arch_support_alt_relocation(special_alt, insn, alt_reloc)) {
|
!arch_support_alt_relocation(special_alt, insn, alt_reloc)) {
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ struct instruction {
|
||||||
struct instruction *jump_dest;
|
struct instruction *jump_dest;
|
||||||
struct instruction *first_jump_src;
|
struct instruction *first_jump_src;
|
||||||
struct reloc *jump_table;
|
struct reloc *jump_table;
|
||||||
|
struct reloc *reloc;
|
||||||
struct list_head alts;
|
struct list_head alts;
|
||||||
struct symbol *func;
|
struct symbol *func;
|
||||||
struct list_head stack_ops;
|
struct list_head stack_ops;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue