Skip to contentSkip to conversation

objtool: Improve code generation for annotation macros

PATCH Superseded Josh Poimboeuf 3 participants 7 messages Nov 26, 2025 – Dec 3, 2025

Subsystems (7)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Josh Poimboeuf

author maintainer
#0 lore raw

cover objtool: Improve code generation for annotation macros

For tip/objtool/core.

As much as possible, undo the code generation damage introduced by ANNOTATE_DATA_SPECIAL:

- Remove its usage in favor of SHF_MERGE + sh_entsize, where possible

- Print the annotation on a single line:

      912: .pushsection ".discard.annotate_data", "M", @progbits, 8; .long 912b - .; .long 1; .popsection

- Remove the trailing newline/tab; let the invoking code decide on the appropriate separator for the given context

Josh Poimboeuf (4):
x86/alternative: Remove ANNOTATE_DATA_SPECIAL usage x86/asm: Remove ANNOTATE_DATA_SPECIAL usage
objtool: Consolidate annotation macros
objtool: Remove newlines and tabs from annotation macros

 arch/um/include/asm/Kbuild                 |  1 -
 arch/um/include/shared/common-offsets.h    |  3 ++
 arch/x86/include/asm/alternative.h         |  9 +++---
 arch/x86/include/asm/asm.h                 | 25 ++++++++-------
 arch/x86/include/asm/bug.h                 |  2 +-
 arch/x86/include/asm/cpufeature.h          |  2 +-
 arch/x86/include/asm/irq_stack.h           |  2 +-
 arch/x86/include/asm/jump_label.h          |  2 +-
 arch/x86/include/asm/nospec-branch.h       |  4 +--
 arch/x86/include/asm/paravirt_types.h      |  2 +-
 arch/x86/include/asm/smap.h                |  8 ++---
 arch/x86/include/asm/static_call.h         |  2 +-
 arch/x86/kernel/alternative.c              |  4 +--
 arch/x86/kernel/asm-offsets.c              |  3 ++
 arch/x86/kernel/rethook.c                  |  2 +-
 arch/x86/kernel/static_call.c              |  4 +--
 arch/x86/lib/error-inject.c                |  2 +-
 arch/x86/um/shared/sysdep/kernel-offsets.h |  2 ++
 include/linux/annotate.h                   | 36 +++++++++-------------
 include/linux/objtool.h                    |  2 +-
 kernel/bounds.c                            |  1 +
 scripts/mod/devicetable-offsets.c          |  1 +
 22 files changed, 62 insertions(+), 57 deletions(-)
Signature · 1 line
2.51.1
author maintainer
#1 lore raw

PATCH 1/4 x86/alternative: Remove ANNOTATE_DATA_SPECIAL usage

Instead of manually annotating each .altinstructions entry, just make the section mergeable and store the entry size in the ELF section header.

Either way works for objtool create_fake_symbols(), this way produces cleaner code generation.

---
 arch/um/include/shared/common-offsets.h | 2 ++
 arch/x86/include/asm/alternative.h      | 7 +++----
 arch/x86/kernel/asm-offsets.c           | 2 ++
 3 files changed, 7 insertions(+), 4 deletions(-)
arch/um/include/shared/common-offsets.h +2 -0
index 8ca66a1918c3..4e19103afd71 100644
@@ -18,3 +18,5 @@ DEFINE(UM_NSEC_PER_USEC, NSEC_PER_USEC);
 DEFINE(UM_KERN_GDT_ENTRY_TLS_ENTRIES, GDT_ENTRY_TLS_ENTRIES);
 
 DEFINE(UM_SECCOMP_ARCH_NATIVE, SECCOMP_ARCH_NATIVE);
+
+DEFINE(ALT_INSTR_SIZE, sizeof(struct alt_instr));
arch/x86/include/asm/alternative.h +3 -4
index b14c045679e1..df2c8705e17b 100644
@@ -197,8 +197,8 @@ static inline int alternatives_text_reserved(void *start, void *end)
 	"773:\n"
 
 #define ALTINSTR_ENTRY(ft_flags)					      \
-	".pushsection .altinstructions,\"a\"\n"				      \
-	ANNOTATE_DATA_SPECIAL						      \
+	".pushsection .altinstructions, \"aM\", @progbits, "		      \
+		      __stringify(ALT_INSTR_SIZE) "\n"			      \
 	" .long 771b - .\n"				/* label           */ \
 	" .long 774f - .\n"				/* new instruction */ \
 	" .4byte " __stringify(ft_flags) "\n"		/* feature + flags */ \
@@ -339,7 +339,6 @@ void nop_func(void);
  * instruction. See apply_alternatives().
  */
 .macro altinstr_entry orig alt ft_flags orig_len alt_len
-	ANNOTATE_DATA_SPECIAL
 	.long \orig - .
 	.long \alt - .
 	.4byte \ft_flags
@@ -363,7 +362,7 @@ void nop_func(void);
 741:									\
 	.skip -(((744f-743f)-(741b-740b)) > 0) * ((744f-743f)-(741b-740b)),0x90	;\
 742:									\
-	.pushsection .altinstructions,"a" ;				\
+	.pushsection .altinstructions, "aM", @progbits, ALT_INSTR_SIZE ;\
 	altinstr_entry 740b,743f,flag,742b-740b,744f-743f ;		\
 	.popsection ;							\
 	.pushsection .altinstr_replacement,"ax"	;			\
arch/x86/kernel/asm-offsets.c +2 -0
index 32ba599a51f8..db3bb5143329 100644
@@ -124,4 +124,6 @@ static void __used common(void)
 	OFFSET(ARIA_CTX_rounds, aria_ctx, rounds);
 #endif
 
+	BLANK();
+	DEFINE(ALT_INSTR_SIZE,	sizeof(struct alt_instr));
 }
Signature · 1 line
2.51.1
author maintainer
#2 lore raw

PATCH 2/4 x86/asm: Remove ANNOTATE_DATA_SPECIAL usage

In reply to Josh Poimboeuf

Instead of manually annotating each __ex_table entry, just make the section mergeable and store the entry size in the ELF section header.

Either way works for objtool create_fake_symbols(), this way produces cleaner code generation.

---
 arch/um/include/asm/Kbuild                 |  1 -
 arch/um/include/shared/common-offsets.h    |  1 +
 arch/x86/include/asm/asm.h                 | 25 ++++++++++++----------
 arch/x86/kernel/asm-offsets.c              |  1 +
 arch/x86/um/shared/sysdep/kernel-offsets.h |  2 ++
 kernel/bounds.c                            |  1 +
 scripts/mod/devicetable-offsets.c          |  1 +
 7 files changed, 20 insertions(+), 12 deletions(-)
arch/um/include/asm/Kbuild +0 -1
index b6810db24ca4..1b9b82bbe322 100644
@@ -5,7 +5,6 @@ generic-y += device.h
 generic-y += dma-mapping.h
 generic-y += emergency-restart.h
 generic-y += exec.h
-generic-y += extable.h
 generic-y += ftrace.h
 generic-y += hw_irq.h
 generic-y += irq_regs.h
arch/um/include/shared/common-offsets.h +1 -0
index 4e19103afd71..a6f77cb6aa7e 100644
@@ -20,3 +20,4 @@ DEFINE(UM_KERN_GDT_ENTRY_TLS_ENTRIES, GDT_ENTRY_TLS_ENTRIES);
 DEFINE(UM_SECCOMP_ARCH_NATIVE, SECCOMP_ARCH_NATIVE);
 
 DEFINE(ALT_INSTR_SIZE, sizeof(struct alt_instr));
+DEFINE(EXTABLE_SIZE,   sizeof(struct exception_table_entry));
arch/x86/include/asm/asm.h +14 -11
index bd62bd87a841..0e8c611bc9e2 100644
@@ -126,18 +126,21 @@ static __always_inline __pure void *rip_rel_ptr(void *p)
 
 #ifdef __KERNEL__
 
+#ifndef COMPILE_OFFSETS
+#include <asm/asm-offsets.h>
+#endif
+
 # include <asm/extable_fixup_types.h>
 
 /* Exception table entry */
 #ifdef __ASSEMBLER__
 
-# define _ASM_EXTABLE_TYPE(from, to, type)			\
-	.pushsection "__ex_table","a" ;				\
-	.balign 4 ;						\
-	ANNOTATE_DATA_SPECIAL ;					\
-	.long (from) - . ;					\
-	.long (to) - . ;					\
-	.long type ;						\
+# define _ASM_EXTABLE_TYPE(from, to, type)				\
+	.pushsection "__ex_table", "aM", @progbits, EXTABLE_SIZE ;	\
+	.balign 4 ;							\
+	.long (from) - . ;						\
+	.long (to) - . ;						\
+	.long type ;							\
 	.popsection
 
 # ifdef CONFIG_KPROBES
@@ -180,18 +183,18 @@ static __always_inline __pure void *rip_rel_ptr(void *p)
 	".purgem extable_type_reg\n"
 
 # define _ASM_EXTABLE_TYPE(from, to, type)			\
-	" .pushsection \"__ex_table\",\"a\"\n"			\
+	" .pushsection __ex_table, \"aM\", @progbits, "		\
+		       __stringify(EXTABLE_SIZE) "\n"		\
 	" .balign 4\n"						\
-	ANNOTATE_DATA_SPECIAL					\
 	" .long (" #from ") - .\n"				\
 	" .long (" #to ") - .\n"				\
 	" .long " __stringify(type) " \n"			\
 	" .popsection\n"
 
 # define _ASM_EXTABLE_TYPE_REG(from, to, type, reg)				\
-	" .pushsection \"__ex_table\",\"a\"\n"					\
+	" .pushsection __ex_table, \"aM\", @progbits, "				\
+		       __stringify(EXTABLE_SIZE) "\n"				\
 	" .balign 4\n"								\
-	ANNOTATE_DATA_SPECIAL							\
 	" .long (" #from ") - .\n"						\
 	" .long (" #to ") - .\n"						\
 	DEFINE_EXTABLE_TYPE_REG							\
arch/x86/kernel/asm-offsets.c +1 -0
index db3bb5143329..25fcde525c68 100644
@@ -126,4 +126,5 @@ static void __used common(void)
 
 	BLANK();
 	DEFINE(ALT_INSTR_SIZE,	sizeof(struct alt_instr));
+	DEFINE(EXTABLE_SIZE,	sizeof(struct exception_table_entry));
 }
arch/x86/um/shared/sysdep/kernel-offsets.h +2 -0
index 6fd1ed400399..8215a0200ddd 100644
@@ -1,4 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#define COMPILE_OFFSETS
 #include <linux/stddef.h>
 #include <linux/sched.h>
 #include <linux/elf.h>
@@ -7,6 +8,7 @@
 #include <linux/audit.h>
 #include <asm/mman.h>
 #include <asm/seccomp.h>
+#include <asm/extable.h>
 
 /* workaround for a warning with -Wmissing-prototypes */
 void foo(void);
kernel/bounds.c +1 -0
index 29b2cd00df2c..02b619eb6106 100644
@@ -6,6 +6,7 @@
  */
 
 #define __GENERATING_BOUNDS_H
+#define COMPILE_OFFSETS
 /* Include headers that define the enum constants of interest */
 #include <linux/page-flags.h>
 #include <linux/mmzone.h>
scripts/mod/devicetable-offsets.c +1 -0
index d3d00e85edf7..ef2ffb68f69d 100644
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
+#define COMPILE_OFFSETS
 #include <linux/kbuild.h>
 #include <linux/mod_devicetable.h>
 
Signature · 1 line
2.51.1
author maintainer
#3 lore raw

PATCH 3/4 objtool: Consolidate annotation macros

In reply to Josh Poimboeuf

Consolidate __ASM_ANNOTATE into a single macro which is used by both C and asm. This also makes the code generation a bit more palatable by putting it all on a single line.

---
 include/linux/annotate.h | 36 +++++++++++++++---------------------
 1 file changed, 15 insertions(+), 21 deletions(-)
include/linux/annotate.h +15 -21
index 7c10d34d198c..996126f5f9ec 100644
@@ -6,41 +6,35 @@
 
 #ifdef CONFIG_OBJTOOL
 
+#define __ASM_ANNOTATE(section, label, type)				\
+	.pushsection section, "M", @progbits, 8;			\
+	.long label - .;						\
+	.long type;							\
+	.popsection
+
 #ifndef __ASSEMBLY__
 
-#define __ASM_ANNOTATE(section, label, type)				\
-	".pushsection " section ",\"M\", @progbits, 8\n\t"		\
-	".long " __stringify(label) " - .\n\t"				\
-	".long " __stringify(type) "\n\t"				\
-	".popsection\n\t"
-
 #define ASM_ANNOTATE_LABEL(label, type)					\
-	__ASM_ANNOTATE(".discard.annotate_insn", label, type)
+	__stringify(__ASM_ANNOTATE(".discard.annotate_insn", label, type)) "\n\t"
 
 #define ASM_ANNOTATE(type)						\
-	"911:\n\t"							\
-	ASM_ANNOTATE_LABEL(911b, type)
+	"911: "								\
+	__stringify(__ASM_ANNOTATE(".discard.annotate_insn", 911b, type)) "\n\t"
 
 #define ASM_ANNOTATE_DATA(type)						\
-	"912:\n\t"							\
-	__ASM_ANNOTATE(".discard.annotate_data", 912b, type)
+	"912: "								\
+	__stringify(__ASM_ANNOTATE(".discard.annotate_data", 912b, type)) "\n\t"
 
 #else /* __ASSEMBLY__ */
 
-.macro __ANNOTATE section, type
-.Lhere_\@:
-	.pushsection \section, "M", @progbits, 8
-	.long	.Lhere_\@ - .
-	.long	\type
-	.popsection
-.endm
-
 .macro ANNOTATE type
-	__ANNOTATE ".discard.annotate_insn", \type
+.Lhere_\@:
+	__ASM_ANNOTATE(".discard.annotate_insn", .Lhere_\@, \type)
 .endm
 
 .macro ANNOTATE_DATA type
-	__ANNOTATE ".discard.annotate_data", \type
+.Lhere_\@:
+	__ASM_ANNOTATE(".discard.annotate_data", .Lhere_\@, \type)
 .endm
 
 #endif /* __ASSEMBLY__ */
Signature · 1 line
2.51.1
author maintainer
#4 lore raw

PATCH 4/4 objtool: Remove newlines and tabs from annotation macros

In reply to Josh Poimboeuf

Remove newlines and tabs from the annotation macros so the invoking code can insert them as needed to match the style of the surrounding code.

---
 arch/x86/include/asm/alternative.h    | 2 +-
 arch/x86/include/asm/bug.h            | 2 +-
 arch/x86/include/asm/cpufeature.h     | 2 +-
 arch/x86/include/asm/irq_stack.h      | 2 +-
 arch/x86/include/asm/jump_label.h     | 2 +-
 arch/x86/include/asm/nospec-branch.h  | 4 ++--
 arch/x86/include/asm/paravirt_types.h | 2 +-
 arch/x86/include/asm/smap.h           | 8 ++++----
 arch/x86/include/asm/static_call.h    | 2 +-
 arch/x86/kernel/alternative.c         | 4 ++--
 arch/x86/kernel/rethook.c             | 2 +-
 arch/x86/kernel/static_call.c         | 4 ++--
 arch/x86/lib/error-inject.c           | 2 +-
 include/linux/annotate.h              | 6 +++---
 include/linux/objtool.h               | 2 +-
 15 files changed, 23 insertions(+), 23 deletions(-)
arch/x86/include/asm/alternative.h +1 -1
index df2c8705e17b..03364510d5fe 100644
@@ -208,7 +208,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
 
 #define ALTINSTR_REPLACEMENT(newinstr)		/* replacement */	\
 	".pushsection .altinstr_replacement, \"ax\"\n"			\
-	ANNOTATE_DATA_SPECIAL						\
+	ANNOTATE_DATA_SPECIAL "\n"					\
 	"# ALT: replacement\n"						\
 	"774:\n\t" newinstr "\n775:\n"					\
 	".popsection\n"
arch/x86/include/asm/bug.h +1 -1
index 372f4018880c..2134e64911e1 100644
@@ -57,7 +57,7 @@
 #define _BUG_FLAGS_ASM(ins, file, line, flags, size, extra)		\
 	"1:\t" ins "\n"							\
 	".pushsection __bug_table,\"aw\"\n"				\
-	ANNOTATE_DATA_SPECIAL						\
+	ANNOTATE_DATA_SPECIAL "\n"					\
 	__BUG_ENTRY(file, line, flags)					\
 	"\t.org 2b + " size "\n"					\
 	".popsection\n"							\
arch/x86/include/asm/cpufeature.h +1 -1
index fc5f32d4da6e..d8bc614f92fa 100644
@@ -101,7 +101,7 @@ static __always_inline bool _static_cpu_has(u16 bit)
 	asm goto(ALTERNATIVE_TERNARY("jmp 6f", %c[feature], "", "jmp %l[t_no]")
 		".pushsection .altinstr_aux,\"ax\"\n"
 		"6:\n"
-		ANNOTATE_DATA_SPECIAL
+		ANNOTATE_DATA_SPECIAL "\n"
 		" testb %[bitnum], %a[cap_byte]\n"
 		" jnz %l[t_yes]\n"
 		" jmp %l[t_no]\n"
arch/x86/include/asm/irq_stack.h +1 -1
index 735c3a491f60..8325b79f2ac6 100644
@@ -101,7 +101,7 @@
 
 #define ASM_CALL_ARG0							\
 	"1: call %c[__func]				\n"		\
-	ANNOTATE_REACHABLE(1b)
+	ANNOTATE_REACHABLE(1b) "			\n"
 
 #define ASM_CALL_ARG1							\
 	"movq	%[arg1], %%rdi				\n"		\
arch/x86/include/asm/jump_label.h +1 -1
index e0a6930a4029..05b16299588d 100644
@@ -15,7 +15,7 @@
 #define JUMP_TABLE_ENTRY(key, label)			\
 	".pushsection __jump_table,  \"aw\" \n\t"	\
 	_ASM_ALIGN "\n\t"				\
-	ANNOTATE_DATA_SPECIAL				\
+	ANNOTATE_DATA_SPECIAL "\n"			\
 	".long 1b - . \n\t"				\
 	".long " label " - . \n\t"			\
 	_ASM_PTR " " key " - . \n\t"			\
arch/x86/include/asm/nospec-branch.h +2 -2
index 08ed5a2e46a5..a5d41d8cd70a 100644
@@ -464,7 +464,7 @@ static inline void call_depth_return_thunk(void) {}
  */
 # define CALL_NOSPEC						\
 	ALTERNATIVE_2(						\
-	ANNOTATE_RETPOLINE_SAFE					\
+	ANNOTATE_RETPOLINE_SAFE "\n"				\
 	"call *%[thunk_target]\n",				\
 	"       jmp    904f;\n"					\
 	"       .align 16\n"					\
@@ -480,7 +480,7 @@ static inline void call_depth_return_thunk(void) {}
 	"904:	call   901b;\n",				\
 	X86_FEATURE_RETPOLINE,					\
 	"lfence;\n"						\
-	ANNOTATE_RETPOLINE_SAFE					\
+	ANNOTATE_RETPOLINE_SAFE "\n"				\
 	"call *%[thunk_target]\n",				\
 	X86_FEATURE_RETPOLINE_LFENCE)
 
arch/x86/include/asm/paravirt_types.h +1 -1
index 37a8627d8277..3502939415ad 100644
@@ -249,7 +249,7 @@ extern struct paravirt_patch_template pv_ops;
  * don't need to bother with CFI prefixes.
  */
 #define PARAVIRT_CALL					\
-	ANNOTATE_RETPOLINE_SAFE				\
+	ANNOTATE_RETPOLINE_SAFE "\n\t"			\
 	"call *%[paravirt_opptr];"
 
 /*
arch/x86/include/asm/smap.h +4 -4
index 4f84d421d1cf..cd173facecd2 100644
@@ -40,7 +40,7 @@ static __always_inline unsigned long smap_save(void)
 	unsigned long flags;
 
 	asm volatile ("# smap_save\n\t"
-		      ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE
+		      ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE "\n\t"
 				  "", "pushf; pop %0; clac",
 				  X86_FEATURE_SMAP)
 		      : "=rm" (flags) : : "memory", "cc");
@@ -51,7 +51,7 @@ static __always_inline unsigned long smap_save(void)
 static __always_inline void smap_restore(unsigned long flags)
 {
 	asm volatile ("# smap_restore\n\t"
-		      ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE
+		      ALTERNATIVE(ANNOTATE_IGNORE_ALTERNATIVE "\n\t"
 				  "", "push %0; popf",
 				  X86_FEATURE_SMAP)
 		      : : "g" (flags) : "memory", "cc");
@@ -64,9 +64,9 @@ static __always_inline void smap_restore(unsigned long flags)
 	ALTERNATIVE("", "stac", X86_FEATURE_SMAP)
 
 #define ASM_CLAC_UNSAFE \
-	ALTERNATIVE("", ANNOTATE_IGNORE_ALTERNATIVE "clac", X86_FEATURE_SMAP)
+	ALTERNATIVE("", ANNOTATE_IGNORE_ALTERNATIVE "\n\t" "clac", X86_FEATURE_SMAP)
 #define ASM_STAC_UNSAFE \
-	ALTERNATIVE("", ANNOTATE_IGNORE_ALTERNATIVE "stac", X86_FEATURE_SMAP)
+	ALTERNATIVE("", ANNOTATE_IGNORE_ALTERNATIVE "\n\t" "stac", X86_FEATURE_SMAP)
 
 #endif /* __ASSEMBLER__ */
 
arch/x86/include/asm/static_call.h +1 -1
index 41502bd2afd6..4cd725a8fe91 100644
@@ -36,7 +36,7 @@
 	    ".align 4						\n"	\
 	    ".globl " STATIC_CALL_TRAMP_STR(name) "		\n"	\
 	    STATIC_CALL_TRAMP_STR(name) ":			\n"	\
-	    ANNOTATE_NOENDBR						\
+	    ANNOTATE_NOENDBR "					\n"	\
 	    insns "						\n"	\
 	    ".byte 0x0f, 0xb9, 0xcc				\n"	\
 	    ".type " STATIC_CALL_TRAMP_STR(name) ", @function	\n"	\
arch/x86/kernel/alternative.c +2 -2
index d19a3fd7cf04..ddde9c33d974 100644
@@ -2250,7 +2250,7 @@ asm (
 "	.pushsection	.init.text, \"ax\", @progbits\n"
 "	.type		int3_selftest_asm, @function\n"
 "int3_selftest_asm:\n"
-	ANNOTATE_NOENDBR
+	ANNOTATE_NOENDBR "\n"
 	/*
 	 * INT3 padded with NOP to CALL_INSN_SIZE. The INT3 triggers an
 	 * exception, then the int3_exception_nb notifier emulates a call to
@@ -2268,7 +2268,7 @@ asm (
 "	.pushsection	.init.text, \"ax\", @progbits\n"
 "	.type		int3_selftest_callee, @function\n"
 "int3_selftest_callee:\n"
-	ANNOTATE_NOENDBR
+	ANNOTATE_NOENDBR "\n"
 "	movl	$0x1234, (%" _ASM_ARG1 ")\n"
 	ASM_RET
 "	.size		int3_selftest_callee, . - int3_selftest_callee\n"
arch/x86/kernel/rethook.c +1 -1
index 8a1c0111ae79..85e2f2d16a90 100644
@@ -25,7 +25,7 @@ asm(
 	".type arch_rethook_trampoline, @function\n"
 	"arch_rethook_trampoline:\n"
 #ifdef CONFIG_X86_64
-	ANNOTATE_NOENDBR	/* This is only jumped from ret instruction */
+	ANNOTATE_NOENDBR "\n"	/* This is only jumped from ret instruction */
 	/* Push a fake return address to tell the unwinder it's a rethook. */
 	"	pushq $arch_rethook_trampoline\n"
 	UNWIND_HINT_FUNC
arch/x86/kernel/static_call.c +2 -2
index 378c388d1b31..66ca75301891 100644
@@ -45,8 +45,8 @@ asm (".global __static_call_return\n\t"
      ".type __static_call_return, @function\n\t"
      ASM_FUNC_ALIGN "\n\t"
      "__static_call_return:\n\t"
-     ANNOTATE_NOENDBR
-     ANNOTATE_RETPOLINE_SAFE
+     ANNOTATE_NOENDBR "\n\t"
+     ANNOTATE_RETPOLINE_SAFE "\n\t"
      "ret; int3\n\t"
      ".size __static_call_return, . - __static_call_return \n\t");
 
arch/x86/lib/error-inject.c +1 -1
index b5a6d83106bc..512a2538596f 100644
@@ -13,7 +13,7 @@ asm(
 	".globl just_return_func\n"
 	ASM_FUNC_ALIGN
 	"just_return_func:\n"
-		ANNOTATE_NOENDBR
+		ANNOTATE_NOENDBR "\n"
 		ASM_RET
 	".size just_return_func, .-just_return_func\n"
 );
include/linux/annotate.h +3 -3
index 996126f5f9ec..5efac5d4f9cf 100644
@@ -15,15 +15,15 @@
 #ifndef __ASSEMBLY__
 
 #define ASM_ANNOTATE_LABEL(label, type)					\
-	__stringify(__ASM_ANNOTATE(".discard.annotate_insn", label, type)) "\n\t"
+	__stringify(__ASM_ANNOTATE(".discard.annotate_insn", label, type))
 
 #define ASM_ANNOTATE(type)						\
 	"911: "								\
-	__stringify(__ASM_ANNOTATE(".discard.annotate_insn", 911b, type)) "\n\t"
+	__stringify(__ASM_ANNOTATE(".discard.annotate_insn", 911b, type))
 
 #define ASM_ANNOTATE_DATA(type)						\
 	"912: "								\
-	__stringify(__ASM_ANNOTATE(".discard.annotate_data", 912b, type)) "\n\t"
+	__stringify(__ASM_ANNOTATE(".discard.annotate_data", 912b, type))
 
 #else /* __ASSEMBLY__ */
 
include/linux/objtool.h +1 -1
index b18ab53561c9..9a00e701454c 100644
@@ -12,7 +12,7 @@
 #define UNWIND_HINT(type, sp_reg, sp_offset, signal)		\
 	"987: \n\t"						\
 	".pushsection .discard.unwind_hints\n\t"		\
-	ANNOTATE_DATA_SPECIAL					\
+	ANNOTATE_DATA_SPECIAL "\n\t"				\
 	/* struct unwind_hint */				\
 	".long 987b - .\n\t"					\
 	".short " __stringify(sp_offset) "\n\t"			\
Signature · 1 line
2.51.1
maintainer
#5 lore raw
In reply to Josh Poimboeuf
Quoted 11 lines · Josh Poimboeuf

For tip/objtool/core.

As much as possible, undo the code generation damage introduced by ANNOTATE_DATA_SPECIAL:

- Remove its usage in favor of SHF_MERGE + sh_entsize, where possible

- Print the annotation on a single line:

      912: .pushsection ".discard.annotate_data", "M", @progbits, 8; .long 912b - .; .long 1; .popsection
Quoted 8 lines

- Remove the trailing newline/tab; let the invoking code decide on the appropriate separator for the given context

Josh Poimboeuf (4):
x86/alternative: Remove ANNOTATE_DATA_SPECIAL usage x86/asm: Remove ANNOTATE_DATA_SPECIAL usage
objtool: Consolidate annotation macros
objtool: Remove newlines and tabs from annotation macros

Durr, this will conflict with tip/core/bugs. Let me ponder this a bit.

#6 lore raw
Quoted 15 lines · Peter Zijlstra
Quoted 14 lines · Josh Poimboeuf

For tip/objtool/core.

As much as possible, undo the code generation damage introduced by ANNOTATE_DATA_SPECIAL:

- Remove its usage in favor of SHF_MERGE + sh_entsize, where possible

- Print the annotation on a single line:

      912: .pushsection ".discard.annotate_data", "M", @progbits, 8; .long 912b - .; .long 1; .popsection

- Remove the trailing newline/tab; let the invoking code decide on the appropriate separator for the given context

Quoted 7 lines
Quoted 5 lines

Josh Poimboeuf (4):
x86/alternative: Remove ANNOTATE_DATA_SPECIAL usage x86/asm: Remove ANNOTATE_DATA_SPECIAL usage
objtool: Consolidate annotation macros
objtool: Remove newlines and tabs from annotation macros

Durr, this will conflict with tip/core/bugs. Let me ponder this a bit.

So Josh has resolved these conflicts based on latest -git which has all these moving pieces integrated into a single tree, so I've applied these fixes to tip:objtool/urgent.

Thanks,

Ingo