glibc/sysdeps/sh
Alexey Neyman d40dbe722f sh: Fix building with gcc5/6
Build glibc for sh4-unknown-linux-gnu currently fails if one's
using GCC5/6: in dl-conflict.c, the elf_machine_rela() function
is called with NULL as its 3rd argument, sym. The implementation
of that function in sysdeps/sh/dl-machine.h dereferences that pointer:

const Elf32_Sym *const refsym = sym;
...
if (map == &GL(dl_rtld_map))
  value -= map->l_addr + refsym->st_value + reloc->r_addend;

GCC discovers a null pointer dereference, and in accordance with
-fdelete-null-pointer-checks (which is enabled in -O2) replaces this
code with a trap - which, as SH does not implement a trap pattern in
GCC, evaluates to an abort() call. This abort() call pulls many more
objects from libc_nonshared.a, eventually resulting in link failure
due to multiple definitions for a number of symbols.

As far as I see, the conditional before this code is always false in
rtld: _dl_resolve_conflicts() is called with main_map as the first
argument, not GL(_dl_rtld_map), but since that call is in yet another
compilation unit, GCC does not know about it. Patch that wraps this
conditional into !defined RESOLVE_CONFLICT_FIND_MAP attached.

	* sysdeps/sh/dl-machine.h (elf_machine_rela): The condition
	in R_SH_DIR32 case is always false when inlined from
	dl-conflict.c. Ifdef out to prevent GCC from insertin an
	abort() call.
2017-03-12 17:29:32 -03:00
..
bits
nptl
sh3
sh4
soft-fp
____longjmp_chk.S
_mcount.S
abort-instr.h
backtrace.c
bsd-_setjmp.S
bsd-setjmp.S
configure
configure.ac
crti.S
crtn.S
dl-machine.h
dl-tls.h
dl-trampoline.S
fpu_control.h
gccframe.h
gmp-mparam.h
Implies
jmpbuf-offsets.h
jmpbuf-unwind.h
ldsodefs.h
libc-tls.c
libm-test-ulps
libm-test-ulps-name
linkmap.h
machine-gmon.h
Makefile
math_private.h
memcpy.S
memset.S
memusage.h
preconfigure
s_fma.c
s_fmaf.c
sotruss-lib.c
stackguard-macros.h
stackinfo.h
start.S
strlen.S
sysdep.h
tininess.h
tls-macros.h
tst-audit.h