> -----Original Message-----
> From: Matheus Bernardino (QUIC) <quic_mathb...@quicinc.com>
> Sent: Tuesday, April 2, 2024 2:56 PM
> To: elfutils-devel@sourceware.org
> Cc: Brian Cain <bc...@quicinc.com>; Sid Manning <sidn...@quicinc.com>;
> m...@klomp.org; Andrew Pinski (QUIC) <quic_apin...@quicinc.com>;
> Matheus Bernardino (QUIC) <quic_mathb...@quicinc.com>
> Subject: [PATCH v2 2/2] Hexagon: implement machine flag check
> 
> This fixes the "invalid machine flag" error from eu-elflint when passing
> hexagon binaries.
> 
> Signed-off-by: Matheus Tavares Bernardino <quic_mathb...@quicinc.com>
> ---
>  backends/hexagon_init.c   | 1 +
>  backends/hexagon_symbol.c | 8 ++++++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/backends/hexagon_init.c b/backends/hexagon_init.c
> index 9c8c6d8d..1cd27513 100644
> --- a/backends/hexagon_init.c
> +++ b/backends/hexagon_init.c
> @@ -45,6 +45,7 @@ hexagon_init (Elf *elf __attribute__ ((unused)),
>  {
>    hexagon_init_reloc (eh);
>    HOOK (eh, reloc_simple_type);
> +  HOOK (eh, machine_flag_check);
> 
>    return eh;
>  }
> diff --git a/backends/hexagon_symbol.c b/backends/hexagon_symbol.c
> index b341243e..1e681e9f 100644
> --- a/backends/hexagon_symbol.c
> +++ b/backends/hexagon_symbol.c
> @@ -56,3 +56,11 @@ hexagon_reloc_simple_type (Ebl *ebl __attribute__
> ((unused)), int type,
>        return ELF_T_NUM;
>      }
>  }
> +
> +bool
> +hexagon_machine_flag_check (GElf_Word flags)
> +{
> +  GElf_Word arch_variant = flags &~ EF_HEXAGON_MACH;
> +  /* 0x8000 covers the "tiny core" arch variants. */
> +  return arch_variant == 0 || arch_variant == 0x8000;
> +}
> --
> 2.37.2

What about this instead?

bool hexagon_machine_flag_check(GElf_Word flags) {
        GElf_Word reserved_flags = ~(EF_HEXAGON_TINY | EF_HEXAGON_MACH);

        return (flags & reserved_flags) == 0;
}

... implies a new EF_HEXAGON_TINY 0x8000 definition BTW.

Reply via email to