Re: [PATCH v2 2/5] objtool: Allow arch code to discover jump table size
From: Ard Biesheuvel
Date: Fri Oct 11 2024 - 12:51:16 EST
On Thu, 10 Oct 2024 at 21:52, Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:
>
> On Thu, Oct 10, 2024 at 02:28:04PM +0200, Ard Biesheuvel wrote:
> > @@ -2222,7 +2234,6 @@ static void mark_func_jump_tables(struct objtool_file *file,
> > struct symbol *func)
> > {
> > struct instruction *insn, *last = NULL;
> > - struct reloc *reloc;
> >
> > func_for_each_insn(file, func, insn) {
> > if (!last)
> > @@ -2245,9 +2256,7 @@ static void mark_func_jump_tables(struct objtool_file *file,
> > if (insn->type != INSN_JUMP_DYNAMIC)
> > continue;
> >
> > - reloc = find_jump_table(file, func, insn);
> > - if (reloc)
> > - insn->_jump_table = reloc;
> > + find_jump_table(file, func, insn);
>
> Can we detect the annotation here, and if it exists, pivot to a separate
> generic implementation which skips all the arch-specific code and hacks?
>
> That way we could keep the "ugly" separate, and also have all arches
> supported by default.
>
I had a stab at this, and while the code changes are a bit intrusive,
the end result is much better for it (IMHO).
In the end, the logic in arch_find_switch_table() is mostly generic
anyway, but it is the code traversal in check.c that is the "ugly". So
I moved lots of things around. I'll send that out before signing off
today.