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

From: Josh Poimboeuf
Date: Wed Jun 26 2019 - 22:47:08 EST


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.

--
Josh