diff options
Diffstat (limited to 'backends')
-rw-r--r-- | backends/ChangeLog | 9 | ||||
-rw-r--r-- | backends/Makefile.am | 6 | ||||
-rw-r--r-- | backends/arc_init.c | 59 | ||||
-rw-r--r-- | backends/arc_reloc.def | 87 | ||||
-rw-r--r-- | backends/arc_symbol.c | 81 |
5 files changed, 240 insertions, 2 deletions
diff --git a/backends/ChangeLog b/backends/ChangeLog index 5813ddcc..f28ab89b 100644 --- a/backends/ChangeLog +++ b/backends/ChangeLog @@ -1,3 +1,12 @@ +2022-12-21 Shahab Vahedi <shahab@synopsys.email> + + * Makefile.am (modules): Add arc. + (arc_SRCS): Added. + (libebl_backends_a_SOURCES): Append arc_SRCS. + * arc_init.c: New file. + * arc_reloc.def: New file. + * arc_symbol.c: New file. + 2022-12-02 Hengqi Chen <hengqi.chen@gmail.com> * Makefile.am (modules): Add loongarch. diff --git a/backends/Makefile.am b/backends/Makefile.am index 0824123d..f373e5fb 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 + m68k bpf riscv csky loongarch arc i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \ i386_retval.c i386_regs.c i386_auxv.c \ @@ -98,12 +98,14 @@ csky_SRCS = csky_attrs.c csky_init.c csky_symbol.c csky_cfi.c \ loongarch_SRCS = loongarch_init.c loongarch_symbol.c +arc_SRCS = arc_init.c arc_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) + $(loongarch_SRCS) $(arc_SRCS) libebl_backends_pic_a_SOURCES = am_libebl_backends_pic_a_OBJECTS = $(libebl_backends_a_SOURCES:.c=.os) diff --git a/backends/arc_init.c b/backends/arc_init.c new file mode 100644 index 00000000..a7cceceb --- /dev/null +++ b/backends/arc_init.c @@ -0,0 +1,59 @@ +/* Initialization of ARC specific backend library. + Copyright (C) 2022 Synopsys Inc. + 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/>. */ + +/* More details on an ARC elf can be found at: + https://github.com/foss-for-synopsys-dwc-arc-processors/ \ + arc-ABI-manual/blob/master/arcv3-elf.md */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#define BACKEND arc_ +#define RELOC_PREFIX R_ARC_ +#include "libebl_CPU.h" + +/* This defines the common reloc hooks based on arc_reloc.def. */ +#include "common-reloc.c" + +Ebl * +arc_init (Elf *elf __attribute__ ((unused)), + GElf_Half machine __attribute__ ((unused)), + Ebl *eh) +{ + arc_init_reloc (eh); + HOOK (eh, machine_flag_check); + HOOK (eh, reloc_simple_type); + HOOK (eh, section_type_name); + + /* /bld/gcc-stage2/arc-snps-linux-gnu/libgcc/libgcc.map.in + #define __LIBGCC_DWARF_FRAME_REGISTERS__. */ + eh->frame_nregs = 146; + + return eh; +} diff --git a/backends/arc_reloc.def b/backends/arc_reloc.def new file mode 100644 index 00000000..dfa30629 --- /dev/null +++ b/backends/arc_reloc.def @@ -0,0 +1,87 @@ +/* List the relocation types for ARC. -*- C -*- + 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, EXEC|DYN) +RELOC_TYPE (8, REL|EXEC|DYN) +RELOC_TYPE (16, REL|EXEC|DYN) +RELOC_TYPE (24, REL|EXEC|DYN) +RELOC_TYPE (32, REL|EXEC|DYN) +RELOC_TYPE (N8, REL|EXEC|DYN) +RELOC_TYPE (N16, REL|EXEC|DYN) +RELOC_TYPE (N24, REL|EXEC|DYN) +RELOC_TYPE (N32, REL|EXEC|DYN) +RELOC_TYPE (SDA, REL) +RELOC_TYPE (SECTOFF, REL) +RELOC_TYPE (S21H_PCREL, REL) +RELOC_TYPE (S21W_PCREL, REL) +RELOC_TYPE (S25H_PCREL, REL) +RELOC_TYPE (S25W_PCREL, REL) +RELOC_TYPE (SDA32, REL) +RELOC_TYPE (SDA_LDST, REL) +RELOC_TYPE (SDA_LDST1, REL) +RELOC_TYPE (SDA_LDST2, REL) +RELOC_TYPE (SDA16_LD, REL) +RELOC_TYPE (SDA16_LD1, REL) +RELOC_TYPE (SDA16_LD2, REL) +RELOC_TYPE (S13_PCREL, REL) +RELOC_TYPE (W, REL) +RELOC_TYPE (32_ME, REL) +RELOC_TYPE (N32_ME, REL) +RELOC_TYPE (SECTOFF_ME, REL) +RELOC_TYPE (SDA32_ME, REL) +RELOC_TYPE (W_ME, REL) +RELOC_TYPE (SDA_12, REL) +RELOC_TYPE (SDA16_ST2, REL) +RELOC_TYPE (32_PCREL, REL) +RELOC_TYPE (PC32, REL) +RELOC_TYPE (GOTPC32, REL) +RELOC_TYPE (PLT32, REL) +RELOC_TYPE (COPY, EXEC|DYN) +RELOC_TYPE (GLOB_DAT, EXEC|DYN) +RELOC_TYPE (JMP_SLOT, EXEC|DYN) +RELOC_TYPE (RELATIVE, EXEC|DYN) +RELOC_TYPE (GOTOFF, REL) +RELOC_TYPE (GOTPC, REL) +RELOC_TYPE (GOT32, REL) +RELOC_TYPE (S21W_PCREL_PLT, REL) +RELOC_TYPE (S25H_PCREL_PLT, REL) +RELOC_TYPE (JLI_SECTOFF, REL) +RELOC_TYPE (TLS_DTPMOD, REL) +RELOC_TYPE (TLS_DTPOFF, REL) +RELOC_TYPE (TLS_TPOFF, REL) +RELOC_TYPE (TLS_GD_GOT, REL) +RELOC_TYPE (TLS_GD_LD, REL) +RELOC_TYPE (TLS_GD_CALL, REL) +RELOC_TYPE (TLS_IE_GOT, REL) +RELOC_TYPE (TLS_DTPOFF_S9, REL) +RELOC_TYPE (TLS_LE_S9, REL) +RELOC_TYPE (TLS_LE_32, REL) +RELOC_TYPE (S25W_PCREL_PLT, REL) +RELOC_TYPE (S21H_PCREL_PLT, REL) +RELOC_TYPE (NPS_CMEM16, REL) diff --git a/backends/arc_symbol.c b/backends/arc_symbol.c new file mode 100644 index 00000000..be69814e --- /dev/null +++ b/backends/arc_symbol.c @@ -0,0 +1,81 @@ +/* ARC specific symbolic name handling. + 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 arc_ +#include "libebl_CPU.h" + + +/* Check whether machine flags are valid. */ +bool +arc_machine_flag_check (GElf_Word flags) +{ + return ((flags & ~EF_ARC_ALL_MSK) == 0); +} + +/* Check for the simple reloc types. */ +Elf_Type +arc_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type, + int *addsub __attribute ((unused))) +{ + switch (type) + { + case R_ARC_32: + return ELF_T_WORD; + case R_ARC_16: + return ELF_T_HALF; + case R_ARC_8: + return ELF_T_BYTE; + default: + return ELF_T_NUM; + } +} + +/* Return symbolic representation of section type. */ +const char * +arc_section_type_name (int type, + char *buf __attribute__ ((unused)), + size_t len __attribute__ ((unused))) +{ + switch (type) + { + case SHT_ARC_ATTRIBUTES: + return "ARC_ATTRIBUTES"; + default: + break; + } + + return NULL; +} |