GAS treats the R5900 as MIPS III, with some modifications. The MIPS III
designation means that the GNU C Library will try to assemble the LL and
SC instructions, even though they are not implemented in the R5900. GAS
will therefore produce the following errors:
Error: opcode not supported on this processor: r5900 (mips3) `ll $2,0($4)'
Error: opcode not supported on this processor: r5900 (mips3) `sc $6,0($4)'
The MIPS II ISA override as used here enables the kernel to trap and
emulate the LL and SC instructions, as required.
This change has been tested by compiling the GNU C Library 2.27 with a
GCC 8.2.0 cross-compiler for mipsr5900el-unknown-linux-gnu under Gentoo.
* sysdeps/mips/sys/tas.h (_test_and_set): Handle the R5900 CPU
with the ISA override.
There are a few .set mips* assembler directives used in the MIPS specific
sysdep code that force an instruction to be assembled for a specific ISA.
The reason for these is to allow an instruction to be encoded when it might
not be supported in the current ISA (when the code is run the Linux kernel
will trap and emulate any unsupported instructions). Unfortunately forcing
a specific ISA means that when assembling for a newer ISA, where the
instruction has a different encoding, the wrong encoding will be used.
* sysdeps/mips/bits/atomic.h [_MIPS_SIM == _ABIO32] (MIPS_PUSH_MIPS2):
Only use .set mips2 if the current ISA is below mips2.
* sysdeps/mips/sys/tas.h [_MIPS_SIM == _ABIO32] (_test_and_set):
Likewise.
* sysdeps/mips/nptl/tls.h (READ_THREAD_POINTER): Only use .set
mips32r2 if the current ISA is below mips32r2.
* sysdeps/mips/tls-macros.h (TLS_RDHWR): New define.
(TLS_IE): Updated to use the TLD_RDHWR macro.
(TLS_LE): Likewise.
* sysdeps/unix/mips/sysdep.h (__mips_isa_rev): Moved out of #ifdef
__ASSEMBLER__ condition.
I've moved the MIPS port from ports to the main sysdeps hierarchy.
Beyond the README update, the move of the files was simply
git mv ports/sysdeps/mips sysdeps/mips
git mv ports/sysdeps/unix/mips sysdeps/unix/mips
git mv ports/sysdeps/unix/sysv/linux/mips sysdeps/unix/sysv/linux/mips
and in addition to the ChangeLog entries here, I put a note at the top
of ports/ChangeLog.mips similar to those in other files.
Tested that disassembly of installed shared libraries for mips is the
same before and after this patch (except for ld.so where paths in
assertions are involved, as for arm).
* sysdeps/mips: Move directory from ports/sysdeps/mips.
* sysdeps/unix/mips: Move directory from ports/sysdeps/unix/mips.
* sysdeps/unix/sysv/linux/mips: Move directory from
ports/sysdeps/unix/sysv/linux/mips.
* README: Update listing for mips-*-linux-gnu and
mips64-*-linux-gnu.
* sysdeps/mips: Move directory to ../sysdeps/mips.
* sysdeps/unix/mips: Move directory to ../sysdeps/unix/mips.
* sysdeps/unix/sysv/linux/mips: Move directory to
../sysdeps/unix/sysv/linux/mips.