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 following issues are fixed:
- ICE generating the new libgcc __ashlsi3_r0 and __lshrsi3_r0 shift
operations for non-J2 SH2.
- new sh_legitimate_constant_p function was unused because there was
an existing version with different signature which C++ allowed to be
overloaded rather than reporting the error.
- reversed asm spec conditional for fdpic broke non-fdpic builds.
this commit rebases the patch against gcc trunk and backports the
result. file order has been tweaked by hand so that the diff is
friendly to manual inspection.
since -E is no longer passed to the linker, musl commit
6fc30c2493fcfedec89e45088bea87766a1e3286 is now necessary to get a
version of rcrt1.o that works with the new static PIE support, or
-Wl,-E can be passed manually to work with old rcrt1.o.
I originally missed the udiv_qrnnd part of the fdpic patch when
forward-porting it because longlong.h moved to a non-obvious location.
however, the original patch was broken anyway; it misordered
instructions at branch delay slots and clobbered in-use registers.
my version of the code is more efficient because it uses knowledge
that __udiv_qrnnd_16 is a pure-PIC function that makes no calls, uses
no static data, and does not clobber r12. this means we only need to
load the instruction address, not the got address, from the function
descriptor to make the call.
the same can be achieved even more efficiently by declaring
__udiv_qrnnd_16 with object type instead of function type and using
the existing non-fdpic asm unmodified. I did not do this because I was
afraid it would be considered a hack unacceptable for upstream.
some of the forward-ported fdpic patch code contained duplicates of
code that was changed in the fix for pr66609. failure to notice this
before allowed the bug to re-emerge and broke musl's use of
overridable weak aliases.
two changes are made:
1. always enable flag_pic for fdpic. without this, various ICE and bad
codegen was observed.
2. allow sibcall for fdpic; it's valid since r12 is call-clobbered.
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.