freebsd-skq/usr.bin/clang
markj 401e64920a Add an lld option to emit PC-relative relocations for ifunc calls.
The current kernel ifunc implementation creates a PLT entry for each
ifunc definition.  ifunc calls therefore consist of a call to the
PLT entry followed by an indirect jump.  The jump target is written
during boot when the kernel linker resolves R_[*]_IRELATIVE relocations.
This implementation is defined by requirements for userland code, where
text relocations are avoided.  This requirement is not present for the
kernel, so the implementation has avoidable overhead (namely, an extra
indirect jump per call).

Address this for now by adding a special option to the static linker
to inhibit PLT creation for ifuncs.  Instead, relocations to ifunc call
sites are passed through to the output file, so the kernel linker can
enumerate such call sites and apply PC-relative relocations directly
to the text section.  Thus the overhead of an ifunc call becomes exactly
the same as that of an ordinary function call.  This option is only for
use by the kernel and will not work for regular programs.

The final form of this optimization is up for debate; for now, this
change is simple and static enough to be acceptable as an interim
solution.

Reviewed by:	emaste
Discussed with:	arichardson, dim
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D16748
2018-08-23 14:58:19 +00:00
..
bugpoint
clang
clang-format
clang-tblgen
llc
lld
lldb
lli
llvm-ar
llvm-as
llvm-bcanalyzer
llvm-cov
llvm-cxxdump
llvm-cxxfilt
llvm-diff
llvm-dis
llvm-dwarfdump
llvm-extract
llvm-link
llvm-lto
llvm-lto2
llvm-mc
llvm-modextract
llvm-nm
llvm-objcopy
llvm-objdump
llvm-pdbutil
llvm-profdata
llvm-rtdyld
llvm-symbolizer
llvm-tblgen
llvm-xray
opt
clang.prog.mk
llvm.prog.mk
Makefile
Makefile.inc