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>
---
 arch/x86/kernel/unwind_orc.c | 2 ++
 include/linux/objtool.h      | 9 ++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c
index 977ee75e047c..4624d6d916a2 100644
--- a/arch/x86/kernel/unwind_orc.c
+++ b/arch/x86/kernel/unwind_orc.c
@@ -199,6 +199,8 @@ static struct orc_entry *orc_find(unsigned long ip)
 {
        static struct orc_entry *orc;
 
+       BUILD_BUG_ON(UNWIND_HINT_SIZE != sizeof(struct unwind_hint));
+
        if (ip == 0)
                return &null_orc_entry;
 
diff --git a/include/linux/objtool.h b/include/linux/objtool.h
index 366ad004d794..483dd3131826 100644
--- a/include/linux/objtool.h
+++ b/include/linux/objtool.h
@@ -8,11 +8,14 @@
 
 #include <asm/asm.h>
 
+#define UNWIND_HINT_SIZE 12
+
 #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 +91,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
-- 
2.49.0


Reply via email to