[PATCH] Handle ADD/SUB relocations

2018-10-02 Thread Andreas Schwab
This adds support for ADD and SUB relocations as seen on RISC-V.

Signed-off-by: Andreas Schwab 
---
 backends/ChangeLog  | 20 
 backends/aarch64_symbol.c   |  3 ++-
 backends/alpha_symbol.c |  3 ++-
 backends/arm_symbol.c   |  3 ++-
 backends/bpf_symbol.c   |  3 ++-
 backends/i386_symbol.c  |  3 ++-
 backends/ia64_symbol.c  |  3 ++-
 backends/m68k_symbol.c  |  3 ++-
 backends/ppc64_symbol.c |  3 ++-
 backends/ppc_symbol.c   |  3 ++-
 backends/riscv_symbol.c | 26 +-
 backends/s390_symbol.c  |  3 ++-
 backends/sh_symbol.c|  3 ++-
 backends/sparc_symbol.c |  3 ++-
 backends/tilegx_symbol.c|  3 ++-
 backends/x86_64_symbol.c|  3 ++-
 libdwfl/ChangeLog   |  4 
 libdwfl/relocate.c  | 21 +++--
 libebl/ChangeLog|  7 +++
 libebl/ebl-hooks.h  |  2 +-
 libebl/eblopenbackend.c |  5 +++--
 libebl/eblrelocsimpletype.c |  4 ++--
 libebl/libebl.h |  6 --
 src/ChangeLog   |  4 
 src/strip.c | 23 +++
 25 files changed, 136 insertions(+), 28 deletions(-)

diff --git a/backends/ChangeLog b/backends/ChangeLog
index fdff302194..a7434dd2d3 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,23 @@
+2018-10-02  Andreas Schwab  
+
+   * riscv_symbol.c (riscv_reloc_simple_type): Add parameter addsub.
+   Set it for ADD and SUB relocations.
+   * aarch64_symbol.c (aarch64_reloc_simple_type): Add and ignore
+   third parameter.
+   * alpha_symbol.c (alpha_reloc_simple_type): Likewise.
+   * arm_symbol.c (arm_reloc_simple_type): Likewise.
+   * bpf_symbol.c (bpf_reloc_simple_type): Likewise.
+   * i386_symbol.c (i386_reloc_simple_type): Likewise.
+   * ia64_symbol.c (ia64_reloc_simple_type): Likewise.
+   * m68k_symbol.c (m68k_reloc_simple_type): Likewise.
+   * ppc64_symbol.c (ppc64_reloc_simple_type): Likewise.
+   * ppc_symbol.c (ppc_reloc_simple_type): Likewise.
+   * s390_symbol.c (s390_reloc_simple_type): Likewise.
+   * sh_symbol.c (sh_reloc_simple_type): Likewise.
+   * sparc_symbol.c (sparc_reloc_simple_type): Likewise.
+   * tilegx_symbol.c (tilegx_reloc_simple_type): Likewise.
+   * x86_64_symbol.c (x86_64_reloc_simple_type): Likewise.
+
 2018-09-12  Mark Wielaard  
 
* ppc64_init.c (ppc64_init): Use elf_getshdrstrndx.
diff --git a/backends/aarch64_symbol.c b/backends/aarch64_symbol.c
index dfd755a54b..e30c409d74 100644
--- a/backends/aarch64_symbol.c
+++ b/backends/aarch64_symbol.c
@@ -40,7 +40,8 @@
 
 /* Check for the simple reloc types.  */
 Elf_Type
-aarch64_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
+aarch64_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type,
+  int *addsub __attribute__ ((unused)))
 {
   switch (type)
 {
diff --git a/backends/alpha_symbol.c b/backends/alpha_symbol.c
index b7f7c17a00..53a9e7b7b4 100644
--- a/backends/alpha_symbol.c
+++ b/backends/alpha_symbol.c
@@ -61,7 +61,8 @@ alpha_dynamic_tag_check (int64_t tag)
 
 /* Check for the simple reloc types.  */
 Elf_Type
-alpha_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
+alpha_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type,
+int *addsub __attribute__ ((unused)))
 {
   switch (type)
 {
diff --git a/backends/arm_symbol.c b/backends/arm_symbol.c
index 3edda7247e..c8e1d7f914 100644
--- a/backends/arm_symbol.c
+++ b/backends/arm_symbol.c
@@ -109,7 +109,8 @@ arm_machine_flag_check (GElf_Word flags)
 
 /* Check for the simple reloc types.  */
 Elf_Type
-arm_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
+arm_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type,
+  int *addsub __attribute__ ((unused)))
 {
   switch (type)
 {
diff --git a/backends/bpf_symbol.c b/backends/bpf_symbol.c
index c9856f2638..85c948ab81 100644
--- a/backends/bpf_symbol.c
+++ b/backends/bpf_symbol.c
@@ -40,7 +40,8 @@
 
 /* Check for the simple reloc types.  */
 Elf_Type
-bpf_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
+bpf_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type,
+  int *addsub __attribute__ ((unused)))
 {
   switch (type)
 {
diff --git a/backends/i386_symbol.c b/backends/i386_symbol.c
index 7dbf899fd2..a4b6ec08b6 100644
--- a/backends/i386_symbol.c
+++ b/backends/i386_symbol.c
@@ -49,7 +49,8 @@ i386_gotpc_reloc_check (Elf *elf __attribute__ ((unused)), 
int type)
 
 /* Check for the simple reloc types.  */
 Elf_Type
-i386_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
+i386_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type,
+   int *addsub __attribute__ ((unused)))
 {
   switch (type)
 {
diff --git a/backends/ia64_symbol.c b/backends/ia64_symbol.c
index f928b0b7f7..0

[Bug general/23732] New: Test failures on sparc64-linux-gnu

2018-10-02 Thread kelledin at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23732

Bug ID: 23732
   Summary: Test failures on sparc64-linux-gnu
   Product: elfutils
   Version: unspecified
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: general
  Assignee: unassigned at sourceware dot org
  Reporter: kelledin at gmail dot com
CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

elfutils-0.174 (and at least as far back as 0.170) is failing three tests for
me:

==
   elfutils 0.174: tests/test-suite.log
==

# TOTAL: 202
# PASS:  194
# SKIP:  5
# XFAIL: 0
# FAIL:  3
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: run-strip-nothing.sh
==

/usr/src/elfutils-0.174/src/elfcmp: a.out strip.out differ: section [5]
'.dynsym' header
*** failed strip.out different from a.out
FAIL run-strip-nothing.sh (exit status: 255)

FAIL: run-backtrace-native.sh
=

0x100   0x1104000   /usr/src/elfutils-0.174/tests/backtrace-child
0x8001  0x800100126000 
/lib/sparc64-linux-gnu/ld-2.27.so
0x800100128000  0x800100244000 
/lib/sparc64-linux-gnu/libpthread-2.27.so
0x80010047a000  0x80010047c000  [vdso: 91062]
0x80010047c000  0x8001006e8000 
/lib/sparc64-linux-gnu/libc-2.27.so
TID 91062:
# 0 0x80010013beb0  raise
TID 91067:
# 0 0x80010013beb0  raise
/usr/src/elfutils-0.174/tests/backtrace: dwfl_thread_getframes: No DWARF
information found
/usr/src/elfutils-0.174/tests/backtrace: dwfl_thread_getframes: No DWARF
information found
backtrace: backtrace.c:81: callback_verify: Assertion `seen_main' failed.
./test-subr.sh: line 84: 91057 Aborted (core dumped)
LD_LIBRARY_PATH="${built_library_path}${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
$VALGRIND_CMD "$@"
backtrace-child: no main
FAIL run-backtrace-native.sh (exit status: 1)

SKIP: run-backtrace-data.sh
===

/usr/src/elfutils-0.174/tests/backtrace-data: Unwinding not supported for this
architecture
data: arch not supported
SKIP run-backtrace-data.sh (exit status: 77)
FAIL: run-backtrace-dwarf.sh


0x8001004d88d4  raise
/usr/src/elfutils-0.174/tests/backtrace-dwarf: dwfl_thread_getframes: No DWARF
information found
dwarf: no main
FAIL run-backtrace-dwarf.sh (exit status: 1)

SKIP: run-backtrace-native-biarch.sh


biarch testing disabled
SKIP run-backtrace-native-biarch.sh (exit status: 77)

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

/usr/bin/coredumpctl
No match found.
-- Notice: 2 systemd-coredump@.service units are running, output may be
incomplete.
No match found.
-- Notice: 1 systemd-coredump@.service unit is running, output may be
incomplete.
No match found.
-- Notice: 1 systemd-coredump@.service unit is running, output may be
incomplete.
No core.91173 file generated
SKIP run-backtrace-native-core.sh (exit status: 77)

SKIP: run-backtrace-native-core-biarch.sh
=

biarch testing disabled
SKIP run-backtrace-native-core-biarch.sh (exit status: 77)

SKIP: run-lfs-symbols.sh


LFS testing is irrelevent on this system
SKIP run-lfs-symbols.sh (exit status: 77)


Testsuite summary for elfutils 0.174

# TOTAL: 202
# PASS:  194
# SKIP:  5
# XFAIL: 0
# FAIL:  3
# XPASS: 0
# ERROR: 0


(run-backtrace-native-core-biarch.sh was also failing, but I've put that on a
back burner for now while I dig into the other failures.  I can turn it back on
if someone wants the failure output).

run-strip-nothing.sh appears to rearrange the ELF section contents without
actually deleting anything obvious, but whatever it changes is enough to upset
elfcmp.  I actually examined the .dynsym section as best I knew how (with
binutils "readelf --dyn-syms"), and the resulting dump looked identical for
both a.out and strip.out.

run-backtrace-native.sh is pretty obvious: it doesn't see main() in the
backtrace, probably because it can't actually *get* the full backtrace without
DWARF info.  run-backtrace-dwarf.sh failure can probably be traced back to the
same root cause, and I would assume the related biarch test as well was failing
for the same reason.

For background, this is on a mostly-vanilla 4.16.18 kernel, gcc-8.2.0,
binutils-2.31.1, glibc-2.27, with SPARC T2000 CPUs.  Typical build flags are
"-O2 -m64 -mcpu=v9 -mtune=v9", although I've tried different optimization
levels and different (or absent) -mcpu/-mtune flags, with no apparent
difference.  gdb i