In preparation for the objtool klp diff subcommand, define the entry size for the __jump_table section in its ELF header. This will allow tooling to extract individual entries.
Signed-off-by: Josh Poimboeuf <jpoim...@kernel.org> --- arch/x86/include/asm/jump_label.h | 17 +++++++++++------ kernel/bounds.c | 4 ++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h index cd21554b3675..7a6b0e5d85c1 100644 --- a/arch/x86/include/asm/jump_label.h +++ b/arch/x86/include/asm/jump_label.h @@ -12,12 +12,17 @@ #include <linux/stringify.h> #include <linux/types.h> -#define JUMP_TABLE_ENTRY(key, label) \ - ".pushsection __jump_table, \"a\"\n\t" \ - _ASM_ALIGN "\n\t" \ - ".long 1b - . \n\t" \ - ".long " label " - . \n\t" \ - _ASM_PTR " " key " - . \n\t" \ +#ifndef COMPILE_OFFSETS +#include <generated/bounds.h> +#endif + +#define JUMP_TABLE_ENTRY(key, label) \ + ".pushsection __jump_table, \"aM\", @progbits, " \ + __stringify(JUMP_ENTRY_SIZE) "\n\t" \ + _ASM_ALIGN "\n\t" \ + ".long 1b - . \n\t" \ + ".long " label " - . \n\t" \ + _ASM_PTR " " key " - . \n\t" \ ".popsection \n\t" /* This macro is also expanded on the Rust side. */ diff --git a/kernel/bounds.c b/kernel/bounds.c index 02b619eb6106..e4c7ded3dc48 100644 --- a/kernel/bounds.c +++ b/kernel/bounds.c @@ -13,6 +13,7 @@ #include <linux/kbuild.h> #include <linux/log2.h> #include <linux/spinlock_types.h> +#include <linux/jump_label.h> int main(void) { @@ -29,6 +30,9 @@ int main(void) #else DEFINE(LRU_GEN_WIDTH, 0); DEFINE(__LRU_REFS_WIDTH, 0); +#endif +#if defined(CONFIG_HAVE_ARCH_JUMP_LABEL_RELATIVE) && defined(CONFIG_JUMP_LABEL) + DEFINE(JUMP_ENTRY_SIZE, sizeof(struct jump_entry)); #endif /* End of constants */ -- 2.49.0