Skip to content
New issue

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

Refer mapping symbol into R_RISCV_RELAX for rvc/norvc relaxations. #393

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion riscv-elf.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ below.

+
--
[[EF_RISCV_RVC]]
EF_RISCV_RVC (0x0001)::: This bit is set when the binary targets the C ABI,
which allows instructions to be aligned to 16-bit boundaries (the base RV32
and RV64 ISAs only allow 32-bit instruction alignment). When linking
Expand Down Expand Up @@ -430,7 +431,7 @@ Description:: Additional information about the relocation
<| S + A
.2+| 47-50 .2+| *Reserved* .2+| - | .2+| Reserved for future standard use
<|
.2+| 51 .2+| RELAX .2+| Static | .2+| Instruction can be relaxed, paired with a normal relocation at the same address
.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.
<|
.2+| 52 .2+| SUB6 .2+| Static | _word6_ .2+| Local label subtraction
<| V - S - A
Expand Down Expand Up @@ -1622,6 +1623,37 @@ instructions. It is recommended to initialize `jvt` CSR immediately after
csrw jvt, a0
----

=== Compressed and Non-compressed Relaxations in the Same Object

Linker used to enables and disables the compressed relaxations by checking the
[[EF_RISCV_RVC]] of each intput object. Since [[EF_RISCV_RVC]] is an
object-level tag, it cannot handle the case that if `.option arch, +c` and
`.option arch, -c` are in the same object. Therefore, encode the mapping symbols
into each R_RISCV_RELAX can resolve the problem.

Example::
+
--
Relaxation candidate:
[,asm]
----
.option arch, rv32i
auipc ra, 0 # R_RISCV_CALL_PLT (symbol), R_RISCV_RELAX ($xrv32i)
jalr ra, ra, 0

.option arch, +c
auipc ra, 0 # R_RISCV_CALL_PLT (symbol), R_RISCV_RELAX ($xrv32ic)
jalr ra, ra, 0
----
Relaxation result:
[,asm]
----
jal ra, 0 # R_RISCV_JAL (symbol)

c.jal ra, <offset-between-pc-and-symbol>
----
--

[bibliography]
== References

Expand Down
Loading