summaryrefslogtreecommitdiffstats
path: root/backends
diff options
context:
space:
mode:
authorMatheus Tavares Bernardino <[email protected]>2024-04-02 16:55:45 -0300
committerMark Wielaard <[email protected]>2024-04-04 18:34:57 +0200
commit7cf68d0b84d7990d03c4ab15c210952f7c735c2a (patch)
tree498ca275252305d2c1227ad75a5962e3eb9ea711 /backends
parenta8fb92b94970e64d4208112e946f4f3112c4ac73 (diff)
Add support for Hexagon
This implements initial support for the Hexagon architecture. The Hexagon ABI spec can be seen at https://lists.llvm.org/pipermail/llvm-dev/attachments/20190916/21516a52/attachment-0001.pdf A hello_hexagon.ko test is also added. $ head tests/test-suite.log [...] # TOTAL: 275 # PASS: 269 # SKIP: 6 # XFAIL: 0 # FAIL: 0 # XPASS: 0 # ERROR: 0 $ cat tests/run-strip-reloc-ko.sh.log [...] runtest hello_hexagon.ko PASS run-strip-reloc-ko.sh (exit status: 0) * backends/Makefile.am (modules): Add hexagon. (hexagon_SRCS): New var for hexagon_init.c and hexagon_symbol.c. (libebl_backends_a_SOURCES): Add hexagon_SRCS. * backends/hexagon_init.c: New file. * backends/hexagon_reloc.def: Likewise. * backends/hexagon_symbol.c: Likewise. * libebl/eblopenbackend.c (hexagon_init): Declare. (machines): Add hexagon. * libelf/elf-knowledge.h: Add hexagon e_flags values, section indices and and relocs. * src/elflint.c (valid_e_machine): Add EM_QDSP6. * tests/Makefile.am (EXTRA_DIST): Add hello_hexagon.ko.bz2. * tests/hello_hexagon.ko.bz2: New test file. * tests/run-strip-reloc-ko.sh: Add hello_hexagon.ko. Signed-off-by: Matheus Tavares Bernardino <[email protected]>
Diffstat (limited to 'backends')
-rw-r--r--backends/Makefile.am7
-rw-r--r--backends/hexagon_init.c51
-rw-r--r--backends/hexagon_reloc.def130
-rw-r--r--backends/hexagon_symbol.c58
4 files changed, 244 insertions, 2 deletions
diff --git a/backends/Makefile.am b/backends/Makefile.am
index b946fd30..e22b522c 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 mips
+ m68k bpf riscv csky loongarch arc mips hexagon
i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \
i386_retval.c i386_regs.c i386_auxv.c \
@@ -104,12 +104,15 @@ arc_SRCS = arc_init.c arc_symbol.c
mips_SRCS = mips_init.c mips_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) $(mips_SRCS)
+ $(loongarch_SRCS) $(arc_SRCS) $(mips_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;
+ }
+}