Re: [PATCH v3 2/4] objtool: Add support for C jump tables

From: Steven Rostedt
Date: Thu Jun 27 2019 - 08:58:11 EST


On Wed, 26 Jun 2019 21:47:00 -0500
Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:

> On Wed, Jun 26, 2019 at 06:42:40PM -0700, Alexei Starovoitov wrote:
> > > @@ -1035,9 +1038,18 @@ static struct rela *find_switch_table(struct objtool_file *file,
> > >
> > > /*
> > > * Make sure the .rodata address isn't associated with a
> > > - * symbol. gcc jump tables are anonymous data.
> > > + * symbol. GCC jump tables are anonymous data.
> > > + *
> > > + * Also support C jump tables which are in the same format as
> > > + * switch jump tables. Each jump table should be a static
> > > + * local const array named "jump_table" for objtool to
> > > + * recognize it.
> >
> > Nacked-by: Alexei Starovoitov <ast@xxxxxxxxxx>
> >
> > It's not acceptable for objtool to dictate kernel naming convention.
>
> Abrasive nack notwithstanding, I agree it's not ideal.
>
> How about the following approach instead? This is the only other way I
> can think of to annotate a jump table so that objtool can distinguish
> it:
>
> #define __annotate_jump_table __section(".jump_table.rodata")
>
> Then bpf would just need the following:
>
> - static const void *jumptable[256] = {
> + static const void __annotate_jump_table *jumptable[256] = {
>
> This would be less magical and fragile than my original approach.
>
> I think the jump table would still be placed with all the other rodata,
> like before, because the vmlinux linker script recognizes the section
> ".rodata" suffix and bundles them all together.
>

After finally getting a chance to skim through this lovely thread, I
was going to suggest exactly this. This is the way we usually handle
"special" data.

As it appears that Alexei is good with this approach, please go this
route.

Thanks!

-- Steve