On Thu, Sep 04, 2025 at 10:38:45PM +0000, Dylan Hatch wrote:
> Use the -Wa,--gsframe flags to build the code, so GAS will generate
> a new .sframe section for the stack trace information.
> Currently, the sframe format only supports arm64 and x86_64
> architectures. Add this configuration on arm64 to enable sframe
> unwinder in the future.
> 
> Signed-off-by: Weinan Liu <[email protected]>
> Signed-off-by: Dylan Hatch <[email protected]>
> Reviewed-by: Prasanna Kumar T S M <[email protected]>
> ---
>  Makefile                          |  8 ++++++++
>  arch/Kconfig                      |  6 ++++++
>  arch/arm64/Kconfig.debug          | 10 ++++++++++
>  arch/arm64/kernel/vdso/Makefile   |  2 +-
>  include/asm-generic/vmlinux.lds.h | 15 +++++++++++++++
>  5 files changed, 40 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index b9c661913250..09972c71a3e8 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1078,6 +1078,14 @@ endif
>  # Ensure compilers do not transform certain loops into calls to wcslen()
>  KBUILD_CFLAGS += -fno-builtin-wcslen
>  
> +# build with sframe table
> +ifdef CONFIG_SFRAME_UNWIND_TABLE
> +CC_FLAGS_SFRAME := -Wa,--gsframe
> +KBUILD_CFLAGS        += $(CC_FLAGS_SFRAME)
> +KBUILD_AFLAGS        += $(CC_FLAGS_SFRAME)
> +export CC_FLAGS_SFRAME
> +endif
> +
>  # change __FILE__ to the relative path to the source directory
>  ifdef building_out_of_srctree
>  KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srcroot)/=)
> diff --git a/arch/Kconfig b/arch/Kconfig
> index d1b4ffd6e085..4362d2f49d91 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -1782,4 +1782,10 @@ config ARCH_WANTS_PRE_LINK_VMLINUX
>  config ARCH_HAS_CPU_ATTACK_VECTORS
>       bool
>  
> +config AS_SFRAME
> +     def_bool $(as-instr,.cfi_sections .sframe\n.cfi_startproc\n.cfi_endproc)

Is it possible to extend this check so that we reject assemblers that
emit the unsupported "sframe version one" format?

> +config SFRAME_UNWIND_TABLE
> +     bool

Is this extra option actually needed for anything?

>  endmenu
> diff --git a/arch/arm64/Kconfig.debug b/arch/arm64/Kconfig.debug
> index 265c4461031f..d64bf58457de 100644
> --- a/arch/arm64/Kconfig.debug
> +++ b/arch/arm64/Kconfig.debug
> @@ -20,4 +20,14 @@ config ARM64_RELOC_TEST
>       depends on m
>       tristate "Relocation testing module"
>  
> +config SFRAME_UNWINDER
> +     bool "Sframe unwinder"
> +     depends on AS_SFRAME
> +     depends on 64BIT

Shouldn't there be an arch dependency here as well? Since architectures
need to make use of sframe in their unwinders, I was expecting something
like 'depends on ARCH_SUPPORTS_SFRAME_UNWINDER' here.

Will

Reply via email to