Author: arichardson
Date: Tue Aug 11 16:47:00 2020
New Revision: 364125
URL: https://svnweb.freebsd.org/changeset/base/364125

Log:
  Allow linking the kernel with a linker that doesn't support -z ifunc-noplt
  
  This can happen when linking with upstream LLD < 9.0.
  
  Reviewed By:  markj
  Differential Revision: https://reviews.freebsd.org/D25985

Modified:
  head/share/mk/bsd.linker.mk
  head/sys/conf/kern.pre.mk

Modified: head/share/mk/bsd.linker.mk
==============================================================================
--- head/share/mk/bsd.linker.mk Tue Aug 11 16:46:54 2020        (r364124)
+++ head/share/mk/bsd.linker.mk Tue Aug 11 16:47:00 2020        (r364125)
@@ -94,6 +94,9 @@ ${X_}LINKER_FEATURES+=        riscv-relaxations
 .if ${${X_}LINKER_TYPE} == "lld" && ${${X_}LINKER_VERSION} >= 60000
 ${X_}LINKER_FEATURES+= retpoline
 .endif
+.if ${${X_}LINKER_TYPE} == "lld" && ${${X_}LINKER_VERSION} >= 90000
+${X_}LINKER_FEATURES+= ifunc-noplt
+.endif
 .endif
 .else
 # Use LD's values

Modified: head/sys/conf/kern.pre.mk
==============================================================================
--- head/sys/conf/kern.pre.mk   Tue Aug 11 16:46:54 2020        (r364124)
+++ head/sys/conf/kern.pre.mk   Tue Aug 11 16:47:00 2020        (r364125)
@@ -166,9 +166,13 @@ LDFLAGS+=  -z max-page-size=2097152
 .if ${LINKER_TYPE} != "lld"
 LDFLAGS+=      -z common-page-size=4096
 .else
+.if defined(LINKER_FEATURES) && !${LINKER_FEATURES:Mifunc-noplt}
+.warning "Linker ${LD} does not support -z ifunc-noplt -> ifunc calls are 
unoptimized."
+.else
 LDFLAGS+=      -z notext -z ifunc-noplt
 .endif
 .endif
+.endif  # ${MACHINE_CPUARCH} == "amd64"
 
 .if ${MACHINE_CPUARCH} == "riscv"
 # Hack: Work around undefined weak symbols being out of range when linking with
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to