[PATCH] libelf: Sync elf.h from glibc

2018-04-19 Thread Andreas Schwab
Signed-off-by: Andreas Schwab 
---
 libelf/ChangeLog |  4 +++
 libelf/elf.h | 71 
 2 files changed, 63 insertions(+), 12 deletions(-)

diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 62e8911654..ea2b9df884 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2018-04-19  Andreas Schwab  
+
+   * elf.h: Update from glibc.
+
 2018-02-16  Mark Wielaard  
 
* elf.h: Update from glibc.
diff --git a/libelf/elf.h b/libelf/elf.h
index 4f4357705b..f7748983c8 100644
--- a/libelf/elf.h
+++ b/libelf/elf.h
@@ -3367,6 +3367,9 @@ enum
   relaxable.  */
 #define R_X86_64_NUM   43
 
+/* x86-64 sh_type values.  */
+#define SHT_X86_64_UNWIND  0x7001 /* Unwind information.  */
+
 
 /* AM33 relocations.  */
 #define R_MN10300_NONE 0   /* No reloc.  */
@@ -3785,18 +3788,62 @@ enum
 #define EF_RISCV_FLOAT_ABI_QUAD0x0006
 
 /* RISC-V relocations.  */
-#define R_RISCV_NONE  0
-#define R_RISCV_321
-#define R_RISCV_642
-#define R_RISCV_RELATIVE  3
-#define R_RISCV_COPY  4
-#define R_RISCV_JUMP_SLOT 5
-#define R_RISCV_TLS_DTPMOD32  6
-#define R_RISCV_TLS_DTPMOD64  7
-#define R_RISCV_TLS_DTPREL32  8
-#define R_RISCV_TLS_DTPREL64  9
-#define R_RISCV_TLS_TPREL32  10
-#define R_RISCV_TLS_TPREL64  11
+#define R_RISCV_NONE0
+#define R_RISCV_32  1
+#define R_RISCV_64  2
+#define R_RISCV_RELATIVE3
+#define R_RISCV_COPY4
+#define R_RISCV_JUMP_SLOT   5
+#define R_RISCV_TLS_DTPMOD326
+#define R_RISCV_TLS_DTPMOD647
+#define R_RISCV_TLS_DTPREL328
+#define R_RISCV_TLS_DTPREL649
+#define R_RISCV_TLS_TPREL3210
+#define R_RISCV_TLS_TPREL6411
+#define R_RISCV_BRANCH 16
+#define R_RISCV_JAL17
+#define R_RISCV_CALL   18
+#define R_RISCV_CALL_PLT   19
+#define R_RISCV_GOT_HI20   20
+#define R_RISCV_TLS_GOT_HI20   21
+#define R_RISCV_TLS_GD_HI2022
+#define R_RISCV_PCREL_HI20 23
+#define R_RISCV_PCREL_LO12_I   24
+#define R_RISCV_PCREL_LO12_S   25
+#define R_RISCV_HI20   26
+#define R_RISCV_LO12_I 27
+#define R_RISCV_LO12_S 28
+#define R_RISCV_TPREL_HI20 29
+#define R_RISCV_TPREL_LO12_I   30
+#define R_RISCV_TPREL_LO12_S   31
+#define R_RISCV_TPREL_ADD  32
+#define R_RISCV_ADD8   33
+#define R_RISCV_ADD16  34
+#define R_RISCV_ADD32  35
+#define R_RISCV_ADD64  36
+#define R_RISCV_SUB8   37
+#define R_RISCV_SUB16  38
+#define R_RISCV_SUB32  39
+#define R_RISCV_SUB64  40
+#define R_RISCV_GNU_VTINHERIT  41
+#define R_RISCV_GNU_VTENTRY42
+#define R_RISCV_ALIGN  43
+#define R_RISCV_RVC_BRANCH 44
+#define R_RISCV_RVC_JUMP   45
+#define R_RISCV_RVC_LUI46
+#define R_RISCV_GPREL_I47
+#define R_RISCV_GPREL_S48
+#define R_RISCV_TPREL_I49
+#define R_RISCV_TPREL_S50
+#define R_RISCV_RELAX  51
+#define R_RISCV_SUB6   52
+#define R_RISCV_SET6   53
+#define R_RISCV_SET8   54
+#define R_RISCV_SET16  55
+#define R_RISCV_SET32  56
+#define R_RISCV_32_PCREL   57
+
+#define R_RISCV_NUM58
 
 /* BPF specific declarations.  */
 
-- 
2.17.0


-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


[PATCH] Add support for RISC-V

2018-04-19 Thread Andreas Schwab
This implements initial support for the RISC-V architecture.  It has
been tested with qemu linux-user emulation
,
with the following unresolved issues

FAIL: run-strip-strmerge.sh
===

elflint /home/abuild/rpmbuild/BUILD/elfutils-0.170/tests/elfstrmerge
section [32] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0x51c0 does not 
match .got section address 0x5010
section [32] '.symtab': symbol 119: st_value out of bounds
FAIL run-strip-strmerge.sh (exit status: 1)

FAIL: run-elflint-self.sh
=

section [33] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0x6220 does not 
match .got section address 0x6008
section [33] '.symtab': symbol 135: st_value out of bounds
*** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet 
--gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/addr2line
section [33] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0x91d8 does not 
match .got section address 0x9040
section [33] '.symtab': symbol 163: st_value out of bounds
*** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet 
--gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elfcmp
section [33] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0x1a2a0 does not 
match .got section address 0x1a040
section [33] '.symtab': symbol 267: st_value out of bounds
*** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet 
--gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint
section [33] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0xd418 does not 
match .got section address 0xd0f0
section [33] '.symtab': symbol 238: st_value out of bounds
*** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet 
--gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/nm
section [33] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0xa2d0 does not 
match .got section address 0xa0b0
section [33] '.symtab': symbol 193: st_value out of bounds
*** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet 
--gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/objdump
section [33] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0x2e5b8 does not 
match .got section address 0x2e058
section [33] '.symtab': symbol 410: st_value out of bounds
*** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet 
--gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/readelf
section [32] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0x171b8 does not 
match .got section address 0x17010
*** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet 
--gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/libelf/libelf.so
section [32] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0x3a5b0 does not 
match .got section address 0x3a0d8
*** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet 
--gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/libdw/libdw.so
section [31] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0xd0c8 does not 
match .got section address 0xd008
*** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet 
--gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/backends/libebl_i386.so
section [31] '.symtab': _GLOBAL_OFFSET_TABLE_ symbol value 0xf0c8 does not 
match .got section address 0xf008
*** failure in /home/abuild/rpmbuild/BUILD/elfutils-0.170/src/elflint --quiet 
--gnu-ld /home/abuild/rpmbuild/BUILD/elfutils-0.170/backends/libebl_x86_64.so
FAIL run-elflint-self.sh (exit status: 1)

FAIL: run-native-test.sh


/home/abuild/rpmbuild/BUILD/elfutils-0.170/tests/allregs: 
dwfl_module_register_names: no backend registers known
FAIL run-native-test.sh (exit status: 1)

FAIL: run-backtrace-native-core.sh
==

backtrace: backtrace.c:111: callback_verify: Assertion `symname && strcmp 
(symname, "raise") == 0' failed.
./test-subr.sh: line 84: 26040 Aborted (core dumped) 
LD_LIBRARY_PATH="${built_library_path}${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" 
$VALGRIND_CMD "$@"
backtrace-child-core.26027: no main
rmdir: failed to remove 'test-26016': Directory not empty
FAIL run-backtrace-native-core.sh (exit status: 1)

In addition, all tests that use ptrace are failing as linux-user
emulation does not implement it.

There are no regressions for a x86_64 build.

Signed-off-by: Andreas Schwab 
---
 backends/ChangeLog |   7 
 backends/Makefile.am   |   8 +++-
 backends/riscv_init.c  |  57 +
 backends/riscv_reloc.def   |  83 +
 backends/riscv_symbol.c|  62 +++
 libebl/ChangeLog   |   4 ++
 libebl/eblopenbackend.c|   2 +
 src/ChangeLog  |   4 ++
 src/elflint.c  |   2 +-
 tests/ChangeLog|   5 +++
 tests/hello_riscv64.ko.bz2 | Bin 0 -> 1166 bytes
 te