lkml.org 
[lkml]   [2019]   [Feb]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/6] objtool: Replace STACK_FRAME_NON_STANDARD annotation
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) <peterz@infradead.org>
> ---
> 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

\
 
 \ /
  Last update: 2019-02-25 17:12    [W:0.184 / U:1.852 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site