To print eh human readable description of the ELF e_machine header field
we used the ebl name. But this is not set for most EM constants. Introduce
a new function dwelf_elf_e_machine_string that does work for all known
EM values. Use that in eu-readelf to print a string representation of the
e_machine value.
Since this was the only usage of ebl->name, remove that from struct ebl.
Also add a testcase that makes sure dwelf_elf_e_machine_string works for
all EM values in the libelf/elf.h header so we will immediately notice
when a new value appears.
Signed-off-by: Mark Wielaard
---
backends/ChangeLog | 18 ++
backends/aarch64_init.c | 1 -
backends/alpha_init.c | 1 -
backends/arm_init.c | 1 -
backends/bpf_init.c | 1 -
backends/i386_init.c| 1 -
backends/ia64_init.c| 1 -
backends/m68k_init.c| 1 -
backends/ppc64_init.c | 1 -
backends/ppc_init.c | 1 -
backends/riscv_init.c | 1 -
backends/s390_init.c| 1 -
backends/sh_init.c | 1 -
backends/sparc_init.c | 6 -
backends/tilegx_init.c | 1 -
backends/x86_64_init.c | 1 -
libdw/ChangeLog | 5 +
libdw/libdw.map | 7 +-
libdwelf/ChangeLog | 6 +
libdwelf/Makefile.am| 3 +-
libdwelf/dwelf_elf_e_machine_string.c | 406
libdwelf/libdwelf.h | 4 +
libebl/ChangeLog| 6 +
libebl/eblopenbackend.c | 3 -
libebl/libeblP.h| 3 -
src/ChangeLog | 5 +
src/readelf.c | 7 +-
tests/ChangeLog | 9 +
tests/Makefile.am | 11 +-
tests/dwelf_elf_e_machine_string.c | 64 +
tests/run-dwelf_elf_e_machine_string.sh | 31 +++
31 files changed, 576 insertions(+), 32 deletions(-)
create mode 100644 libdwelf/dwelf_elf_e_machine_string.c
create mode 100644 tests/dwelf_elf_e_machine_string.c
create mode 100755 tests/run-dwelf_elf_e_machine_string.sh
diff --git a/backends/ChangeLog b/backends/ChangeLog
index 6c2b47a..af1a40e 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,21 @@
+2019-06-28 Mark Wielaard
+
+ * aarch64_init.c (aarch64_init.c): Remove eh->name;
+ * alpha_init.c (alpha_init.c): Remove eh->name;
+ * arm_init.c (arm_init.c): Remove eh->name;
+ * bpf_init.c (bpf_init.c): Remove eh->name;
+ * i386_init.c (i386_init.c): Remove eh->name;
+ * ia64_init.c (ia64_init.c): Remove eh->name;
+ * m68k_init.c (m68k_init.c): Remove eh->name;
+ * ppc64_init.c (ppc64_init.c): Remove eh->name;
+ * ppc_init.c (ppc_init.c): Remove eh->name;
+ * riscv_init.c (riscv_init.c): Remove eh->name;
+ * s390_init.c (s390_init.c): Remove eh->name;
+ * sh_init.c (sh_init.c): Remove eh->name;
+ * sparc_init.c (sparc_init.c): Remove eh->name;
+ * tilegx_init.c (tilegx_init.c): Remove eh->name;
+ * x86_64_init.c (x86_64_init.c): Remove eh->name;
+
2019-04-14 Mark Wielaard
* riscv_cfi.c: Fix BACKEND define.
diff --git a/backends/aarch64_init.c b/backends/aarch64_init.c
index fad923f..95268ae 100644
--- a/backends/aarch64_init.c
+++ b/backends/aarch64_init.c
@@ -49,7 +49,6 @@ aarch64_init (Elf *elf __attribute__ ((unused)),
return NULL;
/* We handle it. */
- eh->name = "AARCH64";
aarch64_init_reloc (eh);
HOOK (eh, register_info);
HOOK (eh, core_note);
diff --git a/backends/alpha_init.c b/backends/alpha_init.c
index 25c5b32..f66f40c 100644
--- a/backends/alpha_init.c
+++ b/backends/alpha_init.c
@@ -50,7 +50,6 @@ alpha_init (Elf *elf __attribute__ ((unused)),
return NULL;
/* We handle it. */
- eh->name = "Alpha";
alpha_init_reloc (eh);
HOOK (eh, dynamic_tag_name);
HOOK (eh, dynamic_tag_check);
diff --git a/backends/arm_init.c b/backends/arm_init.c
index f2b1b11..af023f0 100644
--- a/backends/arm_init.c
+++ b/backends/arm_init.c
@@ -50,7 +50,6 @@ arm_init (Elf *elf __attribute__ ((unused)),
return NULL;
/* We handle it. */
- eh->name = "ARM";
arm_init_reloc (eh);
HOOK (eh, segment_type_name);
HOOK (eh, section_type_name);
diff --git a/backends/bpf_init.c b/backends/bpf_init.c
index a046e06..d407d37 100644
--- a/backends/bpf_init.c
+++ b/backends/bpf_init.c
@@ -49,7 +49,6 @@ bpf_init (Elf *elf __attribute__ ((unused)),
return NULL;
/* We handle it. */
- eh->name = "BPF";
bpf_init_reloc (eh);
HOOK (eh, register_info);
HOOK (eh, disasm);
diff --git a/backends/i386_init.c b/backends/i386_init.c
index fc1587a..67428b5 100644
--- a/backends/i386_