]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: jal cannot refer to a default visibility symbol for shared object. [PR 108339]
authorNelson Chu <nelson.chu@sifive.com>
Mon, 29 Nov 2021 12:48:20 +0000 (04:48 -0800)
committerKito Cheng <kito.cheng@sifive.com>
Mon, 20 Feb 2023 11:03:43 +0000 (19:03 +0800)
commit951ca35bdbbde7bb348337d7db3919c4a0628e25
treee44ff3104d1aa42d09e72c5fa70247421984ff80
parentd465a40200324d56c51f02f2c5807e716f9c8775
RISC-V: jal cannot refer to a default visibility symbol for shared object. [PR 108339]

This is the original binutils bugzilla report,
https://sourceware.org/bugzilla/show_bug.cgi?id=28509

And this is the first version of the proposed binutils patch,
https://sourceware.org/pipermail/binutils/2021-November/118398.html

After applying the binutils patch, I get the the unexpected error when
building libgcc,

/scratch/nelsonc/riscv-gnu-toolchain/riscv-gcc/libgcc/config/riscv/div.S:42:
/scratch/nelsonc/build-upstream/rv64gc-linux/build-install/riscv64-unknown-linux-gnu/bin/ld: relocation R_RISCV_JAL against `__udivdi3' which may bind externally can not be used when making a shared object; recompile with -fPIC

Therefore, this patch add an extra hidden alias symbol for __udivdi3, and
then use HIDDEN_JUMPTARGET to target a non-preemptible symbol instead.
The solution is similar to glibc as follows,
https://sourceware.org/git/?p=glibc.git;a=commit;h=68389203832ab39dd0dbaabbc4059e7fff51c29b

libgcc/ChangeLog:

PR target/108339
* config/riscv/div.S: Add the hidden alias symbol for __udivdi3, and
then use HIDDEN_JUMPTARGET to target it since it is non-preemptible.
* config/riscv/riscv-asm.h: Added new macros HIDDEN_JUMPTARGET and
HIDDEN_DEF.

(cherry picked from commit 45116f342057b7facecd3d05c2091ce3a77eda59)
libgcc/config/riscv/div.S
libgcc/config/riscv/riscv-asm.h