Re: [PATCH] compiler/gcc: Make asm() templates asm __inline__() by default
From: Josh Poimboeuf
Date: Tue Mar 18 2025 - 18:10:13 EST
On Tue, Mar 18, 2025 at 09:11:40PM +0100, Ingo Molnar wrote:
> #ifdef CONFIG_CC_HAS_ASM_INLINE
> # define asm_inline __asm__ __inline
> # define asm(...) asm_inline(__VA_ARGS__)
> #else
> # define asm_inline asm
> #endif
Nice, I'd been wanting to do that for a while.
> And I fixed up the places where this isn't syntactically correct:
>
> 35 files changed, 82 insertions(+), 79 deletions(-)
>
> I haven't looked at code generation much yet, but text size changes are
> minimal:
>
> text data bss dec hex filename
> 29429076 7931870 1401196 38762142 24f769e vmlinux.before
> 29429631 7931870 1401200 38762701 24f78cd vmlinux.after
>
> Which is promising, assuming I haven't messed up anywhere.
Unfortunately "size" can be misleading:
- Inexplicably, "text" includes a lot of non-executable sections, many
of which have sizes which are directly affected by actual .text
changes.
- CONFIG_MITIGATION_SRSO adds ~2MB padding between entry code and the
rest of the runtime text, though this is not much of a concern for
comparing apples to apples as it only hides the size of the entry
text which is tiny.
This was discussed before (and yes "objtool size" would be nice
someday).
https://lore.kernel.org/20231012013507.jrqnm35p7az6atov@treble
I think this should work decently enough:
$ readelf -WS vmlinux | grep " .text" | sed 's/\[ //' | awk '{printf("0x%s\n", $6)}'
0x5588b08
--
Josh