# LINK ERROR: relocation truncated to fit: R\_RISCV\_JAL against symbol

**URL:** <https://forums.sifive.com/t/link-error-relocation-truncated-to-fit-r-riscv-jal-against-symbol/4163>\
**Category:** RISC-V\
**Created:** [November 3, 2020, 10:21am UTC](https://forums.sifive.com/t/link-error-relocation-truncated-to-fit-r-riscv-jal-against-symbol/4163 "2020-11-03T10:21:53Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Remember](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@Remember](https://forums.sifive.com/u/Remember)\
**Post date:** [November 9, 2020, 9:46am UTC](https://forums.sifive.com/t/link-error-relocation-truncated-to-fit-r-riscv-jal-against-symbol/4163/4 "2020-11-09T09:46:42Z")

</div>

Yes, there are `jal` instruction, `j` pseudoinstruction or conditional branch instruction in these .S files in the following links… Also, there errors generate after I add some new code package into my whole project. Before that it can be built correctly even with `-ggdb -O0` options.  
[context\_gcc.S](https://github.com/RT-Thread/rt-thread/blob/master/libcpu/risc-v/common/context_gcc.S)  
[interrupt\_gcc.S](https://github.com/RT-Thread/rt-thread/blob/master/libcpu/risc-v/k210/interrupt_gcc.S)  
[startup\_gcc.S](https://github.com/RT-Thread/rt-thread/blob/master/libcpu/risc-v/k210/startup_gcc.S)

Do these errors mean that the targets of these instructions are beyond the address range they can access? And when options `-Os` is used, the size of the code is optimized to a smaller one so that those targets fall into the address range of those instructions again? If so, how should I fix it?

Sorry I cannot provide a complete testcase now.

---

_[View the full topic](https://forums.sifive.com/t/link-error-relocation-truncated-to-fit-r-riscv-jal-against-symbol/4163)._
