loongson / la-abi-specs

25 stars 6 forks source link

R_LARCH_TLS_{LD,GD,DESC}_PCREL20_S2 #12

Open rui314 opened 1 month ago

rui314 commented 1 month ago

Is it really the case that compiler/assembler emits R_LARCHTLS{LD,GD,DESC}_PCREL20_S2 relocations? It looks like these are GNU ld's internal relocations and never occur in real-world object files. If that's the case, these relocations should be removed from the psABI. We've removed GNU ld's internal relocations from RISC-V's psABI, too.

SixWeining commented 1 month ago

Both gnu-as and llvm-as can emit these relocations:

What do you mean that these are GNU ld's internal relocations?

cc @chenglulu326 @scylaac @wangleiat

rui314 commented 1 month ago

My guessing is that they are implemented to GNU/LLVM assembler just because they are in this psABI spec, but they don't seem to be necessary in the first place (i.e. I suspect this is a spec bug). What are the real use cases of these relocations?

For RISC-V, GNU ld defines bunch of implementation-defined relocations for relaxations, and they were accidentally registered to the psABI spec. We've removed them; see https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/9f1540282aa00dd3ae2c624e45c60f430b939ebd for example.

rui314 commented 1 month ago

I'm also pretty sure that you guys want to remove R_LARCH_GNU_VTINHERIT and R_LARCH_GNU_VTENTRY. See https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/97690f6935ec5ac9e40623227156a2c834898feb.

MQ-mengqing commented 1 month ago

My guessing is that they are implemented to GNU/LLVM assembler just because they are in this psABI spec, but they don't seem to be necessary in the first place (i.e. I suspect this is a spec bug). What are the real use cases of these relocations?

There may be a tiny model on LoongArch, (in the future ?). https://gcc.gnu.org/onlinedocs/gcc/LoongArch-Options.html#index-mcmodel_003d-1

rui314 commented 1 month ago

Since LoongArch defines section-shrinking linker relaxations, there's no use for these _S2 variant of relocations over their corresponding HI/LO pair of relocations, is there? It seems ratifying the _S2 variant only causes issues in the future; you guys don't really want any compiler to use these relocations.

After all, it's your psABI, so that's just my two cents. I just wanted you guys know that we've fixed the same problem for RISC-V.

SixWeining commented 1 month ago

I think bolt needs these relocation types (--emit-relocs).

xen0n commented 1 month ago

I think it's primarily a decision over whether we want to be able to express (1) any possible relocation operation permitted by the ISA capability, or (2) just those relevant to the typical compile-link workflow. In the latter case, all relocations are emitted by the compiler in the longest form possible, to be shrinked by the linker's relaxation pass, later and once. But if we want to still preserve the relocations in the linker output we'd probably still want to have additional reloc types around.

Is my understanding correct?