the linker was wrongly leaving dynamic relocations for GD-model TLS
defined in the main program when linking the main program as PIE. this
was only suboptimal for dynamic pie, but for static pie it resulted in
runtime failure since there is no dynamic linker to resolve the DTPMOD
reference.
this has been reported as binutils bug #22570.
commit 23d6f66966 introduced this
regression as a failure to backport part of the gas testsuite diff
from binutils master to 2.25.1 where the file being patched had a
trivial difference. I'm not sure how this went unnoticed at the time
it was committed.
the new patch is identical to the one committed upstream, except that
the binutils 2.25.1 used info->executable instead of
bfd_link_executable(info), and support for nds32 and score targets is
removed since 2.25.1 did not have the relevant code for them.
the behavior by bfd/ld matched the ABI document but was the opposite
of the kernel's interpretation and opposite of how ld treats the flag
on every other target using fdpic.
see this thread for details:
https://sourceware.org/ml/binutils/2015-09/msg00186.html
binutils-2.25.1/0003-shemuls.diff is needed to include the existing
fdpic support in the build when targeting sh*-linux-* rather than
tucking it away under sh*-uclinux-* only
gcc-5.2.0/0007-fdpic.diff is based on the original abandoned fdpic
patch 3/3 sent to the gcc list in 2010, updated for modern gcc and
with the uclinux dependencies removed. the original is here:
https://gcc.gnu.org/ml/gcc-patches/2010-08/msg01464.html
gcc-5.2.0/0001-musl.diff has been updated to use the right musl
dynamic linker pathname for fdpic so that musl-specific changes can be
avoided in the main fdpic patch.
at present, additional patches to musl are needed to produce working
binaries for the target.