Page MenuHomeFreeBSD

Use "far" calls and branches so that lld uses valid relocations.

Authored by jhb on Dec 3 2019, 10:27 PM.



ld.bfd used a R_RISCV_CALL to invoke sigprocmask previously, but this
has the unfortunate effect of sometimes using the PLT stub to permit
symbol resolution and sometimes branching to the local symbol
directly. Far calls and branches use R_RISCV_CALL_PLT which always
uses a PLT stub. lld reports an error when using R_RISCV_CALL in a
shared library, so this fixes the build with lld while also being more

Test Plan
  • built world with lld
  • ran tests from /usr/tests/lib/libc/setjmp

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jhb created this revision.Dec 3 2019, 10:27 PM

In this instance it's uses of R_RISCV_JAL/R_RISCV_BRANCH rather than R_RISCV_CALL, but they all behave the same in BFD (plus their compressed variants, and interestingly also R_RISCV_PCREL_HI20). LLD will always error if you use these on undefined/preemptible symbols, much like any other architecture, whereas BFD does the weird resolution as John describes.

br accepted this revision.Dec 4 2019, 2:42 PM
This revision is now accepted and ready to land.Dec 4 2019, 2:42 PM
This revision was automatically updated to reflect the committed changes.