Skip to content

Commit c96a69e

Browse files
committed
Relaxable TLSDESC only requires that R_RISCV_TLSDESC_HI20 to be paired with R_RISCV_RELAX
Requiring 4 R_RISCV_RELAX relocations impose a large size increase to the relocatable file. To mitigate this size increase, we can say that the whole TLSDESC code sequence is relaxable if the first instruction (R_RISCV_TLSDESC_HI20) is paired with R_RISCV_RELAX. A statically linked executable typically has a simple relocation resolver that handles just RELATIVE/IFUNC. For a `-fpic -mtls-dialect=desc` relocatable file, the linker is required to perform TLS optimization to local-exec for a statically linked executable. Therefore, instruction rewriting is essentially inevitable if the relocation resolver is kept simple. Ths general-dynamic TLS model, without a defined optimization scheme, actually has the same issue.
1 parent 0396206 commit c96a69e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

riscv-elf.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,9 +1848,9 @@ Relaxation candidate (`tX` and `tY` can be any combination of two general purpos
18481848
----
18491849
label:
18501850
auipc tX, <hi> // R_RISCV_TLSDESC_HI20 (symbol), R_RISCV_RELAX
1851-
lw tY, tX, <lo> // R_RISCV_TLSDESC_LOAD_LO12 (label), R_RISCV_RELAX
1852-
addi a0, tX, <lo> // R_RISCV_TLSDESC_ADD_LO12 (label), R_RISCV_RELAX
1853-
jalr t0, tY // R_RISCV_TLSDESC_CALL (label), R_RISCV_RELAX
1851+
lw tY, tX, <lo> // R_RISCV_TLSDESC_LOAD_LO12 (label)
1852+
addi a0, tX, <lo> // R_RISCV_TLSDESC_ADD_LO12 (label)
1853+
jalr t0, tY // R_RISCV_TLSDESC_CALL (label)
18541854
----
18551855

18561856
Relaxation result:
@@ -1889,9 +1889,9 @@ Relaxation candidate (`tX` and `tY` can be any combination of two general purpos
18891889
----
18901890
label:
18911891
auipc tX, <hi> // R_RISCV_TLSDESC_HI20 (symbol), R_RISCV_RELAX
1892-
lw tY, tX, <lo> // R_RISCV_TLSDESC_LOAD_LO12 (label), R_RISCV_RELAX
1893-
addi a0, tX, <lo> // R_RISCV_TLSDESC_ADD_LO12 (label), R_RISCV_RELAX
1894-
jalr t0, tY // R_RISCV_TLSDESC_CALL (label), R_RISCV_RELAX
1892+
lw tY, tX, <lo> // R_RISCV_TLSDESC_LOAD_LO12 (label)
1893+
addi a0, tX, <lo> // R_RISCV_TLSDESC_ADD_LO12 (label)
1894+
jalr t0, tY // R_RISCV_TLSDESC_CALL (label)
18951895
----
18961896

18971897
Relaxation result (long form):

0 commit comments

Comments
 (0)