Closed rui314 closed 1 year ago
I guess that's more like an intermediate relocation used for the linker relaxation process, like R_RISCV_GPREL_[IS]
relative relocation ( https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/205), because I also don't believe that's can be useful to let user use c.lui
with this relocation directly, so we should consider deprecate and use this relocation as internal intermediate relocation only.
@Nelson1225 @MaskRay @jrtc27 any thought for this?
If there's no assembly syntax to emit that relocation and the relocation is just a binutils internal relocation, we probably should remove it altogether from the psABI. It should be safe to do so.
I guess that's more like an intermediate relocation used for the linker relaxation process, like R_RISCVGPREL[IS] relative relocation ( https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/205), because I also don't believe that's can be useful to let user use c.lui with this relocation directly, so we should consider deprecate and use this relocation as internal intermediate relocation only.
Yap, user cannot use this relocation directly in GNU assembler. We only accept immediate value in c.lui in gas, without any modifiers. However, it's also really rare to see this relaxation in ld, since we should reserve the maxpagesize and commongaesize for data segment alignment (pr27566, from Jim's comment). The pagesize usually occupied most of the rvc_lui space...
If there's no assembly syntax to emit that relocation and the relocation is just a binutils internal relocation, we probably should remove it altogether from the psABI. It should be safe to do so.
Looks good to me :-)
Removing R_RISCV_RVC_LUI
looks good, like we removed R_RISCV_GNU_VTINHERIT
, R_RISCV_GNU_VTENTRY
, R_RISCV_GPREL_I
, R_RISCV_GPREL_S
that were not produced by assemblers.
I was looking for a way to test the
R_RISCV_RVC_LUI
relocation for the mold linker, but it looks like there's no way to make the assembler to emit that relocation type.lui a0, %hi20(foo)
produces aR_RISCV_HI20
relocation, butc.lui a0, %hi20(foo)
is rejected as an illegal combination of the instruction and the operand.R_RISCV_RVC_LUI
also seems to be an odd relocation, and I can't think of a valid use case for it. In order to usec.lui
, you need to make sure that the operand address is representable as a signed 17 bit value. But if you know what the value is, you don't need to emit a relocation -- you can just emit that value directly. If you don't know what the value is, you can't safely emit that relocation because you don't know whether the value will fit in 17 bits or not.The only valid use case would be a code model which limits the program size to 2^16. However, even for that code model, we don't need
R_RISCV_RVC_LUI
because the linker can already relaxlui
toc.lui
if the operand is small enough.lld supports that relocation, but it looks like there's no test for that relocation. mold does not support it at all, and we haven't received any user reports about it.
Does anyone know what this relocation was for? Is there any way to make the assembler/compiler to emit that relocation?