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

From: Alexei Starovoitov
Date: Wed Jun 26 2019 - 21:43:10 EST


On Wed, Jun 26, 2019 at 5:38 PM Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:
>
> Objtool doesn't know how to read C jump tables, so it has to whitelist
> functions which use them, causing missing ORC unwinder data for such
> functions, e.g. ___bpf_prog_run().
>
> C jump tables are very similar to GCC switch jump tables, which objtool
> already knows how to read. So adding support for C jump tables is easy.
> It just needs to be able to find the tables and distinguish them from
> other data.
>
> To allow the jump tables to be found, create a standard: objtool will
> automatically recognize any static local jump table named "jump_table".
>
> Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> ---
> tools/objtool/check.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 172f99195726..8341c2fff14f 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -18,6 +18,8 @@
>
> #define FAKE_JUMP_OFFSET -1
>
> +#define JUMP_TABLE_SYM_PREFIX "jump_table."
> +
> struct alternative {
> struct list_head list;
> struct instruction *insn;
> @@ -997,6 +999,7 @@ static struct rela *find_switch_table(struct objtool_file *file,
> struct instruction *orig_insn = insn;
> struct section *rodata_sec;
> unsigned long table_offset;
> + struct symbol *sym;
>
> /*
> * Backward search using the @first_jump_src links, these help avoid
> @@ -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.