-
Committer:
Ben Hutchings
-
Date:
2023-07-15 23:02:10 UTC
-
Revision ID:
git-v1:e25809bbea2ed2825c543cb153d9f282eac26fc5
[klibc] mips64: Compatibility with R6 compact branches
MIPS R6 introduced compact branch instructions, including BALC as a
replacement for JAL. Both BALC and JAL have a 26-bit offset field
that's shifted 2 bits left. However, in BALC this is treated as a
PC-relative signed offset (±128 MiB) rather than a segment-relative
unsigned offset (0-256 MiB).
The base address of the klibc shared library therefore needs to change
depending on whether the executable calls it with JAL or BALC.
gcc (but not Clang, currently) generates BALC instructions for
external function calls on R6 targets, which breaks shared library
builds of klibc for these targets. Add a config symbol to control
whether compact branches are used and to change the shared library
base address accordingly.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>