In preparation for the objtool klp diff subcommand, define the entry size for the discard.unwind_hints section in its ELF header. This will allow tooling to extract individual entries.
Signed-off-by: Josh Poimboeuf <jpoim...@kernel.org> --- include/linux/objtool.h | 11 ++++++++--- kernel/bounds.c | 4 ++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/linux/objtool.h b/include/linux/objtool.h index 366ad004d794..c7a3851ae4ae 100644 --- a/include/linux/objtool.h +++ b/include/linux/objtool.h @@ -2,6 +2,10 @@ #ifndef _LINUX_OBJTOOL_H #define _LINUX_OBJTOOL_H +#ifndef COMPILE_OFFSETS +#include <generated/bounds.h> +#endif + #include <linux/objtool_types.h> #ifdef CONFIG_OBJTOOL @@ -10,9 +14,10 @@ #ifndef __ASSEMBLY__ -#define UNWIND_HINT(type, sp_reg, sp_offset, signal) \ +#define UNWIND_HINT(type, sp_reg, sp_offset, signal) \ "987: \n\t" \ - ".pushsection .discard.unwind_hints\n\t" \ + ".pushsection .discard.unwind_hints, \"M\", @progbits, "\ + __stringify(UNWIND_HINT_SIZE) "\n\t" \ /* struct unwind_hint */ \ ".long 987b - .\n\t" \ ".short " __stringify(sp_offset) "\n\t" \ @@ -88,7 +93,7 @@ */ .macro UNWIND_HINT type:req sp_reg=0 sp_offset=0 signal=0 .Lhere_\@: - .pushsection .discard.unwind_hints + .pushsection .discard.unwind_hints, "M", @progbits, UNWIND_HINT_SIZE /* struct unwind_hint */ .long .Lhere_\@ - . .short \sp_offset diff --git a/kernel/bounds.c b/kernel/bounds.c index 21c37e3ea629..f9bc13727721 100644 --- a/kernel/bounds.c +++ b/kernel/bounds.c @@ -15,6 +15,7 @@ #include <linux/spinlock_types.h> #include <linux/jump_label.h> #include <linux/static_call_types.h> +#include <linux/objtool_types.h> int main(void) { @@ -37,6 +38,9 @@ int main(void) #endif #ifdef CONFIG_HAVE_STATIC_CALL_INLINE DEFINE(STATIC_CALL_TRAMP_KEY_SIZE, sizeof(struct static_call_tramp_key)); +#endif +#ifdef CONFIG_OBJTOOL + DEFINE(UNWIND_HINT_SIZE, sizeof(struct unwind_hint)); #endif /* End of constants */ -- 2.49.0