On Mon, Feb 25, 2019 at 01:43:34PM +0100, Peter Zijlstra wrote:
> Replace the existing STACK_FRAME_NON_STANDARD annotation with a
> 'better' scheme.
> 
> The old annotation works by taking the address of a function; this
> is visible to the compiler and might affect code generation (the
> function pointer escapes). The new annotation simply stores the
> function name and has objtool do a symtab lookup.
> 
> Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
> ---
>  include/linux/frame.h |   19 +++++++++++++---
>  tools/objtool/check.c |   58 
> +++++++++++++++++++++-----------------------------
>  tools/objtool/check.h |    1 
>  3 files changed, 41 insertions(+), 37 deletions(-)
> 
> --- a/include/linux/frame.h
> +++ b/include/linux/frame.h
> @@ -11,9 +11,22 @@
>   *
>   * For more information, see 
> tools/objtool/Documentation/stack-validation.txt.
>   */
> -#define STACK_FRAME_NON_STANDARD(func) \
> -     static void __used __section(.discard.func_stack_frame_non_standard) \
> -             *__func_stack_frame_non_standard_##func = func
> +#define STACK_FRAME_NON_STANDARD(func)                                       
> \
> +     asm (".pushsection .discard.nonstd_frame_strtab, \"S\", @3\n\t" \
> +          "999: .ascii \"" #func "\"\n\t"                            \
> +          "     .byte 0\n\t"                                         \
> +          ".popsection\n\t"                                          \
> +          ".pushsection .discard.nonstd_frame\n\t"                   \
> +          ".long 999b - .\n\t"                                       \
> +          ".popsection\n\t")
> +

I don't think this will work in the case where GCC does an IPA
optimization and renames the function (e.g., renames func to
func.isra.1234), right?  That might be a deal breaker...

> +/*
> + * SHT_STRTAB(@3) sections should start with a \0 byte such that the 0 offset
> + * encodes the NULL string.
> + */
> +asm (".pushsection .discard.nonstd_frame_strtab, \"S\", @3\n\t"
> +     ".byte 0\n\t"
> +     ".popsection\n\t");

Including the file creates the section, which is a bit nasty.  Instead
just change STACK_FRAME_NON_STANDARD to prefix every string with a \0?

-- 
Josh

Reply via email to