Skip to content

Commit

Permalink
Refer mapping symbol into R_RISCV_RELAX for rvc/norvc relaxations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelson Chu committed Jul 21, 2023
1 parent d72db56 commit cf29462
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions 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 @@ -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

0 comments on commit cf29462

Please sign in to comment.