On Wed, Dec 9, 2020 at 9:21 AM Christoph Müllner
<christoph.muell...@theobroma-systems.com> wrote:
>
> From: Christoph Muellner <christoph.muell...@theobroma-systems.com>
>
> It is possible to call aarch64_declare_function_name() and
> have cfun not set. Let's sanitize the access to this variable.
>
> gcc/
>
>     * config/aarch64/aarch64.c (aarch64_declare_function_name):
>     Santize access to cfun.
> ---
>  gcc/config/aarch64/aarch64.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
> index 67ffba02d3e..264ccb8beb2 100644
> --- a/gcc/config/aarch64/aarch64.c
> +++ b/gcc/config/aarch64/aarch64.c
> @@ -19317,7 +19317,8 @@ aarch64_declare_function_name (FILE *stream, const 
> char* name,
>    ASM_OUTPUT_TYPE_DIRECTIVE (stream, name, "function");
>    ASM_OUTPUT_LABEL (stream, name);
>
> -  cfun->machine->label_is_assembled = true;
> +  if (cfun)
> +    cfun->machine->label_is_assembled = true;
>  }


Hmm, looking through the usage of ASM_DECLARE_FUNCTION_NAME, cfun has
to be set, and usually that is set when current_function_decl is also
set.
Can you figure out why cfun is not set but current_function_decl is set?

Thanks,
Andrew Pinski

>
>  /* Implement PRINT_PATCHABLE_FUNCTION_ENTRY.  Check if the patch area is 
> after
> --
> 2.29.2
>

Reply via email to