@@ -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)
new file mode 100644
@@ -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;
+}
+
new file mode 100644
@@ -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)
new file mode 100644
@@ -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;
+ }
+}
@@ -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]))
@@ -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 */
@@ -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]))