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
Unknown Object (File)
Sun, Apr 28, 3:45 PM
Unknown Object (File)
Jan 26 2024, 5:47 AM
Unknown Object (File)
Jan 24 2024, 10:58 PM
Unknown Object (File)
Jan 10 2024, 1:48 AM
Unknown Object (File)
Nov 28 2023, 10:15 AM
Unknown Object (File)
Sep 28 2023, 10:03 PM
Unknown Object (File)
Aug 19 2023, 3:12 AM
Unknown Object (File)
Aug 14 2023, 5:45 PM
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

Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 27925
Build 26094: arc lint + arc unit

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