We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
While building musl for riscv64 with mold as linker, mold refused to link the GP-setup code.
This assembly snippet is created from arch/riscv64/crt_arch.h, which is included by ldso/dlstart.c. Save this snippet as dlstart.s.
arch/riscv64/crt_arch.h
ldso/dlstart.c
dlstart.s
.section .sdata,"aw" .text .global _dlstart .type _dlstart,%function _dlstart: .weak __global_pointer$ .hidden __global_pointer$ .option push .option norelax lla gp, __global_pointer$ .option pop mv a0, sp .weak _DYNAMIC .hidden _DYNAMIC lla a1, _DYNAMIC andi sp, sp, -16 tail _dlstart_c .type _dlstart_c,%function _dlstart_c: # The actual code here does not matter. ret
Then compile and link.
$ clang --target=riscv64 -march=rv64g dlstart.s -c -o dlstart.o $ ld.lld -e _dlstart -shared dlstart.o -o fake_libc.so # no error $ mold -shared -e _dlstart dlstart.o -o fake_libc.so mold: error: dlstart.o:(.text): R_RISCV_PCREL_HI20 relocation at offset 0x0 against symbol `__global_pointer$' can not be used; recompile with -fno-PIC
Note that the GP-setup code in _dlstart do follows the recommended way to initialize the gp register in RISC-V ELF specification, and the PIC option for compiler doesn't affect the content of dlstart.o.
_dlstart
dlstart.o
With git bisect I found mold refuses to link such input after 5fb6091.
git bisect
The text was updated successfully, but these errors were encountered:
Thank you for your report. Maybe we should just revert the commit that broke your test case.
Sorry, something went wrong.
58558e3
Successfully merging a pull request may close this issue.
Description
While building musl for riscv64 with mold as linker, mold refused to link the GP-setup code.
A minimal reproduce
This assembly snippet is created from
arch/riscv64/crt_arch.h
, which is included byldso/dlstart.c
. Save this snippet asdlstart.s
.Then compile and link.
Note that the GP-setup code in
_dlstart
do follows the recommended way to initialize the gp register in RISC-V ELF specification, and the PIC option for compiler doesn't affect the content ofdlstart.o
.More information
With
git bisect
I found mold refuses to link such input after 5fb6091.The text was updated successfully, but these errors were encountered: