Re: [PATCH 1/2] objtool: Fix clang switch table edge case

From: Nathan Chancellor
Date: Tue Feb 18 2020 - 15:09:22 EST


On Mon, Feb 17, 2020 at 09:41:53PM -0600, Josh Poimboeuf wrote:
> Clang has the ability to create a switch table which is not a jump
> table, but is rather a table of string pointers. This confuses objtool,
> because it sees the relocations for the string pointers and assumes
> they're part of a jump table:
>
> drivers/ata/sata_dwc_460ex.o: warning: objtool: sata_dwc_bmdma_start_by_tag()+0x3a2: can't find switch jump table
> net/ceph/messenger.o: warning: objtool: ceph_con_workfn()+0x47c: can't find switch jump table
>
> Make objtool's find_jump_table() smart enough to distinguish between a
> switch jump table (which has relocations to text addresses in the same
> function as the original instruction) and other anonymous rodata (which
> may have relocations to elsewhere).
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/485
> Reported-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
> Tested-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
> Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>

Tested with clang-11 and binutils 2.34, a combo that was previously
broken and I no longer see these warnings on either defconfig or
allyesconfig.

Tested-by: Nathan Chancellor <natechancellor@xxxxxxxxx>