https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108339
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-10 branch has been updated by Kito Cheng <k...@gcc.gnu.org>: https://gcc.gnu.org/g:951ca35bdbbde7bb348337d7db3919c4a0628e25 commit r10-11221-g951ca35bdbbde7bb348337d7db3919c4a0628e25 Author: Nelson Chu <nelson....@sifive.com> Date: Mon Nov 29 04:48:20 2021 -0800 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)