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

Reply via email to