* [PATCH] Add support for ARCv2
@ 2022-10-28 13:43 Shahab Vahedi
2022-10-31 14:52 ` [PATCH v2] " Shahab Vahedi
[not found] ` <Y13Tk6e/qsoolka+@wildebeest.org>
0 siblings, 2 replies; 10+ messages in thread
From: Shahab Vahedi @ 2022-10-28 13:43 UTC (permalink / raw)
To: elfutils-devel
Cc: "Shahab Vahedi <shahab"@synopsys.com, Claudiu Zissulescu
This adds support for Synopsys ARCv2 processors. ARC target related
macros has been added to libelf/elf.h. However, there a few changes
on existing ARC macros to correct them and be in sync with binutils.
There are no regressions in tests for an x86_64 build.
==========================================
elfutils 0.187: tests/test-suite.log
==========================================
.. contents:: :depth: 2
FAIL: run-backtrace-native-core.sh
==================================
backtrace: No modules recognized in core file
backtrace-child-core.8740: no main
rmdir: failed to remove 'test-8732': Directory not empty
FAIL run-backtrace-native-core.sh (exit status: 1)
FAIL: run-backtrace-native-core-biarch.sh
=========================================
backtrace: No modules recognized in core file
backtrace-child-biarch-core.8763: no main
rmdir: failed to remove 'test-8755': Directory not empty
FAIL run-backtrace-native-core-biarch.sh (exit status: 1)
SKIP: run-lfs-symbols.sh
========================
LFS testing is irrelevant on this system
SKIP run-lfs-symbols.sh (exit status: 77)
Signed-off-by: Shahab Vahedi <shahab@synopsys.com>
---
backends/Makefile.am | 7 +++-
backends/arc_init.c | 55 ++++++++++++++++++++++++++
backends/arc_reloc.def | 87 ++++++++++++++++++++++++++++++++++++++++
backends/arc_symbol.c | 81 +++++++++++++++++++++++++++++++++++++
libebl/eblopenbackend.c | 2 +
libelf/elf.h | 88 +++++++++++++++++++++++++----------------
src/elflint.c | 2 +-
7 files changed, 286 insertions(+), 36 deletions(-)
create mode 100644 backends/arc_init.c
create mode 100644 backends/arc_reloc.def
create mode 100644 backends/arc_symbol.c
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 9566377f..7f8e47a0 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
+ m68k bpf riscv csky arc
i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \
i386_retval.c i386_regs.c i386_auxv.c \
@@ -96,11 +96,14 @@ riscv_SRCS = riscv_init.c riscv_symbol.c riscv_cfi.c riscv_regs.c \
csky_SRCS = csky_attrs.c csky_init.c csky_symbol.c csky_cfi.c \
csky_regs.c csky_initreg.c csky_corenote.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)
+ $(m68k_SRCS) $(bpf_SRCS) $(riscv_SRCS) \
+ $(csky_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..a013bc4e
--- /dev/null
+++ b/backends/arc_init.c
@@ -0,0 +1,55 @@
+/* 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/>. */
+
+#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..e996c5d9
--- /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;
+}
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index 02f80653..f2288f63 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -55,6 +55,7 @@ Ebl *m68k_init (Elf *, GElf_Half, Ebl *);
Ebl *bpf_init (Elf *, GElf_Half, Ebl *);
Ebl *riscv_init (Elf *, GElf_Half, Ebl *);
Ebl *csky_init (Elf *, GElf_Half, Ebl *);
+Ebl *arc_init (Elf *, GElf_Half, Ebl *);
/* This table should contain the complete list of architectures as far
as the ELF specification is concerned. */
@@ -150,6 +151,7 @@ static const struct
{ riscv_init, "elf_riscv", "riscv", 5, EM_RISCV, ELFCLASS64, ELFDATA2LSB },
{ riscv_init, "elf_riscv", "riscv", 5, EM_RISCV, ELFCLASS32, ELFDATA2LSB },
{ csky_init, "elf_csky", "csky", 4, EM_CSKY, ELFCLASS32, ELFDATA2LSB },
+ { arc_init, "elf_arc", "arc", 3, EM_ARCV2, ELFCLASS32, ELFDATA2LSB },
};
#define nmachines (sizeof (machines) / sizeof (machines[0]))
diff --git a/libelf/elf.h b/libelf/elf.h
index 02a1b3f5..8428e3df 100644
--- a/libelf/elf.h
+++ b/libelf/elf.h
@@ -4148,24 +4148,48 @@ enum
#define R_LARCH_GNU_VTINHERIT 57
#define R_LARCH_GNU_VTENTRY 58
+/* ARC specific declarations. */
+
+/* Processor specific flags for the Ehdr e_flags field. */
+#define EF_ARC_MACH_MSK 0x000000ff
+#define EF_ARC_OSABI_MSK 0x00000f00
+#define EF_ARC_ALL_MSK (EF_ARC_MACH_MSK | EF_ARC_OSABI_MSK)
+
+/* Various CPU types. These numbers are exposed in the ELF header flags
+ (e_flags field), and so must never change. */
+#define E_ARC_MACH_ARC600 0x00000002
+#define E_ARC_MACH_ARC601 0x00000004
+#define E_ARC_MACH_ARC700 0x00000003
+#define EF_ARC_CPU_ARCV2EM 0x00000005
+#define EF_ARC_CPU_ARCV2HS 0x00000006
+#define EF_ARC_CPU_ARC64 0x00000007
+
+/* ARC Linux specific ABIs. */
+#define E_ARC_OSABI_ORIG 0x00000000 /* MUST be 0 for back-compat. */
+#define E_ARC_OSABI_V2 0x00000200
+#define E_ARC_OSABI_V3 0x00000300
+#define E_ARC_OSABI_V4 0x00000400
+#define E_ARC_OSABI_CURRENT E_ARC_OSABI_V4
+/* Leave bits 0xf0 alone in case we ever have more than 16 cpu types. */
+
+/* Additional section types. */
+#define SHT_ARC_ATTRIBUTES 0x70000001 /* Section holds attributes. */
/* ARCompact/ARCv2 specific relocs. */
-#define R_ARC_NONE 0x0
-#define R_ARC_8 0x1
-#define R_ARC_16 0x2
-#define R_ARC_24 0x3
-#define R_ARC_32 0x4
-#define R_ARC_B26 0x5
-#define R_ARC_B22_PCREL 0x6
-#define R_ARC_H30 0x7
-#define R_ARC_N8 0x8
-#define R_ARC_N16 0x9
-#define R_ARC_N24 0xA
-#define R_ARC_N32 0xB
-#define R_ARC_SDA 0xC
-#define R_ARC_SECTOFF 0xD
-#define R_ARC_S21H_PCREL 0xE
-#define R_ARC_S21W_PCREL 0xF
+#define R_ARC_NONE 0x00
+#define R_ARC_8 0x01
+#define R_ARC_16 0x02
+#define R_ARC_24 0x03
+#define R_ARC_32 0x04
+
+#define R_ARC_N8 0x08
+#define R_ARC_N16 0x09
+#define R_ARC_N24 0x0A
+#define R_ARC_N32 0x0B
+#define R_ARC_SDA 0x0C
+#define R_ARC_SECTOFF 0x0D
+#define R_ARC_S21H_PCREL 0x0E
+#define R_ARC_S21W_PCREL 0x0F
#define R_ARC_S25H_PCREL 0x10
#define R_ARC_S25W_PCREL 0x11
#define R_ARC_SDA32 0x12
@@ -4182,29 +4206,24 @@ enum
#define R_ARC_SECTOFF_ME 0x1D
#define R_ARC_SDA32_ME 0x1E
#define R_ARC_W_ME 0x1F
-#define R_ARC_H30_ME 0x20
-#define R_ARC_SECTOFF_U8 0x21
-#define R_ARC_SECTOFF_S9 0x22
-#define R_AC_SECTOFF_U8 0x23
-#define R_AC_SECTOFF_U8_1 0x24
-#define R_AC_SECTOFF_U8_2 0x25
-#define R_AC_SECTOFF_S9 0x26
-#define R_AC_SECTOFF_S9_1 0x27
-#define R_AC_SECTOFF_S9_2 0x28
-#define R_ARC_SECTOFF_ME_1 0x29
-#define R_ARC_SECTOFF_ME_2 0x2A
-#define R_ARC_SECTOFF_1 0x2B
-#define R_ARC_SECTOFF_2 0x2C
+
+#define R_ARC_SDA_12 0x2D
+#define R_ARC_SDA16_ST2 0x30
+#define R_ARC_32_PCREL 0x31
#define R_ARC_PC32 0x32
#define R_ARC_GOTPC32 0x33
#define R_ARC_PLT32 0x34
#define R_ARC_COPY 0x35
#define R_ARC_GLOB_DAT 0x36
-#define R_ARC_JUMP_SLOT 0x37
+#define R_ARC_JMP_SLOT 0x37
#define R_ARC_RELATIVE 0x38
#define R_ARC_GOTOFF 0x39
#define R_ARC_GOTPC 0x3A
#define R_ARC_GOT32 0x3B
+#define R_ARC_S21W_PCREL_PLT 0x3C
+#define R_ARC_S25H_PCREL_PLT 0x3D
+
+#define R_ARC_JLI_SECTOFF 0x3F
#define R_ARC_TLS_DTPMOD 0x42
#define R_ARC_TLS_DTPOFF 0x43
@@ -4213,9 +4232,12 @@ enum
#define R_ARC_TLS_GD_LD 0x46
#define R_ARC_TLS_GD_CALL 0x47
#define R_ARC_TLS_IE_GOT 0x48
-#define R_ARC_TLS_DTPOFF_S9 0x4a
-#define R_ARC_TLS_LE_S9 0x4a
-#define R_ARC_TLS_LE_32 0x4b
+#define R_ARC_TLS_DTPOFF_S9 0x49
+#define R_ARC_TLS_LE_S9 0x4A
+#define R_ARC_TLS_LE_32 0x4B
+#define R_ARC_S25W_PCREL_PLT 0x4C
+#define R_ARC_S21H_PCREL_PLT 0x4D
+#define R_ARC_NPS_CMEM16 0x4E
/* OpenRISC 1000 specific relocs. */
#define R_OR1K_NONE 0
diff --git a/src/elflint.c b/src/elflint.c
index 565cffdc..71521d6a 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -329,7 +329,7 @@ static const int valid_e_machine[] =
EM_CRIS, EM_JAVELIN, EM_FIREPATH, EM_ZSP, EM_MMIX, EM_HUANY, EM_PRISM,
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_TILEGX, EM_TILEPRO, EM_AARCH64, EM_BPF, EM_RISCV, EM_CSKY, EM_ARC
};
#define nvalid_e_machine \
(sizeof (valid_e_machine) / sizeof (valid_e_machine[0]))
--
2.38.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2] Add support for ARCv2
2022-10-28 13:43 [PATCH] Add support for ARCv2 Shahab Vahedi
@ 2022-10-31 14:52 ` Shahab Vahedi
[not found] ` <Y13Tk6e/qsoolka+@wildebeest.org>
1 sibling, 0 replies; 10+ messages in thread
From: Shahab Vahedi @ 2022-10-31 14:52 UTC (permalink / raw)
To: elfutils-devel; +Cc: Mark Wielaard, Shahab Vahedi, Claudiu Zissulescu
This adds support for Synopsys ARCv2 processors. ARC target related
macros have been added to libelf/elf.h. However, there are a few changes
on existing ARC macros to correct them and be in sync with binutils. All
the details of those changes are listed in libelf/ChangeLog. I am going
to propose the same type of changes in glibc as well.
There are no regressions in tests for an x86_64 build.
Signed-off-by: Shahab Vahedi <shahab@synopsys.com>
---
Chagelog:
v2:
- Add ChangeLog entries.
- Reduced number of changes in libelf/elf.h
- Reworded the commit message.
backends/ChangeLog | 9 +++++
backends/Makefile.am | 7 +++-
backends/arc_init.c | 55 ++++++++++++++++++++++++++
backends/arc_reloc.def | 87 +++++++++++++++++++++++++++++++++++++++++
backends/arc_symbol.c | 81 ++++++++++++++++++++++++++++++++++++++
libebl/ChangeLog | 5 +++
libebl/eblopenbackend.c | 2 +
libelf/ChangeLog | 17 ++++++++
libelf/elf.h | 76 +++++++++++++++++++++++++----------
src/ChangeLog | 4 ++
src/elflint.c | 2 +-
11 files changed, 322 insertions(+), 23 deletions(-)
create mode 100644 backends/arc_init.c
create mode 100644 backends/arc_reloc.def
create mode 100644 backends/arc_symbol.c
diff --git a/backends/ChangeLog b/backends/ChangeLog
index 5b0daffe..3562cbcd 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,12 @@
+2022-10-31 Shahab Vahedi <shahab@synopsys.com>
+
+ * 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-08-09 Andreas Schwab <schwab@suse.de>
* riscv_init.c (riscv_init): HOOK segment_type_name,
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 9566377f..7f8e47a0 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
+ m68k bpf riscv csky arc
i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \
i386_retval.c i386_regs.c i386_auxv.c \
@@ -96,11 +96,14 @@ riscv_SRCS = riscv_init.c riscv_symbol.c riscv_cfi.c riscv_regs.c \
csky_SRCS = csky_attrs.c csky_init.c csky_symbol.c csky_cfi.c \
csky_regs.c csky_initreg.c csky_corenote.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)
+ $(m68k_SRCS) $(bpf_SRCS) $(riscv_SRCS) \
+ $(csky_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..a013bc4e
--- /dev/null
+++ b/backends/arc_init.c
@@ -0,0 +1,55 @@
+/* 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/>. */
+
+#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..e996c5d9
--- /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;
+}
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 6f55a5e7..3085e1eb 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,8 @@
+2022-10-31 Shahab Vahedi <shahab@synopsys.com>
+
+ * eblopenbackend.c (arc_init): New function declaration.
+ (machines): Add entry for arc.
+
2022-10-21 Yonggang Luo <luoyonggang@gmail.com>
* eblclosebackend.c: Remove dlfcn.h include.
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index 02f80653..f2288f63 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -55,6 +55,7 @@ Ebl *m68k_init (Elf *, GElf_Half, Ebl *);
Ebl *bpf_init (Elf *, GElf_Half, Ebl *);
Ebl *riscv_init (Elf *, GElf_Half, Ebl *);
Ebl *csky_init (Elf *, GElf_Half, Ebl *);
+Ebl *arc_init (Elf *, GElf_Half, Ebl *);
/* This table should contain the complete list of architectures as far
as the ELF specification is concerned. */
@@ -150,6 +151,7 @@ static const struct
{ riscv_init, "elf_riscv", "riscv", 5, EM_RISCV, ELFCLASS64, ELFDATA2LSB },
{ riscv_init, "elf_riscv", "riscv", 5, EM_RISCV, ELFCLASS32, ELFDATA2LSB },
{ csky_init, "elf_csky", "csky", 4, EM_CSKY, ELFCLASS32, ELFDATA2LSB },
+ { arc_init, "elf_arc", "arc", 3, EM_ARCV2, ELFCLASS32, ELFDATA2LSB },
};
#define nmachines (sizeof (machines) / sizeof (machines[0]))
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 8107c71e..9cafa947 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,20 @@
+2022-10-31 Shahab Vahedi <shahab@synopsys.com>
+
+ * elf.h: Add arc machines, CPUs, OSABIs, attribute, and relocations.
+ (R_ARC_B26): Removed.
+ (R_ARC_SDA_12): New.
+ (R_ARC_SDA16_ST2): New.
+ (R_ARC_32_PCREL): New.
+ (R_ARC_JUMP_SLOT): Renamed to R_ARC_JMP_SLOT.
+ (R_ARC_GOT32): New.
+ (R_ARC_S21W_PCREL_PLT): New.
+ (R_ARC_S25H_PCREL_PLT): New.
+ (R_ARC_JLI_SECTOFF): New.
+ (R_ARC_TLS_DTPOFF_S9): 0x4a -> 0x49.
+ (R_ARC_S25W_PCREL_PLT): New.
+ (R_ARC_S21H_PCREL_PLT): New.
+ (R_ARC_NPS_CMEM16): New.
+
2022-10-28 Mark Wielaard <mark@klomp.org>
* elf.h: Update from glibc.
diff --git a/libelf/elf.h b/libelf/elf.h
index f51300bc..0fc899f7 100644
--- a/libelf/elf.h
+++ b/libelf/elf.h
@@ -4156,24 +4156,50 @@ enum
#define R_LARCH_GNU_VTINHERIT 57
#define R_LARCH_GNU_VTENTRY 58
+/* ARC specific declarations. */
+
+/* Processor specific flags for the Ehdr e_flags field. */
+#define EF_ARC_MACH_MSK 0x000000ff
+#define EF_ARC_OSABI_MSK 0x00000f00
+#define EF_ARC_ALL_MSK (EF_ARC_MACH_MSK | EF_ARC_OSABI_MSK)
+
+/* Various CPU types. These numbers are exposed in the ELF header flags
+ (e_flags field), and so must never change. */
+#define E_ARC_MACH_ARC600 0x00000002
+#define E_ARC_MACH_ARC601 0x00000004
+#define E_ARC_MACH_ARC700 0x00000003
+#define EF_ARC_CPU_ARCV2EM 0x00000005
+#define EF_ARC_CPU_ARCV2HS 0x00000006
+#define EF_ARC_CPU_ARC64 0x00000007
+
+/* ARC Linux specific ABIs. */
+#define E_ARC_OSABI_ORIG 0x00000000 /* MUST be 0 for back-compat. */
+#define E_ARC_OSABI_V2 0x00000200
+#define E_ARC_OSABI_V3 0x00000300
+#define E_ARC_OSABI_V4 0x00000400
+#define E_ARC_OSABI_CURRENT E_ARC_OSABI_V4
+/* Leave bits 0xf0 alone in case we ever have more than 16 cpu types. */
+
+/* Processor specific values for the Shdr sh_type field. */
+#define SHT_ARC_ATTRIBUTES (SHT_LOPROC + 1) /* ARC attributes section. */
/* ARCompact/ARCv2 specific relocs. */
-#define R_ARC_NONE 0x0
-#define R_ARC_8 0x1
-#define R_ARC_16 0x2
-#define R_ARC_24 0x3
-#define R_ARC_32 0x4
-#define R_ARC_B26 0x5
-#define R_ARC_B22_PCREL 0x6
-#define R_ARC_H30 0x7
-#define R_ARC_N8 0x8
-#define R_ARC_N16 0x9
-#define R_ARC_N24 0xA
-#define R_ARC_N32 0xB
-#define R_ARC_SDA 0xC
-#define R_ARC_SECTOFF 0xD
-#define R_ARC_S21H_PCREL 0xE
-#define R_ARC_S21W_PCREL 0xF
+#define R_ARC_NONE 0x00
+#define R_ARC_8 0x01
+#define R_ARC_16 0x02
+#define R_ARC_24 0x03
+#define R_ARC_32 0x04
+
+#define R_ARC_B22_PCREL 0x06
+#define R_ARC_H30 0x07
+#define R_ARC_N8 0x08
+#define R_ARC_N16 0x09
+#define R_ARC_N24 0x0A
+#define R_ARC_N32 0x0B
+#define R_ARC_SDA 0x0C
+#define R_ARC_SECTOFF 0x0D
+#define R_ARC_S21H_PCREL 0x0E
+#define R_ARC_S21W_PCREL 0x0F
#define R_ARC_S25H_PCREL 0x10
#define R_ARC_S25W_PCREL 0x11
#define R_ARC_SDA32 0x12
@@ -4203,16 +4229,23 @@ enum
#define R_ARC_SECTOFF_ME_2 0x2A
#define R_ARC_SECTOFF_1 0x2B
#define R_ARC_SECTOFF_2 0x2C
+#define R_ARC_SDA_12 0x2D
+#define R_ARC_SDA16_ST2 0x30
+#define R_ARC_32_PCREL 0x31
#define R_ARC_PC32 0x32
#define R_ARC_GOTPC32 0x33
#define R_ARC_PLT32 0x34
#define R_ARC_COPY 0x35
#define R_ARC_GLOB_DAT 0x36
-#define R_ARC_JUMP_SLOT 0x37
+#define R_ARC_JMP_SLOT 0x37
#define R_ARC_RELATIVE 0x38
#define R_ARC_GOTOFF 0x39
#define R_ARC_GOTPC 0x3A
#define R_ARC_GOT32 0x3B
+#define R_ARC_S21W_PCREL_PLT 0x3C
+#define R_ARC_S25H_PCREL_PLT 0x3D
+
+#define R_ARC_JLI_SECTOFF 0x3F
#define R_ARC_TLS_DTPMOD 0x42
#define R_ARC_TLS_DTPOFF 0x43
@@ -4221,9 +4254,12 @@ enum
#define R_ARC_TLS_GD_LD 0x46
#define R_ARC_TLS_GD_CALL 0x47
#define R_ARC_TLS_IE_GOT 0x48
-#define R_ARC_TLS_DTPOFF_S9 0x4a
-#define R_ARC_TLS_LE_S9 0x4a
-#define R_ARC_TLS_LE_32 0x4b
+#define R_ARC_TLS_DTPOFF_S9 0x49
+#define R_ARC_TLS_LE_S9 0x4A
+#define R_ARC_TLS_LE_32 0x4B
+#define R_ARC_S25W_PCREL_PLT 0x4C
+#define R_ARC_S21H_PCREL_PLT 0x4D
+#define R_ARC_NPS_CMEM16 0x4E
/* OpenRISC 1000 specific relocs. */
#define R_OR1K_NONE 0
diff --git a/src/ChangeLog b/src/ChangeLog
index d3399a5c..bc58e96a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2022-10-31 Shahab Vahedi <shahab@synopsys.com>
+
+ * elflint.c (valid_e_machine): Add EM_ARC.
+
2022-10-28 Arsen Arsenović <arsen@aarsen.me>
* readelf.c (options): Add Binutils-style --syms alias.
diff --git a/src/elflint.c b/src/elflint.c
index 565cffdc..71521d6a 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -329,7 +329,7 @@ static const int valid_e_machine[] =
EM_CRIS, EM_JAVELIN, EM_FIREPATH, EM_ZSP, EM_MMIX, EM_HUANY, EM_PRISM,
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_TILEGX, EM_TILEPRO, EM_AARCH64, EM_BPF, EM_RISCV, EM_CSKY, EM_ARC
};
#define nvalid_e_machine \
(sizeof (valid_e_machine) / sizeof (valid_e_machine[0]))
--
2.38.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Add support for ARCv2
[not found] ` <Y13Tk6e/qsoolka+@wildebeest.org>
@ 2022-10-31 14:54 ` Shahab Vahedi
2022-11-01 21:01 ` Mark Wielaard
0 siblings, 1 reply; 10+ messages in thread
From: Shahab Vahedi @ 2022-10-31 14:54 UTC (permalink / raw)
To: Mark Wielaard; +Cc: elfutils-devel, Claudiu Zissulescu
Hi Mark,
Thank you for response. First and foremost, there is a second iteration of the
patch [1]. I don't want you, or anybody else, waste time looking into v1. The
changes from v1 have been mentioned at the end of v2 commit message.
[1]
https://sourceware.org/pipermail/elfutils-devel/2022q4/005543.html
Regarding your concerns, please find my answers below.
On 10/30/22 02:29, Mark Wielaard wrote:
> On Fri, Oct 28, 2022 at 01:43:49PM +0000, Shahab Vahedi via Elfutils-devel wrote:
>> This adds support for Synopsys ARCv2 processors.
>
> Is there an easy way to this this (is there a qemu target or a machine
> in the gcc compile farm)?
There is a QEMU target [2]. However, this patch adds a minimal support for ARC.
I'm not quite sure building and running elfutils natively for ARC would test
much at this point. That's why I tested with an x86_64 build with ARC target
support: master + patch -> make check
Unfortunately, there is no machine in GCC's compile farm. There does exist a
pre-built compiler [3] and a repo [4] though.
[2]
https://github.com/foss-for-synopsys-dwc-arc-processors/qemu
[3]
https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/tag/arc-2021.09-release
[4]
https://github.com/foss-for-synopsys-dwc-arc-processors/gcc/tree/arc-2021.09
>> ARC target related
>> macros has been added to libelf/elf.h. However, there a few changes
>> on existing ARC macros to correct them and be in sync with binutils.
>
> We normally sync with the glibc elf.h, have you submitted these
> changes to libc-alpha?
No, but I intend to. In a v2 of the patch [1], I also have added ChangeLog
entries. It must be easier now to quickly figure out what has changed and
if it's OK or not.
>> There are no regressions in tests for an x86_64 build.
>>
>> ==========================================
>> elfutils 0.187: tests/test-suite.log
>> ==========================================
>>
>> .. contents:: :depth: 2
>>
>> FAIL: run-backtrace-native-core.sh
>> ==================================
>>
>> backtrace: No modules recognized in core file
>> backtrace-child-core.8740: no main
>> rmdir: failed to remove 'test-8732': Directory not empty
>> FAIL run-backtrace-native-core.sh (exit status: 1)
>>
>> FAIL: run-backtrace-native-core-biarch.sh
>> =========================================
>>
>> backtrace: No modules recognized in core file
>> backtrace-child-biarch-core.8763: no main
>> rmdir: failed to remove 'test-8755': Directory not empty
>> FAIL run-backtrace-native-core-biarch.sh (exit status: 1)
>
> These two need abi_cfi hooks to describe the DWARF CFI needed to
> unwind.
To be clear, these are the test results on a build without the patch AND
with the patch. I'm not sure why it happens even without the patch on
my system. If you want, I can file a bug report with more details.
--
Shahab
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Add support for ARCv2
2022-10-31 14:54 ` [PATCH] " Shahab Vahedi
@ 2022-11-01 21:01 ` Mark Wielaard
2022-11-09 16:33 ` Shahab Vahedi
2022-11-30 8:15 ` Shahab Vahedi
0 siblings, 2 replies; 10+ messages in thread
From: Mark Wielaard @ 2022-11-01 21:01 UTC (permalink / raw)
To: Shahab Vahedi; +Cc: elfutils-devel, Claudiu Zissulescu
Hi Shahab,
On Mon, Oct 31, 2022 at 02:54:33PM +0000, Shahab Vahedi via Elfutils-devel wrote:
> Thank you for response. First and foremost, there is a second iteration of the
> patch [1]. I don't want you, or anybody else, waste time looking into v1. The
> changes from v1 have been mentioned at the end of v2 commit message.
Thanks.
> There is a QEMU target [2]. However, this patch adds a minimal support for ARC.
> I'm not quite sure building and running elfutils natively for ARC would test
> much at this point. That's why I tested with an x86_64 build with ARC target
> support: master + patch -> make check
>
> Unfortunately, there is no machine in GCC's compile farm. There does exist a
> pre-built compiler [3] and a repo [4] though.
It might be good to add some tests that can be run on a non ARC
architecture just so people can check they didn't break something. See
e.g. tests/run-strip-reloc.sh tests/run-allregs.sh or
tests/run-addrcfi.sh which take small prebuild object files.
> >> ARC target related
> >> macros has been added to libelf/elf.h. However, there a few changes
> >> on existing ARC macros to correct them and be in sync with binutils.
> >
> > We normally sync with the glibc elf.h, have you submitted these
> > changes to libc-alpha?
>
> No, but I intend to. In a v2 of the patch [1], I also have added ChangeLog
> entries. It must be easier now to quickly figure out what has changed and
> if it's OK or not.
Thanks. Normally we wait syncing the elf.h file once a patch lands in glibc.
> >> There are no regressions in tests for an x86_64 build.
> >>
> >> ==========================================
> >> elfutils 0.187: tests/test-suite.log
> >> ==========================================
> >>
> >> .. contents:: :depth: 2
> >>
> >> FAIL: run-backtrace-native-core.sh
> >> ==================================
> >>
> >> backtrace: No modules recognized in core file
> >> backtrace-child-core.8740: no main
> >> rmdir: failed to remove 'test-8732': Directory not empty
> >> FAIL run-backtrace-native-core.sh (exit status: 1)
> >>
> >> FAIL: run-backtrace-native-core-biarch.sh
> >> =========================================
> >>
> >> backtrace: No modules recognized in core file
> >> backtrace-child-biarch-core.8763: no main
> >> rmdir: failed to remove 'test-8755': Directory not empty
> >> FAIL run-backtrace-native-core-biarch.sh (exit status: 1)
> >
> > These two need abi_cfi hooks to describe the DWARF CFI needed to
> > unwind.
>
> To be clear, these are the test results on a build without the patch AND
> with the patch. I'm not sure why it happens even without the patch on
> my system. If you want, I can file a bug report with more details.
Aha, sorry, I missed this was on x86_64. That is indeed odd. If you
could file a bug report with your environment where this fails that
would be good.
Thanks,
Mark
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Add support for ARCv2
2022-11-01 21:01 ` Mark Wielaard
@ 2022-11-09 16:33 ` Shahab Vahedi
2022-11-30 8:15 ` Shahab Vahedi
1 sibling, 0 replies; 10+ messages in thread
From: Shahab Vahedi @ 2022-11-09 16:33 UTC (permalink / raw)
To: Mark Wielaard; +Cc: elfutils-devel, Claudiu Zissulescu, Shahab Vahedi
Hi Mark,
On 11/1/22 22:01, Mark Wielaard wrote:
> On Mon, Oct 31, 2022 at 02:54:33PM +0000, Shahab Vahedi via Elfutils-devel wrote:
>> To be clear, these are the test results on a build without the patch AND
>> with the patch. I'm not sure why it happens even without the patch on
>> my system. If you want, I can file a bug report with more details.
>
> Aha, sorry, I missed this was on x86_64. That is indeed odd. If you
> could file a bug report with your environment where this fails that
> would be good.
It has been filed [1].
[1]
https://sourceware.org/bugzilla/show_bug.cgi?id=29767
--
Shahab
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Add support for ARCv2
2022-11-01 21:01 ` Mark Wielaard
2022-11-09 16:33 ` Shahab Vahedi
@ 2022-11-30 8:15 ` Shahab Vahedi
2022-11-30 23:36 ` Mark Wielaard
1 sibling, 1 reply; 10+ messages in thread
From: Shahab Vahedi @ 2022-11-30 8:15 UTC (permalink / raw)
To: Mark Wielaard; +Cc: elfutils-devel, Claudiu Zissulescu, Francois Bedard
Hi Mark,
On 11/1/22 22:01, Mark Wielaard wrote:
> Thanks. Normally we wait syncing the elf.h file once a patch lands in glibc.
The necessary changes are in glibc now [1]. How/When does the sync happen? Should
I submit a patch, or trigger a request, etc.?
[1] ARC: update definitions in elf/elf.h
https://sourceware.org/git?p=glibc.git;a=commit;h=6ae0737d430
--
Shahab
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Add support for ARCv2
2022-11-30 8:15 ` Shahab Vahedi
@ 2022-11-30 23:36 ` Mark Wielaard
2022-12-01 9:44 ` Shahab Vahedi
0 siblings, 1 reply; 10+ messages in thread
From: Mark Wielaard @ 2022-11-30 23:36 UTC (permalink / raw)
To: Shahab Vahedi; +Cc: elfutils-devel, Claudiu Zissulescu, Francois Bedard
[-- Attachment #1: Type: text/plain, Size: 269 bytes --]
Hi Shahab,
On Wed, Nov 30, 2022 at 08:15:55AM +0000, Shahab Vahedi via Elfutils-devel wrote:
> The necessary changes are in glibc now [1]. How/When does the sync happen? Should
> I submit a patch, or trigger a request, etc.?
Nice. I just synced elf.h.
Thanks,
Mark
[-- Attachment #2: 0001-libelf-Sync-elf.h-from-glibc.patch --]
[-- Type: text/x-diff, Size: 3210 bytes --]
From 86347d80bec28c762ddc47aee866fcdaf781f25a Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 1 Dec 2022 00:25:01 +0100
Subject: [PATCH] libelf: Sync elf.h from glibc
Adds various new ARC related declarations.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
libelf/ChangeLog | 4 ++++
libelf/elf.h | 36 +++++++++++++++++++++++++++++-------
2 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 8107c71e..3ae3afe3 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2022-11-30 Mark Wielaard <mark@klomp.org>
+
+ * elf.h: Update from glibc.
+
2022-10-28 Mark Wielaard <mark@klomp.org>
* elf.h: Update from glibc.
diff --git a/libelf/elf.h b/libelf/elf.h
index f51300bc..da41bad3 100644
--- a/libelf/elf.h
+++ b/libelf/elf.h
@@ -4093,8 +4093,11 @@ enum
#define R_NDS32_TLS_DESC 119
/* LoongArch ELF Flags */
-#define EF_LARCH_ABI 0x07
-#define EF_LARCH_ABI_LP64D 0x03
+#define EF_LARCH_ABI_MODIFIER_MASK 0x07
+#define EF_LARCH_ABI_SOFT_FLOAT 0x01
+#define EF_LARCH_ABI_SINGLE_FLOAT 0x02
+#define EF_LARCH_ABI_DOUBLE_FLOAT 0x03
+#define EF_LARCH_OBJABI_V1 0x40
/* LoongArch specific dynamic relocations */
#define R_LARCH_NONE 0
@@ -4156,6 +4159,15 @@ enum
#define R_LARCH_GNU_VTINHERIT 57
#define R_LARCH_GNU_VTENTRY 58
+/* ARC specific declarations. */
+
+/* Processor specific flags for the Ehdr e_flags field. */
+#define EF_ARC_MACH_MSK 0x000000ff
+#define EF_ARC_OSABI_MSK 0x00000f00
+#define EF_ARC_ALL_MSK (EF_ARC_MACH_MSK | EF_ARC_OSABI_MSK)
+
+/* Processor specific values for the Shdr sh_type field. */
+#define SHT_ARC_ATTRIBUTES (SHT_LOPROC + 1) /* ARC attributes section. */
/* ARCompact/ARCv2 specific relocs. */
#define R_ARC_NONE 0x0
@@ -4163,7 +4175,7 @@ enum
#define R_ARC_16 0x2
#define R_ARC_24 0x3
#define R_ARC_32 0x4
-#define R_ARC_B26 0x5
+
#define R_ARC_B22_PCREL 0x6
#define R_ARC_H30 0x7
#define R_ARC_N8 0x8
@@ -4203,16 +4215,23 @@ enum
#define R_ARC_SECTOFF_ME_2 0x2A
#define R_ARC_SECTOFF_1 0x2B
#define R_ARC_SECTOFF_2 0x2C
+#define R_ARC_SDA_12 0x2D
+#define R_ARC_SDA16_ST2 0x30
+#define R_ARC_32_PCREL 0x31
#define R_ARC_PC32 0x32
#define R_ARC_GOTPC32 0x33
#define R_ARC_PLT32 0x34
#define R_ARC_COPY 0x35
#define R_ARC_GLOB_DAT 0x36
-#define R_ARC_JUMP_SLOT 0x37
+#define R_ARC_JMP_SLOT 0x37
#define R_ARC_RELATIVE 0x38
#define R_ARC_GOTOFF 0x39
#define R_ARC_GOTPC 0x3A
#define R_ARC_GOT32 0x3B
+#define R_ARC_S21W_PCREL_PLT 0x3C
+#define R_ARC_S25H_PCREL_PLT 0x3D
+
+#define R_ARC_JLI_SECTOFF 0x3F
#define R_ARC_TLS_DTPMOD 0x42
#define R_ARC_TLS_DTPOFF 0x43
@@ -4221,9 +4240,12 @@ enum
#define R_ARC_TLS_GD_LD 0x46
#define R_ARC_TLS_GD_CALL 0x47
#define R_ARC_TLS_IE_GOT 0x48
-#define R_ARC_TLS_DTPOFF_S9 0x4a
-#define R_ARC_TLS_LE_S9 0x4a
-#define R_ARC_TLS_LE_32 0x4b
+#define R_ARC_TLS_DTPOFF_S9 0x49
+#define R_ARC_TLS_LE_S9 0x4A
+#define R_ARC_TLS_LE_32 0x4B
+#define R_ARC_S25W_PCREL_PLT 0x4C
+#define R_ARC_S21H_PCREL_PLT 0x4D
+#define R_ARC_NPS_CMEM16 0x4E
/* OpenRISC 1000 specific relocs. */
#define R_OR1K_NONE 0
--
2.30.2
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Add support for ARCv2
2022-11-30 23:36 ` Mark Wielaard
@ 2022-12-01 9:44 ` Shahab Vahedi
2022-12-13 14:05 ` Mark Wielaard
0 siblings, 1 reply; 10+ messages in thread
From: Shahab Vahedi @ 2022-12-01 9:44 UTC (permalink / raw)
To: Mark Wielaard
Cc: elfutils-devel, Claudiu Zissulescu, Francois Bedard, Shahab Vahedi
On 12/1/22 00:36, Mark Wielaard wrote:
> Nice. I just synced elf.h.
Thanks a lot Mark! I will send a new patch sans the elf.h and will
add possible test(s) that can be related to it.
--
Shahab
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Add support for ARCv2
2022-12-01 9:44 ` Shahab Vahedi
@ 2022-12-13 14:05 ` Mark Wielaard
2022-12-15 8:49 ` Shahab Vahedi
0 siblings, 1 reply; 10+ messages in thread
From: Mark Wielaard @ 2022-12-13 14:05 UTC (permalink / raw)
To: Shahab Vahedi; +Cc: elfutils-devel, Claudiu Zissulescu, Francois Bedard
Hi Shahab,
On Thu, 2022-12-01 at 09:44 +0000, Shahab Vahedi via Elfutils-devel
wrote:
> On 12/1/22 00:36, Mark Wielaard wrote:
> > Nice. I just synced elf.h.
>
> Thanks a lot Mark! I will send a new patch sans the elf.h and will
> add possible test(s) that can be related to it.
Let me know if I should wait for that or review the v2 patch ignoring
the elf.h changes.
CHeers,
Mark
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH] Add support for ARCv2
2022-12-13 14:05 ` Mark Wielaard
@ 2022-12-15 8:49 ` Shahab Vahedi
0 siblings, 0 replies; 10+ messages in thread
From: Shahab Vahedi @ 2022-12-15 8:49 UTC (permalink / raw)
To: Mark Wielaard; +Cc: elfutils-devel, Claudiu Zissulescu, Francois Bedard
Hi Mark,
On Tue, 2022-12-13 at 15:06, Mark Wielaard via Elfutils-devel wrote:
> Let me know if I should wait for that or review the v2 patch
> ignoring the elf.h changes.
Please ignore v2 of the patch and kindly wait for v3. I will send it
this week (50).
Cheers,
Shahab
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-12-15 8:50 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-28 13:43 [PATCH] Add support for ARCv2 Shahab Vahedi
2022-10-31 14:52 ` [PATCH v2] " Shahab Vahedi
[not found] ` <Y13Tk6e/qsoolka+@wildebeest.org>
2022-10-31 14:54 ` [PATCH] " Shahab Vahedi
2022-11-01 21:01 ` Mark Wielaard
2022-11-09 16:33 ` Shahab Vahedi
2022-11-30 8:15 ` Shahab Vahedi
2022-11-30 23:36 ` Mark Wielaard
2022-12-01 9:44 ` Shahab Vahedi
2022-12-13 14:05 ` Mark Wielaard
2022-12-15 8:49 ` Shahab Vahedi
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).