Skip to content

Commit 87e1c26

Browse files
Nelson Chukito-cheng
authored andcommitted
Refer mapping symbol into R_RISCV_RELAX for rvc/norvc relaxations.
1 parent 01017c3 commit 87e1c26

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

riscv-elf.adoc

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,7 @@ below.
929929

930930
+
931931
--
932+
[[EF_RISCV_RVC]]
932933
EF_RISCV_RVC (0x0001)::: This bit is set when the binary targets the C ABI,
933934
which allows instructions to be aligned to 16-bit boundaries (the base RV32
934935
and RV64 ISAs only allow 32-bit instruction alignment). When linking
@@ -1174,7 +1175,7 @@ Description:: Additional information about the relocation
11741175
<| S + A - P
11751176
.2+| 46-50 .2+| *Reserved* .2+| - | .2+| Reserved for future standard use
11761177
<|
1177-
.2+| 51 .2+| RELAX .2+| Static | .2+| Instruction can be relaxed, paired with a normal relocation at the same address
1178+
.2+| 51 .2+| RELAX .2+| Static | .2+| Instruction can be relaxed, paired with a normal relocation at the same address. This relocation might point to an optional dummy mapping symbol, indicating which extension is permitted for use during the linker relaxation process.
11781179
<|
11791180
.2+| 52 .2+| SUB6 .2+| Static | _word6_ .2+| Local label subtraction
11801181
<| V - S - A
@@ -2734,6 +2735,38 @@ instructions. It is recommended to initialize `jvt` CSR immediately after
27342735
csrw jvt, a0
27352736
----
27362737

2738+
=== Compressed and Non-compressed Relaxations in the Same Object
2739+
2740+
The linker used to enable and disable the compressed relaxations by checking
2741+
the <<EF_RISCV_RVC,EF_RISCV_RVC>> of each input object. Since
2742+
<<EF_RISCV_RVC,EF_RISCV_RVC>> is an object-level tag, it cannot handle the case
2743+
where `.option arch, +c` and `.option arch, -c` are in the same object.
2744+
Therefore, encoding the mapping symbols into each `R_RISCV_RELAX` can resolve
2745+
the problem.
2746+
2747+
Example::
2748+
+
2749+
--
2750+
Relaxation candidate:
2751+
[,asm]
2752+
----
2753+
.option arch, rv32i
2754+
auipc ra, 0 # R_RISCV_CALL_PLT (symbol), R_RISCV_RELAX ($xrv32i)
2755+
jalr ra, ra, 0
2756+
2757+
.option arch, +c
2758+
auipc ra, 0 # R_RISCV_CALL_PLT (symbol), R_RISCV_RELAX ($xrv32ic)
2759+
jalr ra, ra, 0
2760+
----
2761+
Relaxation result:
2762+
[,asm]
2763+
----
2764+
jal ra, 0 # R_RISCV_JAL (symbol)
2765+
2766+
c.jal ra, <offset-between-pc-and-symbol>
2767+
----
2768+
--
2769+
27372770
[bibliography]
27382771
== References
27392772

0 commit comments

Comments
 (0)