* [PATCH 0/2] Add initial support for Hexagon
@ 2024-03-21 21:09 Matheus Tavares Bernardino
2024-03-21 21:09 ` [PATCH 1/2] Add " Matheus Tavares Bernardino
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Matheus Tavares Bernardino @ 2024-03-21 21:09 UTC (permalink / raw)
To: elfutils-devel; +Cc: bcain, sidneym, mark
The patches were inspired by
https://sourceware.org/cgit/elfutils/commit?id=13a4d1279c5b7847049ca3045d04f2705c45ce31
Related to:
https://lore.kernel.org/all/6498586d7d0ed112e6c44be98d439abc549653c7.camel@klomp.org/t/#u
Matheus Tavares Bernardino (2):
Add support for Hexagon
Hexagon: implement machine flag check
backends/Makefile.am | 6 +-
backends/hexagon_init.c | 52 +++++++++++++++
backends/hexagon_reloc.def | 130 ++++++++++++++++++++++++++++++++++++
backends/hexagon_symbol.c | 66 +++++++++++++++++++
libebl/eblopenbackend.c | 2 +
libelf/elf.h | 131 +++++++++++++++++++++++++++++++++++++
src/elflint.c | 2 +-
7 files changed, 386 insertions(+), 3 deletions(-)
create mode 100644 backends/hexagon_init.c
create mode 100644 backends/hexagon_reloc.def
create mode 100644 backends/hexagon_symbol.c
--
2.37.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] Add support for Hexagon
2024-03-21 21:09 [PATCH 0/2] Add initial support for Hexagon Matheus Tavares Bernardino
@ 2024-03-21 21:09 ` Matheus Tavares Bernardino
2024-03-21 21:09 ` [PATCH 2/2] Hexagon: implement machine flag check Matheus Tavares Bernardino
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Matheus Tavares Bernardino @ 2024-03-21 21:09 UTC (permalink / raw)
To: elfutils-devel; +Cc: bcain, sidneym, mark
This implements initial support for the Hexagon architecture.
Signed-off-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com>
---
backends/Makefile.am | 6 +-
backends/hexagon_init.c | 51 +++++++++++++++
backends/hexagon_reloc.def | 130 ++++++++++++++++++++++++++++++++++++
backends/hexagon_symbol.c | 58 ++++++++++++++++
libebl/eblopenbackend.c | 2 +
libelf/elf.h | 131 +++++++++++++++++++++++++++++++++++++
src/elflint.c | 2 +-
7 files changed, 377 insertions(+), 3 deletions(-)
create mode 100644 backends/hexagon_init.c
create mode 100644 backends/hexagon_reloc.def
create mode 100644 backends/hexagon_symbol.c
diff --git a/backends/Makefile.am b/backends/Makefile.am
index bbb2aac7..271c0eab 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -37,7 +37,7 @@ AM_CPPFLAGS += -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \
noinst_LIBRARIES = libebl_backends.a libebl_backends_pic.a
modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \
- m68k bpf riscv csky loongarch arc
+ m68k bpf riscv csky loongarch arc hexagon
i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \
i386_retval.c i386_regs.c i386_auxv.c \
@@ -102,12 +102,14 @@ loongarch_SRCS = loongarch_init.c loongarch_symbol.c loongarch_cfi.c \
arc_SRCS = arc_init.c arc_symbol.c
+hexagon_SRCS = hexagon_init.c hexagon_symbol.c
+
libebl_backends_a_SOURCES = $(i386_SRCS) $(sh_SRCS) $(x86_64_SRCS) \
$(ia64_SRCS) $(alpha_SRCS) $(arm_SRCS) \
$(aarch64_SRCS) $(sparc_SRCS) $(ppc_SRCS) \
$(ppc64_SRCS) $(s390_SRCS) \
$(m68k_SRCS) $(bpf_SRCS) $(riscv_SRCS) $(csky_SRCS) \
- $(loongarch_SRCS) $(arc_SRCS)
+ $(loongarch_SRCS) $(arc_SRCS) $(hexagon_SRCS)
libebl_backends_pic_a_SOURCES =
am_libebl_backends_pic_a_OBJECTS = $(libebl_backends_a_SOURCES:.c=.os)
diff --git a/backends/hexagon_init.c b/backends/hexagon_init.c
new file mode 100644
index 00000000..9c8c6d8d
--- /dev/null
+++ b/backends/hexagon_init.c
@@ -0,0 +1,51 @@
+/* Initialization of Hexagon specific backend library.
+ Copyright (C) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ This file is part of elfutils.
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#define BACKEND hexagon_
+#define RELOC_PREFIX R_HEX_
+#include "libebl_CPU.h"
+
+/* This defines the common reloc hooks based on hexagon_reloc.def. */
+#include "common-reloc.c"
+
+
+Ebl *
+hexagon_init (Elf *elf __attribute__ ((unused)),
+ GElf_Half machine __attribute__ ((unused)),
+ Ebl *eh)
+{
+ hexagon_init_reloc (eh);
+ HOOK (eh, reloc_simple_type);
+
+ return eh;
+}
+
diff --git a/backends/hexagon_reloc.def b/backends/hexagon_reloc.def
new file mode 100644
index 00000000..cd55d374
--- /dev/null
+++ b/backends/hexagon_reloc.def
@@ -0,0 +1,130 @@
+/* List the relocation types for Hexagon. -*- C -*-
+ Copyright (C) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ This file is part of elfutils.
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+/* NAME, REL|EXEC|DYN */
+
+RELOC_TYPE (NONE, 0)
+RELOC_TYPE (B22_PCREL, REL)
+RELOC_TYPE (B15_PCREL, REL)
+RELOC_TYPE (B7_PCREL, REL)
+RELOC_TYPE (LO16, REL)
+RELOC_TYPE (HI16, REL)
+RELOC_TYPE (32, REL)
+RELOC_TYPE (16, REL)
+RELOC_TYPE (8, REL)
+RELOC_TYPE (GPREL16_0, REL)
+RELOC_TYPE (GPREL16_1, REL)
+RELOC_TYPE (GPREL16_2, REL)
+RELOC_TYPE (GPREL16_3, REL)
+RELOC_TYPE (HL16, REL)
+RELOC_TYPE (B13_PCREL, REL)
+RELOC_TYPE (B9_PCREL, REL)
+RELOC_TYPE (B32_PCREL_X, REL)
+RELOC_TYPE (32_6_X, REL)
+RELOC_TYPE (B22_PCREL_X, REL)
+RELOC_TYPE (B15_PCREL_X, REL)
+RELOC_TYPE (B13_PCREL_X, REL)
+RELOC_TYPE (B9_PCREL_X, REL)
+RELOC_TYPE (B7_PCREL_X, REL)
+RELOC_TYPE (16_X, REL)
+RELOC_TYPE (12_X, REL)
+RELOC_TYPE (11_X, REL)
+RELOC_TYPE (10_X, REL)
+RELOC_TYPE (9_X, REL)
+RELOC_TYPE (8_X, REL)
+RELOC_TYPE (7_X, REL)
+RELOC_TYPE (6_X, REL)
+RELOC_TYPE (32_PCREL, REL)
+RELOC_TYPE (COPY, REL)
+RELOC_TYPE (GLOB_DAT, REL)
+RELOC_TYPE (JMP_SLOT, REL)
+RELOC_TYPE (RELATIVE, REL)
+RELOC_TYPE (PLT_B22_PCREL, REL)
+RELOC_TYPE (GOTREL_LO16, REL)
+RELOC_TYPE (GOTREL_HI16, REL)
+RELOC_TYPE (GOTREL_32, REL)
+RELOC_TYPE (GOT_LO16, REL)
+RELOC_TYPE (GOT_HI16, REL)
+RELOC_TYPE (GOT_32, REL)
+RELOC_TYPE (GOT_16, REL)
+RELOC_TYPE (DTPMOD_32, REL)
+RELOC_TYPE (DTPREL_LO16, REL)
+RELOC_TYPE (DTPREL_HI16, REL)
+RELOC_TYPE (DTPREL_32, REL)
+RELOC_TYPE (DTPREL_16, REL)
+RELOC_TYPE (GD_PLT_B22_PCREL, REL)
+RELOC_TYPE (GD_GOT_LO16, REL)
+RELOC_TYPE (GD_GOT_HI16, REL)
+RELOC_TYPE (GD_GOT_32, REL)
+RELOC_TYPE (GD_GOT_16, REL)
+RELOC_TYPE (IE_LO16, REL)
+RELOC_TYPE (IE_HI16, REL)
+RELOC_TYPE (IE_32, REL)
+RELOC_TYPE (IE_GOT_LO16, REL)
+RELOC_TYPE (IE_GOT_HI16, REL)
+RELOC_TYPE (IE_GOT_32, REL)
+RELOC_TYPE (IE_GOT_16, REL)
+RELOC_TYPE (TPREL_LO16, REL)
+RELOC_TYPE (TPREL_HI16, REL)
+RELOC_TYPE (TPREL_32, REL)
+RELOC_TYPE (TPREL_16, REL)
+RELOC_TYPE (6_PCREL_X, REL)
+RELOC_TYPE (GOTREL_32_6_X, REL)
+RELOC_TYPE (GOTREL_16_X, REL)
+RELOC_TYPE (GOTREL_11_X, REL)
+RELOC_TYPE (GOT_32_6_X, REL)
+RELOC_TYPE (GOT_16_X, REL)
+RELOC_TYPE (GOT_11_X, REL)
+RELOC_TYPE (DTPREL_32_6_X, REL)
+RELOC_TYPE (DTPREL_16_X, REL)
+RELOC_TYPE (DTPREL_11_X, REL)
+RELOC_TYPE (GD_GOT_32_6_X, REL)
+RELOC_TYPE (GD_GOT_16_X, REL)
+RELOC_TYPE (GD_GOT_11_X, REL)
+RELOC_TYPE (IE_32_6_X, REL)
+RELOC_TYPE (IE_16_X, REL)
+RELOC_TYPE (IE_GOT_32_6_X, REL)
+RELOC_TYPE (IE_GOT_16_X, REL)
+RELOC_TYPE (IE_GOT_11_X, REL)
+RELOC_TYPE (TPREL_32_6_X, REL)
+RELOC_TYPE (TPREL_16_X, REL)
+RELOC_TYPE (TPREL_11_X, REL)
+RELOC_TYPE (LD_PLT_B22_PCREL, REL)
+RELOC_TYPE (LD_GOT_LO16, REL)
+RELOC_TYPE (LD_GOT_HI16, REL)
+RELOC_TYPE (LD_GOT_32, REL)
+RELOC_TYPE (LD_GOT_16, REL)
+RELOC_TYPE (LD_GOT_32_6_X, REL)
+RELOC_TYPE (LD_GOT_16_X, REL)
+RELOC_TYPE (LD_GOT_11_X, REL)
+RELOC_TYPE (23_REG, REL)
+RELOC_TYPE (GD_PLT_B22_PCREL_X, REL)
+RELOC_TYPE (GD_PLT_B32_PCREL_X, REL)
+RELOC_TYPE (LD_PLT_B22_PCREL_X, REL)
+RELOC_TYPE (LD_PLT_B32_PCREL_X, REL)
+RELOC_TYPE (27_REG, REL)
diff --git a/backends/hexagon_symbol.c b/backends/hexagon_symbol.c
new file mode 100644
index 00000000..b341243e
--- /dev/null
+++ b/backends/hexagon_symbol.c
@@ -0,0 +1,58 @@
+/* Hexagon specific symbolic name handling.
+ Copyright (C) 2024 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ This file is part of elfutils.
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <assert.h>
+#include <elf.h>
+#include <stddef.h>
+#include <string.h>
+
+#define BACKEND hexagon_
+#include "libebl_CPU.h"
+
+
+/* Check for the simple reloc types. */
+Elf_Type
+hexagon_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type,
+ int *addsub __attribute__ ((unused)))
+{
+ switch (type)
+ {
+ case R_HEX_32:
+ return ELF_T_WORD;
+ case R_HEX_16:
+ return ELF_T_HALF;
+ case R_HEX_8:
+ return ELF_T_BYTE;
+ default:
+ return ELF_T_NUM;
+ }
+}
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index 084a1544..f67e4536 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -57,6 +57,7 @@ Ebl *riscv_init (Elf *, GElf_Half, Ebl *);
Ebl *csky_init (Elf *, GElf_Half, Ebl *);
Ebl *loongarch_init (Elf *, GElf_Half, Ebl *);
Ebl *arc_init (Elf *, GElf_Half, Ebl *);
+Ebl *hexagon_init (Elf *, GElf_Half, Ebl *);
/* This table should contain the complete list of architectures as far
as the ELF specification is concerned. */
@@ -154,6 +155,7 @@ static const struct
{ csky_init, "elf_csky", "csky", 4, EM_CSKY, ELFCLASS32, ELFDATA2LSB },
{ loongarch_init, "elf_loongarch", "loongarch", 9, EM_LOONGARCH, ELFCLASS64, ELFDATA2LSB },
{ arc_init, "elf_arc", "arc", 3, EM_ARCV2, ELFCLASS32, ELFDATA2LSB },
+ { hexagon_init, "elf_hexagon", "hexagon", 9, EM_QDSP6, ELFCLASS32, ELFDATA2LSB },
};
#define nmachines (sizeof (machines) / sizeof (machines[0]))
diff --git a/libelf/elf.h b/libelf/elf.h
index f2206e5c..d69fb8fa 100644
--- a/libelf/elf.h
+++ b/libelf/elf.h
@@ -4474,4 +4474,135 @@ enum
#define R_OR1K_TLS_DTPOFF 33
#define R_OR1K_TLS_DTPMOD 34
+/* Hexagon specific declarations. */
+
+/* Processor specific flags for the Ehdr e_flags field. */
+#define EF_HEXAGON_MACH_V2 0x00000001 /* Hexagon V2 */
+#define EF_HEXAGON_MACH_V3 0x00000002 /* Hexagon V3 */
+#define EF_HEXAGON_MACH_V4 0x00000003 /* Hexagon V4 */
+#define EF_HEXAGON_MACH_V5 0x00000004 /* Hexagon V5 */
+#define EF_HEXAGON_MACH_V55 0x00000005 /* Hexagon V55 */
+#define EF_HEXAGON_MACH_V60 0x00000060 /* Hexagon V60 */
+#define EF_HEXAGON_MACH_V61 0x00000061 /* Hexagon V61 */
+#define EF_HEXAGON_MACH_V62 0x00000062 /* Hexagon V62 */
+#define EF_HEXAGON_MACH_V65 0x00000065 /* Hexagon V65 */
+#define EF_HEXAGON_MACH_V66 0x00000066 /* Hexagon V66 */
+#define EF_HEXAGON_MACH_V67 0x00000067 /* Hexagon V67 */
+#define EF_HEXAGON_MACH_V67T 0x00008067 /* Hexagon V67T */
+#define EF_HEXAGON_MACH_V68 0x00000068 /* Hexagon V68 */
+#define EF_HEXAGON_MACH_V69 0x00000069 /* Hexagon V68 */
+#define EF_HEXAGON_MACH_V71 0x00000071 /* Hexagon V71 */
+#define EF_HEXAGON_MACH_V71T 0x00008071 /* Hexagon V71T */
+#define EF_HEXAGON_MACH_V73 0x00000073 /* Hexagon V73 */
+#define EF_HEXAGON_MACH 0x000003ff /* Hexagon V.. */
+
+/* Special section indices. */
+#define SHN_HEXAGON_SCOMMON 0xff00 /* Other access sizes */
+#define SHN_HEXAGON_SCOMMON_1 0xff01 /* Byte-sized access */
+#define SHN_HEXAGON_SCOMMON_2 0xff02 /* Half-word-sized access */
+#define SHN_HEXAGON_SCOMMON_4 0xff03 /* Word-sized access */
+#define SHN_HEXAGON_SCOMMON_8 0xff04 /* Double-word-size access */
+
+/* Hexagon specific relocs. */
+#define R_HEX_NONE 0
+#define R_HEX_B22_PCREL 1
+#define R_HEX_B15_PCREL 2
+#define R_HEX_B7_PCREL 3
+#define R_HEX_LO16 4
+#define R_HEX_HI16 5
+#define R_HEX_32 6
+#define R_HEX_16 7
+#define R_HEX_8 8
+#define R_HEX_GPREL16_0 9
+#define R_HEX_GPREL16_1 10
+#define R_HEX_GPREL16_2 11
+#define R_HEX_GPREL16_3 12
+#define R_HEX_HL16 13
+#define R_HEX_B13_PCREL 14
+#define R_HEX_B9_PCREL 15
+#define R_HEX_B32_PCREL_X 16
+#define R_HEX_32_6_X 17
+#define R_HEX_B22_PCREL_X 18
+#define R_HEX_B15_PCREL_X 19
+#define R_HEX_B13_PCREL_X 20
+#define R_HEX_B9_PCREL_X 21
+#define R_HEX_B7_PCREL_X 22
+#define R_HEX_16_X 23
+#define R_HEX_12_X 24
+#define R_HEX_11_X 25
+#define R_HEX_10_X 26
+#define R_HEX_9_X 27
+#define R_HEX_8_X 28
+#define R_HEX_7_X 29
+#define R_HEX_6_X 30
+#define R_HEX_32_PCREL 31
+#define R_HEX_COPY 32
+#define R_HEX_GLOB_DAT 33
+#define R_HEX_JMP_SLOT 34
+#define R_HEX_RELATIVE 35
+#define R_HEX_PLT_B22_PCREL 36
+#define R_HEX_GOTREL_LO16 37
+#define R_HEX_GOTREL_HI16 38
+#define R_HEX_GOTREL_32 39
+#define R_HEX_GOT_LO16 40
+#define R_HEX_GOT_HI16 41
+#define R_HEX_GOT_32 42
+#define R_HEX_GOT_16 43
+#define R_HEX_DTPMOD_32 44
+#define R_HEX_DTPREL_LO16 45
+#define R_HEX_DTPREL_HI16 46
+#define R_HEX_DTPREL_32 47
+#define R_HEX_DTPREL_16 48
+#define R_HEX_GD_PLT_B22_PCREL 49
+#define R_HEX_GD_GOT_LO16 50
+#define R_HEX_GD_GOT_HI16 51
+#define R_HEX_GD_GOT_32 52
+#define R_HEX_GD_GOT_16 53
+#define R_HEX_IE_LO16 54
+#define R_HEX_IE_HI16 55
+#define R_HEX_IE_32 56
+#define R_HEX_IE_GOT_LO16 57
+#define R_HEX_IE_GOT_HI16 58
+#define R_HEX_IE_GOT_32 59
+#define R_HEX_IE_GOT_16 60
+#define R_HEX_TPREL_LO16 61
+#define R_HEX_TPREL_HI16 62
+#define R_HEX_TPREL_32 63
+#define R_HEX_TPREL_16 64
+#define R_HEX_6_PCREL_X 65
+#define R_HEX_GOTREL_32_6_X 66
+#define R_HEX_GOTREL_16_X 67
+#define R_HEX_GOTREL_11_X 68
+#define R_HEX_GOT_32_6_X 69
+#define R_HEX_GOT_16_X 70
+#define R_HEX_GOT_11_X 71
+#define R_HEX_DTPREL_32_6_X 72
+#define R_HEX_DTPREL_16_X 73
+#define R_HEX_DTPREL_11_X 74
+#define R_HEX_GD_GOT_32_6_X 75
+#define R_HEX_GD_GOT_16_X 76
+#define R_HEX_GD_GOT_11_X 77
+#define R_HEX_IE_32_6_X 78
+#define R_HEX_IE_16_X 79
+#define R_HEX_IE_GOT_32_6_X 80
+#define R_HEX_IE_GOT_16_X 81
+#define R_HEX_IE_GOT_11_X 82
+#define R_HEX_TPREL_32_6_X 83
+#define R_HEX_TPREL_16_X 84
+#define R_HEX_TPREL_11_X 85
+#define R_HEX_LD_PLT_B22_PCREL 86
+#define R_HEX_LD_GOT_LO16 87
+#define R_HEX_LD_GOT_HI16 88
+#define R_HEX_LD_GOT_32 89
+#define R_HEX_LD_GOT_16 90
+#define R_HEX_LD_GOT_32_6_X 91
+#define R_HEX_LD_GOT_16_X 92
+#define R_HEX_LD_GOT_11_X 93
+#define R_HEX_23_REG 94
+#define R_HEX_GD_PLT_B22_PCREL_X 95
+#define R_HEX_GD_PLT_B32_PCREL_X 96
+#define R_HEX_LD_PLT_B22_PCREL_X 97
+#define R_HEX_LD_PLT_B32_PCREL_X 98
+#define R_HEX_27_REG 99
+
#endif /* elf.h */
diff --git a/src/elflint.c b/src/elflint.c
index 864de710..e56e1465 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -331,7 +331,7 @@ static const int valid_e_machine[] =
EM_AVR, EM_FR30, EM_D10V, EM_D30V, EM_V850, EM_M32R, EM_MN10300,
EM_MN10200, EM_PJ, EM_OPENRISC, EM_ARC_A5, EM_XTENSA, EM_ALPHA,
EM_TILEGX, EM_TILEPRO, EM_AARCH64, EM_BPF, EM_RISCV, EM_CSKY, EM_LOONGARCH,
- EM_ARCV2
+ EM_ARCV2, EM_QDSP6
};
#define nvalid_e_machine \
(sizeof (valid_e_machine) / sizeof (valid_e_machine[0]))
--
2.37.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] Hexagon: implement machine flag check
2024-03-21 21:09 [PATCH 0/2] Add initial support for Hexagon Matheus Tavares Bernardino
2024-03-21 21:09 ` [PATCH 1/2] Add " Matheus Tavares Bernardino
@ 2024-03-21 21:09 ` Matheus Tavares Bernardino
2024-03-21 21:13 ` [PATCH 0/2] Add initial support for Hexagon Brian Cain
2024-03-28 13:45 ` Mark Wielaard
3 siblings, 0 replies; 6+ messages in thread
From: Matheus Tavares Bernardino @ 2024-03-21 21:09 UTC (permalink / raw)
To: elfutils-devel; +Cc: bcain, sidneym, mark
This fixes the "invalid machine flag" error from eu-elflint when passing
hexagon binaries.
Signed-off-by: Matheus Tavares Bernardino <quic_mathbern@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
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH 0/2] Add initial support for Hexagon
2024-03-21 21:09 [PATCH 0/2] Add initial support for Hexagon Matheus Tavares Bernardino
2024-03-21 21:09 ` [PATCH 1/2] Add " Matheus Tavares Bernardino
2024-03-21 21:09 ` [PATCH 2/2] Hexagon: implement machine flag check Matheus Tavares Bernardino
@ 2024-03-21 21:13 ` Brian Cain
2024-03-28 13:45 ` Mark Wielaard
3 siblings, 0 replies; 6+ messages in thread
From: Brian Cain @ 2024-03-21 21:13 UTC (permalink / raw)
To: Matheus Bernardino (QUIC), elfutils-devel
Cc: Sid Manning, mark, Andrew Pinski (QUIC)
cc Andrew
> -----Original Message-----
> From: Matheus Bernardino (QUIC) <quic_mathbern@quicinc.com>
> Sent: Thursday, March 21, 2024 4:09 PM
> To: elfutils-devel@sourceware.org
> Cc: Brian Cain <bcain@quicinc.com>; Sid Manning <sidneym@quicinc.com>;
> mark@klomp.org
> Subject: [PATCH 0/2] Add initial support for Hexagon
>
> The patches were inspired by
> https://sourceware.org/cgit/elfutils/commit?id=13a4d1279c5b7847049ca30
> 45d04f2705c45ce31
>
> Related to:
> https://lore.kernel.org/all/6498586d7d0ed112e6c44be98d439abc549653c7.
> camel@klomp.org/t/#u
>
> Matheus Tavares Bernardino (2):
> Add support for Hexagon
> Hexagon: implement machine flag check
>
> backends/Makefile.am | 6 +-
> backends/hexagon_init.c | 52 +++++++++++++++
> backends/hexagon_reloc.def | 130
> ++++++++++++++++++++++++++++++++++++
> backends/hexagon_symbol.c | 66 +++++++++++++++++++
> libebl/eblopenbackend.c | 2 +
> libelf/elf.h | 131 +++++++++++++++++++++++++++++++++++++
> src/elflint.c | 2 +-
> 7 files changed, 386 insertions(+), 3 deletions(-)
> create mode 100644 backends/hexagon_init.c
> create mode 100644 backends/hexagon_reloc.def
> create mode 100644 backends/hexagon_symbol.c
>
> --
> 2.37.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] Add initial support for Hexagon
2024-03-21 21:09 [PATCH 0/2] Add initial support for Hexagon Matheus Tavares Bernardino
` (2 preceding siblings ...)
2024-03-21 21:13 ` [PATCH 0/2] Add initial support for Hexagon Brian Cain
@ 2024-03-28 13:45 ` Mark Wielaard
2024-03-28 22:20 ` Matheus Bernardino
3 siblings, 1 reply; 6+ messages in thread
From: Mark Wielaard @ 2024-03-28 13:45 UTC (permalink / raw)
To: Matheus Tavares Bernardino; +Cc: elfutils-devel, bcain, sidneym
Hi Matheus,
On Thu, Mar 21, 2024 at 06:09:08PM -0300, Matheus Tavares Bernardino wrote:
> The patches were inspired by
> https://sourceware.org/cgit/elfutils/commit?id=13a4d1279c5b7847049ca3045d04f2705c45ce31
>
> Related to:
> https://lore.kernel.org/all/6498586d7d0ed112e6c44be98d439abc549653c7.camel@klomp.org/t/#u
>
> Matheus Tavares Bernardino (2):
> Add support for Hexagon
> Hexagon: implement machine flag check
In general this looks good. It is the minimal backend support to get
eu-strip --reloc-debug-sections and opening ET_REL (kernel module)
debug files with dwfl that are automatically relocated.
The only issue is that we like to keep libelf/elf.h synced with glibc
elf/elf.h. Would it be possible/make sense to submit the elf.h changes
to libc-alpha? Otherwise we should keep the new constants in some
other file (maybe libelf/elf-knowledge.h)?
Is there a public psabi for Hexagon? Then including an URL to it would
be helpful.
If possible you might want to include some simple test file. See
tests/run-strip-reloc-ko.sh
Thanks,
Mark
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] Add initial support for Hexagon
2024-03-28 13:45 ` Mark Wielaard
@ 2024-03-28 22:20 ` Matheus Bernardino
0 siblings, 0 replies; 6+ messages in thread
From: Matheus Bernardino @ 2024-03-28 22:20 UTC (permalink / raw)
To: Mark Wielaard; +Cc: elfutils-devel, bcain, sidneym
Hi, Mark
Thanks for the comments.
On 3/28/24 8:45 AM, Mark Wielaard wrote:
> Hi Matheus,
>
> The only issue is that we like to keep libelf/elf.h synced with glibc
> elf/elf.h. Would it be possible/make sense to submit the elf.h changes
> to libc-alpha? Otherwise we should keep the new constants in some
> other file (maybe libelf/elf-knowledge.h)?
Ah, I see. We don't plan on supporting Hexagon on other libc's as of
this moment, so it would be good if we can add these constants to
libelf/elf-knowledge.h, like you suggested.
> Is there a public psabi for Hexagon? Then including an URL to it would
> be helpful.
Yes, it's available at:
https://lists.llvm.org/pipermail/llvm-dev/attachments/20190916/21516a52/attachment-0001.pdf
(I'll add it to the commit message as well.)
> If possible you might want to include some simple test file. See
> tests/run-strip-reloc-ko.sh
Sure, will do!
Thanks,
Matheus
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-03-28 22:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-21 21:09 [PATCH 0/2] Add initial support for Hexagon Matheus Tavares Bernardino
2024-03-21 21:09 ` [PATCH 1/2] Add " Matheus Tavares Bernardino
2024-03-21 21:09 ` [PATCH 2/2] Hexagon: implement machine flag check Matheus Tavares Bernardino
2024-03-21 21:13 ` [PATCH 0/2] Add initial support for Hexagon Brian Cain
2024-03-28 13:45 ` Mark Wielaard
2024-03-28 22:20 ` Matheus Bernardino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).