Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

objtool: Consolidate annotation macros

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.

Turn this:

911:
.pushsection .discard.annotate_insn,"M", @progbits, 8
.long 911b - .
.long 1
.popsection
jmp __x86_return_thunk

Into:

911: .pushsection ".discard.annotate_insn", "M", @progbits, 8; .long 911b - .; .long 1; .popsection
jmp __x86_return_thunk

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://patch.msgid.link/c05ff40d3383e85c3b59018ef0b3c7aaf993a60d.1764694625.git.jpoimboe@kernel.org

authored by

Josh Poimboeuf and committed by
Ingo Molnar
305c8dc4 f387d0e1

+15 -21
+15 -21
include/linux/annotate.h
··· 6 6 7 7 #ifdef CONFIG_OBJTOOL 8 8 9 + #define __ASM_ANNOTATE(section, label, type) \ 10 + .pushsection section, "M", @progbits, 8; \ 11 + .long label - .; \ 12 + .long type; \ 13 + .popsection 14 + 9 15 #ifndef __ASSEMBLY__ 10 16 11 - #define __ASM_ANNOTATE(section, label, type) \ 12 - ".pushsection " section ",\"M\", @progbits, 8\n\t" \ 13 - ".long " __stringify(label) " - .\n\t" \ 14 - ".long " __stringify(type) "\n\t" \ 15 - ".popsection\n\t" 16 - 17 17 #define ASM_ANNOTATE_LABEL(label, type) \ 18 - __ASM_ANNOTATE(".discard.annotate_insn", label, type) 18 + __stringify(__ASM_ANNOTATE(".discard.annotate_insn", label, type)) "\n\t" 19 19 20 20 #define ASM_ANNOTATE(type) \ 21 - "911:\n\t" \ 22 - ASM_ANNOTATE_LABEL(911b, type) 21 + "911: " \ 22 + __stringify(__ASM_ANNOTATE(".discard.annotate_insn", 911b, type)) "\n\t" 23 23 24 24 #define ASM_ANNOTATE_DATA(type) \ 25 - "912:\n\t" \ 26 - __ASM_ANNOTATE(".discard.annotate_data", 912b, type) 25 + "912: " \ 26 + __stringify(__ASM_ANNOTATE(".discard.annotate_data", 912b, type)) "\n\t" 27 27 28 28 #else /* __ASSEMBLY__ */ 29 29 30 - .macro __ANNOTATE section, type 31 - .Lhere_\@: 32 - .pushsection \section, "M", @progbits, 8 33 - .long .Lhere_\@ - . 34 - .long \type 35 - .popsection 36 - .endm 37 - 38 30 .macro ANNOTATE type 39 - __ANNOTATE ".discard.annotate_insn", \type 31 + .Lhere_\@: 32 + __ASM_ANNOTATE(".discard.annotate_insn", .Lhere_\@, \type) 40 33 .endm 41 34 42 35 .macro ANNOTATE_DATA type 43 - __ANNOTATE ".discard.annotate_data", \type 36 + .Lhere_\@: 37 + __ASM_ANNOTATE(".discard.annotate_data", .Lhere_\@, \type) 44 38 .endm 45 39 46 40 #endif /* __ASSEMBLY__ */