Merge "Snap for 5798008 from ba27a85f3d1b11ee4a27b5e42878081a926ce955 to sdk-release" into sdk-release
diff --git a/METADATA b/METADATA
index 6899f9f..0250646 100644
--- a/METADATA
+++ b/METADATA
@@ -9,10 +9,10 @@
     type: GIT
     value: "git://sourceware.org/git/elfutils.git"
   }
-  version: "31c8b3f098b0654db8f573b2a15d5b6d07d4d3b0"
+  version: "1b1433d5670b75c4bd5c9b598e0b00fba6e82d90"
   last_upgrade_date {
     year: 2019
-    month: 7
-    day: 8
+    month: 8
+    day: 7
   }
 }
diff --git a/backends/ChangeLog b/backends/ChangeLog
index 6c2b47a..f1eaf14 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,33 @@
+2019-07-13 Mao Han <han_mao@c-sky.com>
+
+	* Makefile.am: Add C-SKY.
+	* csky_attrs.c: New file.
+	* csky_cfi.c: New file.
+	* csky_corenote.c: Likewise.
+	* csky_init.c: Likewise.
+	* csky_initreg.c: Likewise.
+	* csky_regs.c: Likewise.
+	* csky_reloc.def: Likewise.
+	* csky_symbol.c: Likewise.
+
+2019-06-28  Mark Wielaard  <mark@klomp.org>
+
+	* 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  <mark@klomp.org>
 
 	* riscv_cfi.c: Fix BACKEND define.
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 2126a2e..175468f 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -33,12 +33,13 @@
 
 
 modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \
-	  tilegx m68k bpf riscv
+	  tilegx m68k bpf riscv csky
 libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a    \
 	     libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a    \
 	     libebl_aarch64_pic.a libebl_sparc_pic.a libebl_ppc_pic.a \
 	     libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a \
-	     libebl_m68k_pic.a libebl_bpf_pic.a libebl_riscv_pic.a
+	     libebl_m68k_pic.a libebl_bpf_pic.a libebl_riscv_pic.a    \
+	     libebl_csky_pic.a
 noinst_LIBRARIES = $(libebl_pic)
 noinst_DATA = $(libebl_pic:_pic.a=.so)
 
@@ -136,6 +137,10 @@
 libebl_riscv_pic_a_SOURCES = $(riscv_SRCS)
 am_libebl_riscv_pic_a_OBJECTS = $(riscv_SRCS:.c=.os)
 
+csky_SRCS = csky_attrs.c csky_init.c csky_symbol.c csky_cfi.c \
+	    csky_regs.c csky_initreg.c csky_corenote.c
+libebl_csky_pic_a_SOURCES = $(csky_SRCS)
+am_libebl_csky_pic_a_OBJECTS = $(csky_SRCS:.c=.os)
 
 libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw) $(libeu)
 	@rm -f $(@:.so=.map)
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 @@
     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 @@
     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 @@
     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 @@
     return NULL;
 
   /* We handle it.  */
-  eh->name = "BPF";
   bpf_init_reloc (eh);
   HOOK (eh, register_info);
   HOOK (eh, disasm);
diff --git a/backends/csky_attrs.c b/backends/csky_attrs.c
new file mode 100644
index 0000000..177f0ba
--- /dev/null
+++ b/backends/csky_attrs.c
@@ -0,0 +1,67 @@
+/* C-SKY ABI-specified defaults for DWARF CFI.
+   Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd.
+   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 <string.h>
+#include <dwarf.h>
+
+#define BACKEND csky_
+#include "libebl_CPU.h"
+
+bool
+csky_check_object_attribute (Ebl *ebl __attribute__ ((unused)),
+			    const char *vendor, int tag,
+			    uint64_t value __attribute__ ((unused)),
+			    const char **tag_name,
+			    const char **value_name __attribute__ ((unused)))
+{
+  if (!strcmp (vendor, "csky"))
+    switch (tag)
+      {
+      case 4:
+	*tag_name = "CSKY_ARCH_NAME";
+	return true;
+
+      case 5:
+	*tag_name = "CSKY_CPU_NAME";
+	return true;
+
+      case 6:
+        *tag_name = "CSKY_ISA_FLAGS";
+        return true;
+
+      case 7:
+        *tag_name = "CSKY_ISA_EXT_FLAGS";
+        return true;
+      }
+
+  return false;
+}
diff --git a/backends/csky_cfi.c b/backends/csky_cfi.c
new file mode 100644
index 0000000..7277dbd
--- /dev/null
+++ b/backends/csky_cfi.c
@@ -0,0 +1,60 @@
+/* C-SKY ABI-specified defaults for DWARF CFI.
+   Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd.
+   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 <dwarf.h>
+
+#define BACKEND csky_
+#include "libebl_CPU.h"
+
+
+int
+csky_abi_cfi (Ebl *ebl __attribute__ ((unused)), Dwarf_CIE *abi_info)
+{
+  static const uint8_t abi_cfi[] =
+    {
+      DW_CFA_def_cfa, ULEB128_7 (14), ULEB128_7 (0),
+      DW_CFA_val_offset, ULEB128_7 (14), ULEB128_7 (0),
+
+#define SV(n) DW_CFA_same_value, ULEB128_7 (n)
+      SV(4), SV (5), SV (6), SV (7), SV (8), SV (9),
+      SV(10), SV (11), SV (15), SV (16), SV (17)
+#undef SV
+    };
+
+  abi_info->initial_instructions = abi_cfi;
+  abi_info->initial_instructions_end = &abi_cfi[sizeof abi_cfi];
+  abi_info->data_alignment_factor = -4;
+
+  abi_info->return_address_register = 15; /* lr.  */
+
+  return 0;
+}
diff --git a/backends/csky_corenote.c b/backends/csky_corenote.c
new file mode 100644
index 0000000..a1479bd
--- /dev/null
+++ b/backends/csky_corenote.c
@@ -0,0 +1,61 @@
+/* C-SKY specific core note handling.
+   Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd.
+   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 <elf.h>
+#include <inttypes.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <sys/time.h>
+
+#define BACKEND	csky_
+#include "libebl_CPU.h"
+
+#define	ULONG			uint32_t
+#define PID_T			int32_t
+#define	UID_T			uint32_t
+#define	GID_T			uint32_t
+#define ALIGN_ULONG		4
+#define ALIGN_PID_T		4
+#define ALIGN_UID_T		4
+#define ALIGN_GID_T		4
+#define TYPE_ULONG		ELF_T_WORD
+#define TYPE_PID_T		ELF_T_SWORD
+#define TYPE_UID_T		ELF_T_WORD
+#define TYPE_GID_T		ELF_T_WORD
+
+static const Ebl_Register_Location prstatus_regs[] =
+  {
+    { .offset = 0, .regno = 0, .count = 36, .bits = 32 } /* r0..r31 */
+  };
+#define PRSTATUS_REGS_SIZE	(36 * 4)
+
+#include "linux-core-note.c"
diff --git a/backends/csky_init.c b/backends/csky_init.c
new file mode 100644
index 0000000..b34a03a
--- /dev/null
+++ b/backends/csky_init.c
@@ -0,0 +1,65 @@
+/* Initialization of C-SKY specific backend library.
+   Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd.
+   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		csky_
+#define RELOC_PREFIX	R_CKCORE_
+#include "libebl_CPU.h"
+
+/* This defines the common reloc hooks based on csky_reloc.def.  */
+#include "common-reloc.c"
+
+const char *
+csky_init (Elf *elf __attribute__ ((unused)),
+	   GElf_Half machine __attribute__ ((unused)),
+	   Ebl *eh,
+	   size_t ehlen)
+{
+  /* Check whether the Elf_BH object has a sufficent size.  */
+  if (ehlen < sizeof (Ebl))
+    return NULL;
+
+  /* We handle it.  */
+  csky_init_reloc (eh);
+  HOOK (eh, abi_cfi);
+  HOOK (eh, core_note);
+  HOOK (eh, check_object_attribute);
+  HOOK (eh, machine_flag_check);
+  HOOK (eh, reloc_simple_type);
+  HOOK (eh, register_info);
+  HOOK (eh, section_type_name);
+  HOOK (eh, set_initial_registers_tid);
+
+  /* gcc/config/ #define DWARF_FRAME_REGISTERS.  */
+  eh->frame_nregs = 38;
+
+  return MODVERSION;
+}
diff --git a/backends/csky_initreg.c b/backends/csky_initreg.c
new file mode 100644
index 0000000..81a0da3
--- /dev/null
+++ b/backends/csky_initreg.c
@@ -0,0 +1,87 @@
+/* Fetch live process registers from TID. C-SKY version.
+   Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd.
+   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 "system.h"
+#include <assert.h>
+#if defined __CSKY__ && defined __linux__
+# include <sys/uio.h>
+# include <sys/procfs.h>
+# include <sys/ptrace.h>
+#endif
+
+#define BACKEND csky_
+#include "libebl_CPU.h"
+
+bool
+csky_set_initial_registers_tid (pid_t tid __attribute__ ((unused)),
+			ebl_tid_registers_t *setfunc __attribute__ ((unused)),
+				void *arg __attribute__ ((unused)))
+{
+#if !defined __CSKY__ || !defined __linux__
+  return false;
+#else /* __CSKY__ */
+  struct pt_regs user_regs;
+  struct iovec iovec;
+  iovec.iov_base = &user_regs;
+  iovec.iov_len = sizeof (user_regs);
+  if (ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, &iovec) != 0)
+    return false;
+
+  Dwarf_Word dwarf_regs[38];
+
+  /* lr.  */
+  dwarf_regs[15] = user_regs.lr;
+  /* sp.  */
+  dwarf_regs[14] = user_regs.usp;
+  /* r0 ~ r13.  */
+  dwarf_regs[0] = user_regs.a0;
+  dwarf_regs[1] = user_regs.a1;
+  dwarf_regs[2] = user_regs.a2;
+  dwarf_regs[3] = user_regs.a3;
+  for (int i = 4; i < 14; i++)
+    dwarf_regs[i] = user_regs.regs[i - 4];
+  /* r ~ r13.  */
+  for (int i = 16; i < 31; i++)
+    dwarf_regs[i] = user_regs.exregs[i - 16];
+  /* tls.  */
+  dwarf_regs[31] = user_regs.tls;
+  /* hi.  */
+  dwarf_regs[36] = user_regs.rhi;
+  /* lo.  */
+  dwarf_regs[37] = user_regs.rlo;
+  /* pc.  */
+  dwarf_regs[32] = user_regs.pc;
+  setfunc (-1, 1, &dwarf_regs[32], arg);
+
+  return setfunc (0, 38, dwarf_regs, arg);
+#endif
+}
diff --git a/backends/csky_regs.c b/backends/csky_regs.c
new file mode 100644
index 0000000..6d45c04
--- /dev/null
+++ b/backends/csky_regs.c
@@ -0,0 +1,101 @@
+/* Register names and numbers for C-SKY DWARF.
+   Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd.
+   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 <string.h>
+#include <dwarf.h>
+
+#define BACKEND csky_
+#include "libebl_CPU.h"
+
+ssize_t
+csky_register_info (Ebl *ebl  __attribute__ ((unused)),
+		    int regno, char *name, size_t namelen,
+		    const char **prefix, const char **setname,
+		    int *bits, int *type)
+{
+  if (name == NULL)
+    return 38;
+
+  *prefix = "";
+  *bits = 32;
+  *type = DW_ATE_signed;
+  *setname = "integer";
+
+  switch (regno)
+    {
+    case 0 ... 9:
+      name[0] = 'r';
+      name[1] = regno + '0';
+      namelen = 2;
+      break;
+
+    case 10 ... 13:
+    case 16 ... 30:
+      name[0] = 'r';
+      name[1] = regno / 10 + '0';
+      name[2] = regno % 10 + '0';
+      namelen = 3;
+      break;
+
+    case 14:
+      stpcpy (name, "sp");
+      namelen = 2;
+      break;
+
+    case 15:
+      stpcpy (name, "lr");
+      namelen = 2;
+      break;
+
+    case 31:
+      stpcpy (name, "tls");
+      namelen = 3;
+      break;
+
+    case 36:
+      stpcpy (name, "hi");
+      namelen = 2;
+      break;
+
+    case 37:
+      stpcpy (name, "lo");
+      namelen = 2;
+      break;
+
+    default:
+      *setname = NULL;
+      return 0;
+    }
+
+  name[namelen++] = '\0';
+  return namelen;
+}
diff --git a/backends/csky_reloc.def b/backends/csky_reloc.def
new file mode 100644
index 0000000..1108f0c
--- /dev/null
+++ b/backends/csky_reloc.def
@@ -0,0 +1,86 @@
+/* List the relocation types for csky.  -*- C -*-
+   Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd.
+   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,		REL|EXEC|DYN)
+RELOC_TYPE (ADDR32,		REL|EXEC|DYN)
+RELOC_TYPE (PCRELIMM8BY4,	REL)
+RELOC_TYPE (PCRELIMM11BY2,	REL)
+RELOC_TYPE (PCREL32,		REL|DYN)
+RELOC_TYPE (PCRELJSR_IMM11BY2,	REL)
+RELOC_TYPE (RELATIVE,		EXEC|DYN)
+RELOC_TYPE (COPY,		EXEC|DYN)
+RELOC_TYPE (GLOB_DAT,		EXEC|DYN)
+RELOC_TYPE (JUMP_SLOT,		EXEC|DYN)
+RELOC_TYPE (GOTOFF,		REL)
+RELOC_TYPE (GOTPC,		REL)
+RELOC_TYPE (GOT32,		REL)
+RELOC_TYPE (PLT32,		REL)
+RELOC_TYPE (ADDRGOT,		REL)
+RELOC_TYPE (ADDRPLT,		REL)
+RELOC_TYPE (PCREL_IMM26BY2,	REL)
+RELOC_TYPE (PCREL_IMM16BY2,	REL)
+RELOC_TYPE (PCREL_IMM16BY4,	REL)
+RELOC_TYPE (PCREL_IMM10BY2,	REL)
+RELOC_TYPE (PCREL_IMM10BY4,	REL)
+RELOC_TYPE (ADDR_HI16,		REL|DYN)
+RELOC_TYPE (ADDR_LO16,		REL|DYN)
+RELOC_TYPE (GOTPC_HI16,		REL)
+RELOC_TYPE (GOTPC_LO16,		REL)
+RELOC_TYPE (GOTOFF_HI16,	REL)
+RELOC_TYPE (GOTOFF_LO16,	REL)
+RELOC_TYPE (GOT12,		REL)
+RELOC_TYPE (GOT_HI16,		REL)
+RELOC_TYPE (GOT_LO16,		REL)
+RELOC_TYPE (PLT12,		REL)
+RELOC_TYPE (PLT_HI16,		REL)
+RELOC_TYPE (PLT_LO16,		REL)
+RELOC_TYPE (ADDRGOT_HI16,	REL)
+RELOC_TYPE (ADDRGOT_LO16,	REL)
+RELOC_TYPE (ADDRPLT_HI16,	REL)
+RELOC_TYPE (ADDRPLT_LO16,	REL)
+RELOC_TYPE (PCREL_JSR_IMM26BY2,	REL|DYN)
+RELOC_TYPE (TOFFSET_LO16,	REL)
+RELOC_TYPE (DOFFSET_LO16,	REL)
+RELOC_TYPE (PCREL_IMM18BY2,	REL)
+RELOC_TYPE (DOFFSET_IMM18,	REL)
+RELOC_TYPE (DOFFSET_IMM18BY2,	REL)
+RELOC_TYPE (DOFFSET_IMM18BY4,	REL)
+RELOC_TYPE (GOT_IMM18BY4,	REL)
+RELOC_TYPE (PLT_IMM18BY4,	REL)
+RELOC_TYPE (PCREL_IMM7BY4,	REL)
+RELOC_TYPE (TLS_LE32,		REL)
+RELOC_TYPE (TLS_IE32,		REL)
+RELOC_TYPE (TLS_GD32,		REL)
+RELOC_TYPE (TLS_LDM32,		REL)
+RELOC_TYPE (TLS_LDO32,		REL)
+RELOC_TYPE (TLS_DTPMOD32,	EXEC|DYN)
+RELOC_TYPE (TLS_DTPOFF32,	EXEC|DYN)
+RELOC_TYPE (TLS_TPOFF32,	EXEC|DYN)
diff --git a/backends/csky_symbol.c b/backends/csky_symbol.c
new file mode 100644
index 0000000..79b5bf9
--- /dev/null
+++ b/backends/csky_symbol.c
@@ -0,0 +1,77 @@
+/* C-SKY specific symbolic name handling.
+   Copyright (C) 2019 Hangzhou C-SKY Microsystems co.,ltd.
+   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 csky_
+#include "libebl_CPU.h"
+
+/* Check for the simple reloc types.  */
+Elf_Type
+csky_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type,
+			int *addsub __attribute__ ((unused)))
+{
+  switch (type)
+    {
+    case R_CKCORE_ADDR32:
+      return ELF_T_WORD;
+    default:
+      return ELF_T_NUM;
+    }
+}
+
+bool
+csky_machine_flag_check (GElf_Word flags)
+{
+  switch (flags & EF_CSKY_ABIMASK)
+    {
+    case EF_CSKY_ABIV2:
+      return true;
+    case EF_CSKY_ABIV1:
+    default:
+      return false;
+    }
+}
+
+const char *
+csky_section_type_name (int type,
+		       char *buf __attribute__ ((unused)),
+		       size_t len __attribute__ ((unused)))
+{
+  if (type == SHT_CSKY_ATTRIBUTES)
+    return "CSKY_ATTRIBUTES";
+
+  return NULL;
+}
diff --git a/backends/i386_init.c b/backends/i386_init.c
index fc1587a..67428b5 100644
--- a/backends/i386_init.c
+++ b/backends/i386_init.c
@@ -49,7 +49,6 @@
     return NULL;
 
   /* We handle it.  */
-  eh->name = "Intel 80386";
   i386_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
   HOOK (eh, gotpc_reloc_check);
diff --git a/backends/ia64_init.c b/backends/ia64_init.c
index 7241d7b..2d1f43f 100644
--- a/backends/ia64_init.c
+++ b/backends/ia64_init.c
@@ -49,7 +49,6 @@
     return NULL;
 
   /* We handle it.  */
-  eh->name = "Intel IA-64";
   ia64_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
   HOOK (eh, segment_type_name);
diff --git a/backends/m68k_init.c b/backends/m68k_init.c
index 8cae710..05d544c 100644
--- a/backends/m68k_init.c
+++ b/backends/m68k_init.c
@@ -48,7 +48,6 @@
     return NULL;
 
   /* We handle it.  */
-  eh->name = "M68K";
   m68k_init_reloc (eh);
   HOOK (eh, gotpc_reloc_check);
   HOOK (eh, reloc_simple_type);
diff --git a/backends/ppc64_init.c b/backends/ppc64_init.c
index 3db5e76..c2e7043 100644
--- a/backends/ppc64_init.c
+++ b/backends/ppc64_init.c
@@ -52,7 +52,6 @@
     return NULL;
 
   /* We handle it.  */
-  eh->name = "PowerPC 64-bit";
   ppc64_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
   HOOK (eh, dynamic_tag_name);
diff --git a/backends/ppc_init.c b/backends/ppc_init.c
index aea9f2d..eb286c2 100644
--- a/backends/ppc_init.c
+++ b/backends/ppc_init.c
@@ -50,7 +50,6 @@
     return NULL;
 
   /* We handle it.  */
-  eh->name = "PowerPC";
   ppc_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
   HOOK (eh, machine_flag_check);
diff --git a/backends/riscv_init.c b/backends/riscv_init.c
index 3398c10..9aaec9c 100644
--- a/backends/riscv_init.c
+++ b/backends/riscv_init.c
@@ -54,7 +54,6 @@
     return NULL;
 
   /* We handle it.  */
-  eh->name = "RISC-V";
   riscv_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
   HOOK (eh, register_info);
diff --git a/backends/s390_init.c b/backends/s390_init.c
index 0004aee..b4f3e7f 100644
--- a/backends/s390_init.c
+++ b/backends/s390_init.c
@@ -51,7 +51,6 @@
     return NULL;
 
   /* We handle it.  */
-  eh->name = "IBM S/390";
   s390_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
   HOOK (eh, check_special_symbol);
diff --git a/backends/sh_init.c b/backends/sh_init.c
index 5526aca..24f4d4a 100644
--- a/backends/sh_init.c
+++ b/backends/sh_init.c
@@ -50,7 +50,6 @@
     return NULL;
 
   /* We handle it.  */
-  eh->name = "Hitachi SH";
   sh_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
   HOOK (eh, gotpc_reloc_check);
diff --git a/backends/sparc_init.c b/backends/sparc_init.c
index 8e946fb..6daff11 100644
--- a/backends/sparc_init.c
+++ b/backends/sparc_init.c
@@ -55,12 +55,6 @@
     return NULL;
 
   /* We handle it.  */
-  if (machine == EM_SPARCV9)
-    eh->name = "SPARC v9";
-  else if (machine == EM_SPARC32PLUS)
-    eh->name = "SPARC v8+";
-  else
-    eh->name = "SPARC";
   sparc_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
   HOOK (eh, machine_flag_check);
diff --git a/backends/tilegx_init.c b/backends/tilegx_init.c
index 162ed36..66df931 100644
--- a/backends/tilegx_init.c
+++ b/backends/tilegx_init.c
@@ -48,7 +48,6 @@
     return NULL;
 
   /* We handle it.  */
-  eh->name = "TILE-Gx";
   tilegx_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
   HOOK (eh, return_value_location);
diff --git a/backends/x86_64_init.c b/backends/x86_64_init.c
index 49f6c6c..8abafb7 100644
--- a/backends/x86_64_init.c
+++ b/backends/x86_64_init.c
@@ -52,7 +52,6 @@
     return NULL;
 
   /* We handle it.  */
-  eh->name = "AMD x86-64";
   x86_64_init_reloc (eh);
   HOOK (eh, reloc_simple_type);
   HOOK (eh, section_type_name);
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 4760f9d..6b779e7 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
+2019-06-28  Mark Wielaard  <mark@klomp.org>
+
+	* libdw.map (ELFUTILS_0.177): New section. Add
+	dwelf_elf_e_machine_string.
+
 2019-05-16  Mark Wielaard  <mark@klomp.org>
 
 	* dwarf.h: Add DW_AT_GNU_numerator, DW_AT_GNU_denominator and
diff --git a/libdw/libdw.map b/libdw/libdw.map
index 55482d5..2e1c0e9 100644
--- a/libdw/libdw.map
+++ b/libdw/libdw.map
@@ -360,4 +360,9 @@
 ELFUTILS_0.175 {
   global:
     dwelf_elf_begin;
-} ELFUTILS_0.173;
\ No newline at end of file
+} ELFUTILS_0.173;
+
+ELFUTILS_0.177 {
+  global:
+    dwelf_elf_e_machine_string;
+} ELFUTILS_0.175;
diff --git a/libdwelf/ChangeLog b/libdwelf/ChangeLog
index 88be342..29f9a50 100644
--- a/libdwelf/ChangeLog
+++ b/libdwelf/ChangeLog
@@ -1,3 +1,9 @@
+2019-06-28  Mark Wielaard  <mark@klomp.org>
+
+	* Makefile.am (libdwelf_a_SOURCES): Add dwelf_elf_e_machine_string.c.
+	* libdwelf.h (dwelf_elf_e_machine_string): Define new function.
+	* dwelf_elf_e_machine_string.c: New file.
+
 2018-10-21  Mark Wielaard  <mark@klomp.org>
 
 	* libdwelf.h (dwelf_elf_begin): Add function declaration.
diff --git a/libdwelf/Makefile.am b/libdwelf/Makefile.am
index a7933fd..a35a287 100644
--- a/libdwelf/Makefile.am
+++ b/libdwelf/Makefile.am
@@ -41,7 +41,8 @@
 
 libdwelf_a_SOURCES = dwelf_elf_gnu_debuglink.c dwelf_dwarf_gnu_debugaltlink.c \
 		     dwelf_elf_gnu_build_id.c dwelf_scn_gnu_compressed_size.c \
-		     dwelf_strtab.c dwelf_elf_begin.c
+		     dwelf_strtab.c dwelf_elf_begin.c \
+		     dwelf_elf_e_machine_string.c
 
 libdwelf = $(libdw)
 
diff --git a/libdwelf/dwelf_elf_e_machine_string.c b/libdwelf/dwelf_elf_e_machine_string.c
new file mode 100644
index 0000000..de07b01
--- /dev/null
+++ b/libdwelf/dwelf_elf_e_machine_string.c
@@ -0,0 +1,406 @@
+/* Returns a human readable description of an ELF header e_machine value.
+   Copyright (C) 2019 Red Hat, 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
+
+#include "libdwelf.h"
+
+
+const char *
+dwelf_elf_e_machine_string (int machine)
+{
+  switch (machine)
+    {
+    case EM_NONE:
+      return "None";
+    case EM_M32:
+      return "WE32100";
+    case EM_SPARC:
+      return "SPARC";
+    case EM_386:
+      return "Intel 80386";
+    case EM_68K:
+      return "M68K";
+    case EM_88K:
+      return "M88K";
+    case EM_IAMCU:
+      return "Intel MCU";
+    case EM_860:
+      return "Intel 80860";
+    case EM_MIPS:
+      return "MIPS R3000";
+    case EM_S370:
+      return "IBM System/370";
+    case EM_MIPS_RS3_LE:
+      return "MIPS R3000";
+    case EM_PARISC:
+      return "HPPA";
+    case EM_VPP500:
+      return "Fujitsu VPP500";
+    case EM_SPARC32PLUS:
+      return "SPARC v8+";
+    case EM_960:
+      return "Intel 80960";
+    case EM_PPC:
+      return "PowerPC";
+    case EM_PPC64:
+      return "PowerPC64";
+    case EM_S390:
+      return "IBM S/390";
+    case EM_SPU:
+      return "IBM SPU/SPC";
+    case EM_V800:
+      return "NEC V800";
+    case EM_FR20:
+      return "Fujitsu FR20";
+    case EM_RH32:
+      return "TRW RH-32";
+    case EM_RCE:
+      return "Motorola RCE";
+    case EM_ARM:
+      return "ARM";
+    case EM_FAKE_ALPHA:
+      return "Digital Alpha";
+    case EM_SH:
+      return "SH";
+    case EM_SPARCV9:
+      return "SPARC v9";
+    case EM_TRICORE:
+      return "Siemens Tricore";
+    case EM_ARC:
+      return "ARC";
+    case EM_H8_300:
+      return "H8/300";
+    case EM_H8_300H:
+      return "H8/300H";
+    case EM_H8S:
+      return "H8S";
+    case EM_H8_500:
+      return "H8/500";
+    case EM_IA_64:
+      return "Intel IA-64";
+    case EM_MIPS_X:
+      return "Stanford MIPS-X";
+    case EM_COLDFIRE:
+      return "Motorola Coldfire";
+    case EM_68HC12:
+      return "Motorola M68HC12";
+    case EM_MMA:
+      return "Fujitsu MMA Multimedia Accelerator";
+    case EM_PCP:
+      return "Siemens PCP";
+    case EM_NCPU:
+      return "Sony nCPU embeded RISC";
+    case EM_NDR1:
+      return "Denso NDR1 microprocessor";
+    case EM_STARCORE:
+      return "Motorola Star*Core processor";
+    case EM_ME16:
+      return "Toyota ME16 processor";
+    case EM_ST100:
+      return "STMicroelectronic ST100";
+    case EM_TINYJ:
+      return "Advanced Logic Corporation Tinyj";
+    case EM_X86_64:
+      return "AMD x86-64";
+    case EM_PDSP:
+      return "Sony DSP Processor";
+    case EM_PDP10:
+      return "Digital PDP-10";
+    case EM_PDP11:
+      return "Digital PDP-11";
+    case EM_FX66:
+      return "Siemens FX66 microcontroller";
+    case EM_ST9PLUS:
+      return "STMicroelectronics ST9+";
+    case EM_ST7:
+      return "STMicroelectronics ST7";
+    case EM_68HC16:
+      return "Motorola MC68HC16 microcontroller";
+    case EM_68HC11:
+      return "Motorola MC68HC11 microcontroller";
+    case EM_68HC08:
+      return "Motorola MC68HC08 microcontroller";
+    case EM_68HC05:
+      return "Motorola MC68HC05 microcontroller";
+    case EM_SVX:
+      return "Silicon Graphics SVx";
+    case EM_ST19:
+      return "STMicroelectronics ST19";
+    case EM_VAX:
+      return "Digital VAX";
+    case EM_CRIS:
+      return "Axis Communications 32-bit embedded processor";
+    case EM_JAVELIN:
+      return "Infineon Technologies 32-bit embedded processor";
+    case EM_FIREPATH:
+      return "Element 14 64-bit DSP Processor";
+    case EM_ZSP:
+      return "LSI Logic 16-bit DSP Processor";
+    case EM_MMIX:
+      return "Donald Knuth's educational 64-bit processor";
+    case EM_HUANY:
+      return "Harvard University machine-independent object";
+    case EM_PRISM:
+      return "SiTera Prism";
+    case EM_AVR:
+      return "Atmel AVR 8-bit microcontroller";
+    case EM_FR30:
+      return "Fujitsu FR30";
+    case EM_D10V:
+      return "Mitsubishi D10V";
+    case EM_D30V:
+      return "Mitsubishi D30V";
+    case EM_V850:
+      return "NEC v850";
+    case EM_M32R:
+      return "Mitsubishi M32R";
+    case EM_MN10300:
+      return "Matsushita MN10300";
+    case EM_MN10200:
+      return "Matsushita MN10200";
+    case EM_PJ:
+      return "picoJava";
+    case EM_OPENRISC:
+      return "OpenRISC";
+    case EM_ARC_COMPACT:
+      return "ARC International ARCompact";
+    case EM_XTENSA:
+      return "Tensilica Xtensa Architecture";
+    case EM_VIDEOCORE:
+      return "Alphamosaic VideoCore";
+    case EM_TMM_GPP:
+      return "Thompson Multimedia General Purpose Processor";
+    case EM_NS32K:
+      return "National Semiconductor 32000";
+    case EM_TPC:
+      return "Tenor Network TPC";
+    case EM_SNP1K:
+      return "Trebia SNP 1000";
+    case EM_ST200:
+      return "STMicroelectronics ST200";
+    case EM_IP2K:
+      return "Ubicom IP2xxx";
+    case EM_MAX:
+      return "MAX processor";
+    case EM_CR:
+      return "National Semiconductor CompactRISC";
+    case EM_F2MC16:
+      return "Fujitsu F2MC16";
+    case EM_MSP430:
+      return "Texas Instruments msp430";
+    case EM_BLACKFIN:
+      return "Analog Devices Blackfin DSP";
+    case EM_SE_C33:
+      return "Seiko Epson S1C33";
+    case EM_SEP:
+      return "Sharp embedded microprocessor";
+    case EM_ARCA:
+      return "Arca RISC";
+    case EM_UNICORE:
+      return "Unicore";
+    case EM_EXCESS:
+      return "eXcess configurable CPU";
+    case EM_DXP:
+      return "Icera Semiconductor Deep Execution Processor";
+    case EM_ALTERA_NIOS2:
+      return "Altera Nios II";
+    case EM_CRX:
+      return "National Semiconductor CompactRISC CRX";
+    case EM_XGATE:
+      return "Motorola XGATE";
+    case EM_C166:
+      return "Infineon C16x/XC16x";
+    case EM_M16C:
+      return "Renesas M16C";
+    case EM_DSPIC30F:
+      return "Microchip Technology dsPIC30F";
+    case EM_CE:
+      return "Freescale Communication Engine RISC";
+    case EM_M32C:
+      return "Renesas M32C";
+    case EM_TSK3000:
+      return "Altium TSK3000";
+    case EM_RS08:
+      return "Freescale RS08";
+    case EM_SHARC:
+      return "Analog Devices SHARC";
+    case EM_ECOG2:
+      return "Cyan Technology eCOG2";
+    case EM_SCORE7:
+      return "Sunplus S+core7 RISC";
+    case EM_DSP24:
+      return "New Japan Radio (NJR) 24-bit DSP";
+    case EM_VIDEOCORE3:
+      return "Broadcom VideoCore III";
+    case EM_LATTICEMICO32:
+      return "RISC for Lattice FPGA";
+    case EM_SE_C17:
+      return "Seiko Epson C17";
+    case EM_TI_C6000:
+      return "Texas Instruments TMS320C6000 DSP";
+    case EM_TI_C2000:
+      return "Texas Instruments TMS320C2000 DSP";
+    case EM_TI_C5500:
+      return "Texas Instruments TMS320C55x DSP";
+    case EM_TI_ARP32:
+      return "Texas Instruments Application Specific RISC";
+    case EM_TI_PRU:
+      return "Texas Instruments Programmable Realtime Unit";
+    case EM_MMDSP_PLUS:
+      return "STMicroelectronics 64bit VLIW DSP";
+    case EM_CYPRESS_M8C:
+      return "Cypress M8C";
+    case EM_R32C:
+      return "Renesas R32C";
+    case EM_TRIMEDIA:
+      return "NXP Semiconductors TriMedia";
+    case EM_QDSP6:
+      return "QUALCOMM DSP6";
+    case EM_8051:
+      return "Intel 8051 and variants";
+    case EM_STXP7X:
+      return "STMicroelectronics STxP7x";
+    case EM_NDS32:
+      return "Andes Technology compact code size embeded RISC";
+    case EM_ECOG1X:
+      return "Cyan Technology eCOG1X";
+    case EM_MAXQ30:
+      return "Dallas Semicondutor MAXQ30";
+    case EM_XIMO16:
+      return "New Japan Radio (NJR) 16-bit DSP";
+    case EM_MANIK:
+      return "M2000 Reconfigurable RISC";
+    case EM_CRAYNV2:
+      return "Cray NV2 vector architecture";
+    case EM_RX:
+      return "Renesas RX";
+    case EM_METAG:
+      return "Imagination Technologies META";
+    case EM_MCST_ELBRUS:
+      return "MCST Elbrus";
+    case EM_ECOG16:
+      return "Cyan Technology eCOG16";
+    case EM_CR16:
+      return "National Semiconductor CompactRISC";
+    case EM_ETPU:
+      return "Freescale Extended Time Processing Unit";
+    case EM_SLE9X:
+      return "Infineon Technologies SLE9X";
+    case EM_L10M:
+      return "Intel L10M";
+    case EM_K10M:
+      return "Intel K10M";
+    case EM_AARCH64:
+      return "AARCH64";
+    case EM_AVR32:
+      return "Amtel AVR32";
+    case EM_STM8:
+      return "STMicroelectronics STM8";
+    case EM_TILE64:
+      return "Tilera TILE64";
+    case EM_TILEPRO:
+      return "Tilera TILEPro";
+    case EM_MICROBLAZE:
+      return "Xilinx MicroBlaze";
+    case EM_CUDA:
+      return "NVIDIA CUDA";
+    case EM_TILEGX:
+      return "Tilera TILE-Gx";
+    case EM_CLOUDSHIELD:
+      return "CloudShield";
+    case EM_COREA_1ST:
+      return "KIPO-KAIST Core-A 1st gen";
+    case EM_COREA_2ND:
+      return "KIPO-KAIST Core-A 2nd gen";
+    case EM_ARC_COMPACT2:
+      return "Synopsys ARCompact V2";
+    case EM_OPEN8:
+      return "Open8 RISC";
+    case EM_RL78:
+      return "Renesas RL78";
+    case EM_VIDEOCORE5:
+      return "Broadcom VideoCore V";
+    case EM_78KOR:
+      return "Renesas 78KOR";
+    case EM_56800EX:
+      return "Freescale 56800EX DSC";
+    case EM_BA1:
+      return "Beyond BA1";
+    case EM_BA2:
+      return "Beyond BA2";
+    case EM_XCORE:
+      return "XMOS xCORE";
+    case EM_MCHP_PIC:
+      return "Microchip 8-bit PIC";
+    case EM_KM32:
+      return "KM211 KM32";
+    case EM_KMX32:
+      return "KM211 KMX32";
+    case EM_EMX16:
+      return "KM211 KMX16";
+    case EM_EMX8:
+      return "KM211 KMX8";
+    case EM_KVARC:
+      return "KM211 KVARC";
+    case EM_CDP:
+      return "Paneve CDP";
+    case EM_COGE:
+      return "Cognitive Smart Memory Processor";
+    case EM_COOL:
+      return "Bluechip CoolEngine";
+    case EM_NORC:
+      return "Nanoradio Optimized RISC";
+    case EM_CSR_KALIMBA:
+      return "CSR Kalimba";
+    case EM_Z80:
+      return "Zilog Z80";
+    case EM_VISIUM:
+      return "CDS VISIUMcore";
+    case EM_FT32:
+      return "FTDI Chip FT32";
+    case EM_MOXIE:
+      return "Moxie";
+    case EM_AMDGPU:
+      return "AMD GPU";
+    case EM_RISCV:
+      return "RISC-V";
+    case EM_BPF:
+      return "BPF";
+    case EM_CSKY:
+      return "C-SKY";
+
+    case EM_ALPHA:
+      return "Alpha";
+
+    default:
+      return NULL;
+    }
+}
diff --git a/libdwelf/libdwelf.h b/libdwelf/libdwelf.h
index 6d49184..cb7ea09 100644
--- a/libdwelf/libdwelf.h
+++ b/libdwelf/libdwelf.h
@@ -133,6 +133,10 @@
    file handle will not be closed.  Does not return ELF_K_NONE handles.  */
 extern Elf *dwelf_elf_begin (int fd);
 
+/* Returns a human readable string for the given ELF header e_machine
+   value, or NULL if the given number isn't currently known.  */
+extern const char *dwelf_elf_e_machine_string (int machine);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 8a7d177..bb91c15 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,13 @@
+2019-04-29 Mao Han <han_mao@c-sky.com>
+
+	* eblopenbackend.c: Add C-SKY.
+
+2019-06-28  Mark Wielaard  <mark@klomp.org>
+
+	* eblopenbackend.c (try_dlopen): Remove result->name check.
+	(openbackend): Remove result->name assignment.
+	(struct ebl): Remove name.
+
 2019-05-30  Mark Wielaard  <mark@klomp.org>
 
 	* eblopenbackend.c (try_dlopen): New function extracted from
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index 36a2492..01711f5 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -135,6 +135,7 @@
   { "bpf", "elf_bpf", "bpf", 3, EM_BPF, 0, 0 },
   { "riscv", "elf_riscv", "riscv", 5, EM_RISCV, ELFCLASS64, ELFDATA2LSB },
   { "riscv", "elf_riscv", "riscv", 5, EM_RISCV, ELFCLASS32, ELFDATA2LSB },
+  { "csky", "elf_csky", "csky", 4, EM_CSKY, ELFCLASS32, ELFDATA2LSB },
 };
 #define nmachines (sizeof (machines) / sizeof (machines[0]))
 
@@ -283,7 +284,6 @@
 	  result->elf = elf;
 
 	  /* A few entries are mandatory.  */
-	  assert (result->name != NULL);
 	  assert (result->destr != NULL);
 
 	  return result;
@@ -398,7 +398,6 @@
 	   Return that information.  */
 	result->dlhandle = NULL;
 	result->elf = elf;
-	result->name = machines[cnt].prefix;
 	fill_defaults (result);
 
 	return result;
@@ -408,7 +407,6 @@
   result->dlhandle = NULL;
   result->elf = elf;
   result->emulation = "<unknown>";
-  result->name = "<unknown>";
   fill_defaults (result);
 
   return result;
diff --git a/libebl/libeblP.h b/libebl/libeblP.h
index 5b339b3..a586968 100644
--- a/libebl/libeblP.h
+++ b/libebl/libeblP.h
@@ -38,9 +38,6 @@
 /* Backend handle.  */
 struct ebl
 {
-  /* Machine name.  */
-  const char *name;
-
   /* Emulation name.  */
   const char *emulation;
 
diff --git a/src/ChangeLog b/src/ChangeLog
index c78e6fa..911ad26 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
+2019-07-13 Mao Han <han_mao@c-sky.com>
+
+	* elflint.c: Add C-SKY.
+
+2019-06-28  Mark Wielaard  <mark@klomp.org>
+
+	* readelf.c (print_ehdr): Use dwelf_elf_e_machine_string instead of
+	ebl->name. If unknown print hex value.
+
 2019-06-25  Mark Wielaard  <mark@klomp.org>
 
 	* stack.c (parse_opt): Fix dwfl_core_file_attach error message.
diff --git a/src/elflint.c b/src/elflint.c
index 810c8bd..edb466d 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -330,7 +330,7 @@
     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_TILEGX, EM_TILEPRO, EM_AARCH64, EM_BPF, EM_RISCV, EM_CSKY
   };
 #define nvalid_e_machine \
   (sizeof (valid_e_machine) / sizeof (valid_e_machine[0]))
diff --git a/src/readelf.c b/src/readelf.c
index 062168b..2084fb1 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -1084,7 +1084,12 @@
   fputs_unlocked (gettext ("  Type:                              "), stdout);
   print_file_type (ehdr->e_type);
 
-  printf (gettext ("  Machine:                           %s\n"), ebl->name);
+  const char *machine = dwelf_elf_e_machine_string (ehdr->e_machine);
+  if (machine != NULL)
+    printf (gettext ("  Machine:                           %s\n"), machine);
+  else
+    printf (gettext ("  Machine:                           <unknown>: 0x%x\n"),
+	    ehdr->e_machine);
 
   printf (gettext ("  Version:                           %d %s\n"),
 	  ehdr->e_version,
@@ -3566,7 +3571,9 @@
 
       if (shdr == NULL || (shdr->sh_type != SHT_GNU_ATTRIBUTES
 			   && (shdr->sh_type != SHT_ARM_ATTRIBUTES
-			       || ehdr->e_machine != EM_ARM)))
+			       || ehdr->e_machine != EM_ARM)
+			   && (shdr->sh_type != SHT_CSKY_ATTRIBUTES
+			       || ehdr->e_machine != EM_CSKY)))
 	continue;
 
       printf (gettext ("\
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 400588f..63d6af9 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,21 @@
+2019-07-16  Mao Han  <han_mao@c-sky.com>
+
+	* hello_csky.ko.bz2: New testfile.
+	* run-addrcfi.sh: Add C-SKY testfile.
+	* run-strip-reloc.sh: Likewise.
+	* testfilecsky.bz2: New testfile.
+	* Makefile.am (EXTRA_DIST): Add hello_csky.ko.bz2 and
+	testfilecsky.bz2.
+
+2019-06-28  Mark Wielaard  <mark@klomp.org>
+
+	* Makefile.am (check_PROGRAMS): Add dwelf_elf_e_machine_string.
+	(TESTS): Add run-dwelf_elf_e_machine_string.sh.
+	(EXTRA_DIST): Likewise.
+	(dwelf_elf_e_machine_string_LDADD): New variable.
+	* dwelf_elf_e_machine_string.c: New file.
+	* run-dwelf_elf_e_machine_string.sh: New test.
+
 2019-07-01  Mark Wielaard  <mark@klomp.org>
 
 	* run-large-elf-file.sh: Add 2GB to mem_needed when running under
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3d95cf6..0ac3531 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -60,7 +60,8 @@
 		  fillfile dwarf_default_lower_bound dwarf-die-addr-die \
 		  get-units-invalid get-units-split attr-integrate-skel \
 		  all-dwarf-ranges unit-info next_cfi \
-		  elfcopy addsections xlate_notes elfrdwrnop
+		  elfcopy addsections xlate_notes elfrdwrnop \
+		  dwelf_elf_e_machine_string
 
 asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
 	    asm-tst6 asm-tst7 asm-tst8 asm-tst9
@@ -162,7 +163,8 @@
 	run-copyadd-sections.sh run-copymany-sections.sh \
 	run-typeiter-many.sh run-strip-test-many.sh \
 	run-strip-version.sh run-xlate-note.sh \
-	run-readelf-discr.sh
+	run-readelf-discr.sh \
+	run-dwelf_elf_e_machine_string.sh
 
 if !BIARCH
 export ELFUTILS_DISABLE_BIARCH = 1
@@ -210,7 +212,7 @@
 	     testfile-nobitsalign.bz2 testfile-nobitsalign.strip.bz2 \
 	     run-strip-reloc.sh hello_i386.ko.bz2 hello_x86_64.ko.bz2 \
 	     hello_ppc64.ko.bz2 hello_s390.ko.bz2 hello_aarch64.ko.bz2 \
-	     hello_m68k.ko.bz2 hello_riscv64.ko.bz2 \
+	     hello_m68k.ko.bz2 hello_riscv64.ko.bz2 hello_csky.ko.bz2 \
 	     run-unstrip-test.sh run-unstrip-test2.sh \
 	     testfile-info-link.bz2 testfile-info-link.debuginfo.bz2 \
 	     testfile-info-link.stripped.bz2 run-unstrip-test3.sh \
@@ -227,6 +229,7 @@
 	     testfile11-debugframe.bz2 testfile12-debugframe.bz2 \
 	     testfileaarch64-debugframe.bz2 testfilearm-debugframe.bz2 \
 	     testfileppc32-debugframe.bz2 testfileppc64-debugframe.bz2 \
+	     testfilecsky.bz2 \
 	     run-varlocs-self.sh run-exprlocs-self.sh \
 	     run-find-prologues.sh run-allregs.sh run-native-test.sh \
 	     run-addrname-test.sh run-dwfl-bug-offline-rel.sh \
@@ -431,7 +434,9 @@
 	     run-strip-version.sh testfile-version.bz2 \
 	     run-xlate-note.sh \
 	     run-readelf-discr.sh \
-	     testfile-rng.debug.bz2 testfile-urng.debug.bz2
+	     testfile-rng.debug.bz2 testfile-urng.debug.bz2 \
+	     run-dwelf_elf_e_machine_string.sh
+
 
 if USE_VALGRIND
 valgrind_cmd='valgrind -q --leak-check=full --error-exitcode=1'
@@ -603,6 +608,7 @@
 addsections_LDADD = $(libelf)
 xlate_notes_LDADD = $(libelf)
 elfrdwrnop_LDADD = $(libelf)
+dwelf_elf_e_machine_string_LDADD = $(libelf) $(libdw)
 
 # We want to test the libelf header against the system elf.h header.
 # Don't include any -I CPPFLAGS. Except when we install our own elf.h.
diff --git a/tests/dwelf_elf_e_machine_string.c b/tests/dwelf_elf_e_machine_string.c
new file mode 100644
index 0000000..1df2b23
--- /dev/null
+++ b/tests/dwelf_elf_e_machine_string.c
@@ -0,0 +1,64 @@
+/* Test program for dwelf_elf_e_machine_string
+   Copyright (C) 2019 Red Hat, Inc.
+   This file is part of elfutils.
+
+   This file is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   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 a copy of the GNU 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 <errno.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <string.h>
+#include <unistd.h>
+
+#include ELFUTILS_HEADER(dwelf)
+
+int
+main (int argc, char **argv)
+{
+  int i;
+  for (i = 1; i < argc; i++)
+    {
+      long val;
+      int em;
+      const char *machine;
+
+      if (strncmp ("0x", argv[i], 2) == 0)
+	val = strtol (&argv[i][2], NULL, 16);
+      else
+	val = strtol (argv[i], NULL, 10);
+
+      if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN))
+           || (errno != 0 && val == 0))
+	{
+          perror ("strtol");
+          exit (EXIT_FAILURE);
+	}
+
+      em = val;
+      assert (em == val);
+
+      machine = dwelf_elf_e_machine_string (em);
+      printf ("0x%x %s\n", em, machine);
+      assert (machine != NULL);
+    }
+
+  return 0;
+}
diff --git a/tests/hello_csky.ko.bz2 b/tests/hello_csky.ko.bz2
new file mode 100644
index 0000000..ed98c7f
--- /dev/null
+++ b/tests/hello_csky.ko.bz2
Binary files differ
diff --git a/tests/run-addrcfi.sh b/tests/run-addrcfi.sh
index fd89d02..64fa24d 100755
--- a/tests/run-addrcfi.sh
+++ b/tests/run-addrcfi.sh
@@ -3747,3 +3747,46 @@
 	control reg66 (%fsw): undefined
 handle_cfi no CFI (.debug_frame): no error
 EOF
+
+# EM_CSKY (function bar 0x8440)
+testfiles testfilecsky
+testrun_compare ${abs_builddir}/addrcfi -e testfilecsky 0x8440 <<\EOF
+dwarf_cfi_addrframe (.eh_frame): no matching address range
+.debug_frame has 0x8440 => [0x8440, 0x844a):
+	return address in reg15
+	CFA location expression: bregx(14)
+	integer reg0 (r0): undefined
+	integer reg1 (r1): undefined
+	integer reg2 (r2): undefined
+	integer reg3 (r3): undefined
+	integer reg4 (r4): same_value
+	integer reg5 (r5): same_value
+	integer reg6 (r6): same_value
+	integer reg7 (r7): same_value
+	integer reg8 (r8): same_value
+	integer reg9 (r9): same_value
+	integer reg10 (r10): same_value
+	integer reg11 (r11): same_value
+	integer reg12 (r12): undefined
+	integer reg13 (r13): undefined
+	integer reg14 (sp): location expression: call_frame_cfa stack_value
+	integer reg15 (lr): same_value
+	integer reg16 (r16): same_value
+	integer reg17 (r17): same_value
+	integer reg18 (r18): undefined
+	integer reg19 (r19): undefined
+	integer reg20 (r20): undefined
+	integer reg21 (r21): undefined
+	integer reg22 (r22): undefined
+	integer reg23 (r23): undefined
+	integer reg24 (r24): undefined
+	integer reg25 (r25): undefined
+	integer reg26 (r26): undefined
+	integer reg27 (r27): undefined
+	integer reg28 (r28): undefined
+	integer reg29 (r29): undefined
+	integer reg30 (r30): undefined
+	integer reg31 (tls): undefined
+	integer reg36 (hi): undefined
+	integer reg37 (lo): undefined
+EOF
diff --git a/tests/run-dwelf_elf_e_machine_string.sh b/tests/run-dwelf_elf_e_machine_string.sh
new file mode 100755
index 0000000..ba6d0e6
--- /dev/null
+++ b/tests/run-dwelf_elf_e_machine_string.sh
@@ -0,0 +1,31 @@
+#! /bin/bash
+# Test to make sure all EM values in elf.h are recognized
+# Copyright (C) 2019 Red Hat, Inc.
+# This file is part of elfutils.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# 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 a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. $srcdir/test-subr.sh
+
+# Get all known EM values from elf.h and pass them through the
+# preprocessor to get the numbers. Call dwelf_elf_e_machine_string on
+# all of them.
+EM_VALUES=$(grep ^\#define\ EM_ ${abs_srcdir}/../libelf/elf.h \
+            | cut -f2 -d\  | cut -f1 | grep -v ^EM_NUM$ | xargs echo)
+# echo "EM_VALUES: $EM_VALUES"
+EM_NUMBERS=$((cat ${abs_srcdir}/../libelf/elf.h; echo "$EM_VALUES") \
+             | gcc -E - | tail -1)
+# echo "EM_NUMBERS: $EM_NUMBERS"
+
+testrun ${abs_top_builddir}/tests/dwelf_elf_e_machine_string $EM_NUMBERS
diff --git a/tests/run-strip-reloc.sh b/tests/run-strip-reloc.sh
index 0c6b1c2..b7ec142 100755
--- a/tests/run-strip-reloc.sh
+++ b/tests/run-strip-reloc.sh
@@ -18,7 +18,7 @@
 . $srcdir/test-subr.sh
 
 testfiles hello_i386.ko hello_x86_64.ko hello_ppc64.ko hello_s390.ko \
-	hello_aarch64.ko hello_m68k.ko hello_riscv64.ko
+	hello_aarch64.ko hello_m68k.ko hello_riscv64.ko hello_csky.ko
 
 tempfiles readelf.out readelf.out1 readelf.out2
 tempfiles out.stripped1 out.debug1 out.stripped2 out.debug2
@@ -119,6 +119,7 @@
 runtest hello_aarch64.ko 1
 runtest hello_m68k.ko 1
 runtest hello_riscv64.ko 1
+runtest hello_csky.ko 1
 
 # self test, shouldn't impact non-ET_REL files at all.
 runtest ${abs_top_builddir}/src/strip 0
diff --git a/tests/testfilecsky.bz2 b/tests/testfilecsky.bz2
new file mode 100644
index 0000000..dfee449
--- /dev/null
+++ b/tests/testfilecsky.bz2
Binary files differ