Page MenuHomeFreeBSD

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

Authored by jhb on Dec 3 2019, 10:27 PM.
Tags
None
Referenced Files
F103439606: D22658.diff
Mon, Nov 25, 1:28 AM
Unknown Object (File)
Sat, Nov 23, 11:19 AM
Unknown Object (File)
Thu, Nov 21, 2:24 AM
Unknown Object (File)
Wed, Nov 20, 5:44 PM
Unknown Object (File)
Tue, Nov 19, 2:30 PM
Unknown Object (File)
Fri, Nov 8, 11:04 AM
Unknown Object (File)
Thu, Nov 7, 7:35 AM
Unknown Object (File)
Tue, Nov 5, 8:31 AM
Subscribers

Details

Summary

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
correct.

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

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

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.

This revision is now accepted and ready to land.Dec 4 2019, 2:42 PM