--- old/usr/src/Makefile.master	2018-09-19 23:19:19.657777126 +0000
+++ new/usr/src/Makefile.master	2018-09-19 23:19:19.674803023 +0000
@@ -40,6 +40,14 @@
 # and libraries.
 #
 ADJUNCT_PROTO=
+# HAVE_ADJUNCT_PROTO - ADJUNCT_PROTO is set to a non-default value
+# NO_ADJUNCT_PROTO - ADJUNCT_PROTO is unset
+#
+# This works by replacing any value in ADJUNCT_PROTO with POUND_SIGN, which
+# only happens if it has some value, and then setting HAVE_ADJUNCT_PROTO
+# oppositely.
+NO_ADJUNCT_PROTO=$(ADJUNCT_PROTO:%=$(POUND_SIGN))
+$(NO_ADJUNCT_PROTO)HAVE_ADJUNCT_PROTO=$(POUND_SIGN)
 
 #
 # Adjunct for building things that run on the build machine.
@@ -693,7 +701,7 @@
 #
 LDLIBS32 =	$(ENVLDLIBS1) $(ENVLDLIBS2) $(ENVLDLIBS3)
 LDLIBS32 +=	$(ADJUNCT_PROTO:%=-L%/usr/lib -L%/lib)
-LDLIBS.cmd = 	$(LDLIBS32)
+LDLIBS.cmd =	$(LDLIBS32)
 LDLIBS.lib =	$(LDLIBS32)
 
 LDLIBS64 =	$(ENVLDLIBS1:%=%/$(MACH64)) \
@@ -726,13 +734,22 @@
 $(__GNUC)CCNEEDED	= -L$(GCCLIBDIR) -lstdc++ -lgcc_s
 $(__GNUC)CCEXTNEEDED	= $(CCNEEDED)
 
-LINK.c=		$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
-LINK64.c=	$(CC) $(CFLAGS64) $(CPPFLAGS) $(LDFLAGS)
+# Libraries we expect to find in ADJUNCT_PROTO
+ADJUNCT_LIBS=
+# Libraries we expect to use natively on the build machine
+NATIVE_LIBS=
+
+LDCHECKS		= $(ZASSERTDEFLIB) $(ZGUIDANCE) $(ZFATALWARNINGS)
+LDCHECKS		+= $(NATIVE_LIBS:%=$(ZASSERTDEFLIB)=%)
+$(NO_ADJUNCT_PROTO)LDCHECKS += $(ADJUNCT_LIBS:%=$(ZASSERTDEFLIB)=%)
+
+LINK.c=		$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LDCHECKS)
+LINK64.c=	$(CC) $(CFLAGS64) $(CPPFLAGS) $(LDFLAGS) $(LDCHECKS)
 NORUNPATH=	-norunpath -nolib
 LINK.cc=	$(CCC) $(CCFLAGS) $(CPPFLAGS) $(NORUNPATH) \
-		$(LDFLAGS) $(CCNEEDED)
+		$(LDFLAGS) $(CCNEEDED) $(LDCHECKS)
 LINK64.cc=	$(CCC) $(CCFLAGS64) $(CPPFLAGS) $(NORUNPATH) \
-		$(LDFLAGS) $(CCNEEDED)
+		$(LDFLAGS) $(CCNEEDED) $(LDCHECKS)
 
 #
 # lint macros
@@ -887,6 +904,9 @@
 ZREDLOCSYM=	-zredlocsym
 ZTEXT=		-ztext
 ZVERBOSE=	-zverbose
+ZASSERTDEFLIB=	-zassert-deflib
+ZGUIDANCE=	-zguidance
+ZFATALWARNINGS=	-zfatal-warnings
 
 GSHARED=	-G
 CCMT=		-mt
@@ -911,8 +931,8 @@
 # CC requires there to be no space between '-K' and 'pic' or 'PIC'.
 sparc_CC_PICFLAGS =	-Kpic
 sparcv9_CC_PICFLAGS =	-KPIC
-i386_CC_PICFLAGS = 	-Kpic
-amd64_CC_PICFLAGS = 	-Kpic
+i386_CC_PICFLAGS =	-Kpic
+amd64_CC_PICFLAGS =	-Kpic
 CC_PICFLAGS =		$($(MACH)_CC_PICFLAGS)
 CC_PICFLAGS64 =		$($(MACH64)_CC_PICFLAGS)
 
@@ -964,7 +984,7 @@
 # The following list of macros are used in the definition of RELEASE_CM
 # which is used to label all binaries in the build:
 #
-# 	RELEASE		Specific release of the build, eg: 5.2
+#	RELEASE		Specific release of the build, eg: 5.2
 #	RELEASE_MAJOR	Major version number part of $(RELEASE)
 #	RELEASE_MINOR	Minor version number part of $(RELEASE)
 #	VERSION		Version of the build (alpha, beta, Generic)
@@ -991,7 +1011,7 @@
 STRIP_STABS=			   $(STRIP) -x $@
 $(SRCDBGBLD)STRIP_STABS=	   :
 
-POST_PROCESS_O=	
+POST_PROCESS_O=
 POST_PROCESS_A=
 POST_PROCESS_SO=	$(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
 			$(ELFSIGN_OBJECT)
@@ -1090,8 +1110,8 @@
 # build the catalogue with awk(1).
 
 .sh.po .ksh.po:
-	$(SED) -n -e ":a" 				\
-		  -e "h" 					\
+	$(SED) -n -e ":a"					\
+		  -e "h"					\
 		  -e "s/.*gettext *\(\"[^\"]*\"\).*/\1/p"	\
 		  -e "x"					\
 		  -e "s/\(.*\)gettext *\"[^\"]*\"\(.*\)/\1\2/"	\
--- old/usr/src/boot/sys/boot/Makefile	2018-09-19 23:19:20.164844574 +0000
+++ new/usr/src/boot/sys/boot/Makefile	2018-09-19 23:19:20.181097116 +0000
@@ -25,6 +25,8 @@
 clobber	:=	TARGET = clobber
 install	:=	TARGET = install
 
+ficl: zfs libstand
+
 all clean clobber: $(SUBDIRS)
 
 #
--- old/usr/src/cmd/Makefile	2018-09-19 23:19:20.620338526 +0000
+++ new/usr/src/cmd/Makefile	2018-09-19 23:19:20.637063784 +0000
@@ -776,7 +776,7 @@
 	auditreduce	\
 	auditset	\
 	auditstat	\
-	praudit		
+	praudit
 
 #
 # commands not owned by the systems group
@@ -823,6 +823,7 @@
 #
 # Dependencies
 #
+abi:	sgs
 fs.d:	fstyp
 ksh:	shcomp isaexec
 print:	lp
--- old/usr/src/cmd/audio/audioconvert/Makefile	2018-09-19 23:19:21.110620377 +0000
+++ new/usr/src/cmd/audio/audioconvert/Makefile	2018-09-19 23:19:21.128165087 +0000
@@ -27,7 +27,7 @@
 
 PROG= audioconvert
 
-include 	../../Makefile.cmd
+include ../../Makefile.cmd
 
 INCLUDES += -I../include -I.
 
@@ -40,6 +40,7 @@
 LDLIBS += -laudio -lm -lc
 
 LDFLAGS += -L../utilities
+$(__SUNC)ADJUNCT_LIBS = libC.so
 
 .PARALLEL:	$(OBJS)
 
--- old/usr/src/cmd/availdevs/Makefile	2018-09-19 23:19:21.560729612 +0000
+++ new/usr/src/cmd/availdevs/Makefile	2018-09-19 23:19:21.577635548 +0000
@@ -39,6 +39,7 @@
 LDLIBS += -lzfs_jni -lnvpair -lzfs
 all install := LDLIBS += -lxml2
 LINTFLAGS += -xerroff=E_NAME_USED_NOT_DEF2
+ADJUNCT_LIBS = libxml2.so
 
 CPPFLAGS += $(INCS) -D_LARGEFILE64_SOURCE=1 -D_REENTRANT
 $(NOT_RELEASE_BUILD) CPPFLAGS += -DDEBUG
--- old/usr/src/cmd/awk/Makefile	2018-09-19 23:19:22.038351849 +0000
+++ new/usr/src/cmd/awk/Makefile	2018-09-19 23:19:22.056123988 +0000
@@ -55,10 +55,12 @@
 LDLIBS += -lm
 LINTFLAGS += -u
 CLEANFILES= maketab proctab.c awk.g.c awk.lx.c y.tab.h
+NATIVELDFLAGS += -Bdirect $(LDCHECKS)
+NATIVE_LIBS= libc.so		# because this is a native tool
 
 .KEEP_STATE:
 
-all: $(PROG) 
+all: $(PROG)
 
 $(PROG): $(OBJS)
 	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
@@ -77,7 +79,7 @@
 	rm -f $@; ./maketab > $@
 
 maketab: maketab.c
-	$(NATIVECC) $(NATIVE_CFLAGS) maketab.c -o $@ $(LDLIBS)
+	$(NATIVECC) $(NATIVE_CFLAGS) -O maketab.c -o $@ $(NATIVELDFLAGS)
 
 install: all $(ROOTPROG) $(ROOTLINK)
 
--- old/usr/src/cmd/boot/bootadm/Makefile	2018-09-19 23:19:22.493012416 +0000
+++ new/usr/src/cmd/boot/bootadm/Makefile	2018-09-19 23:19:22.509140645 +0000
@@ -44,6 +44,7 @@
 LDLIBS_i386= -lfdisk
 LDLIBS += -lficl-sys -lmd -lcryptoutil -lnvpair -lgen -ladm -lefi
 LDLIBS += -lz -lbe -lzfs -lofmt $(LDLIBS_$(MACH))
+ADJUNCT_LIBS = libz.so
 
 # Writing into string literals is incorrect.  We need to match gcc's
 # behavior, which causes us to take SIGSEGV on such a write.
--- old/usr/src/cmd/boot/fiocompress/Makefile	2018-09-19 23:19:22.940981325 +0000
+++ new/usr/src/cmd/boot/fiocompress/Makefile	2018-09-19 23:19:22.958151790 +0000
@@ -39,6 +39,8 @@
 CFLAGS +=	-I../../../uts/common
 LINTFLAGS +=	-I../../../uts/common
 
+ADJUNCT_LIBS = libz.so
+
 all: $(PROG)
 
 $(PROG): $(OBJS)
--- old/usr/src/cmd/cdrw/Makefile	2018-09-19 23:19:23.409747355 +0000
+++ new/usr/src/cmd/cdrw/Makefile	2018-09-19 23:19:23.426745684 +0000
@@ -40,7 +40,8 @@
 CERRWARN +=	-_gcc=-Wno-uninitialized
 CERRWARN +=	-_gcc=-Wno-parentheses
 CPPFLAGS +=	-D_REENTRANT -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(HAL_DBUS_CPPFLAGS)
-LINTFLAGS += 	-um
+LINTFLAGS +=	-um
+ADJUNCT_LIBS =	libdbus-1.so
 
 $(ROOTBIN)/cdrw := FILEMODE = 04755
 
@@ -52,7 +53,7 @@
 	$(LINK.c) -o $(PROG) $(OBJS) $(LDLIBS) $(NONLINTLDLIBS) $(CFLAGS)
 	$(POST_PROCESS)
 
-install: all $(ROOTPROG) 
+install: all $(ROOTPROG)
 
 clean:
 	$(RM) $(OBJS)
--- old/usr/src/cmd/cmd-crypto/decrypt/Makefile.com	2018-09-19 23:19:23.869187976 +0000
+++ new/usr/src/cmd/cmd-crypto/decrypt/Makefile.com	2018-09-19 23:19:23.885538321 +0000
@@ -32,9 +32,9 @@
 
 SRCS = $(OBJS:%.o=../%.c)
 
-include ../../../Makefile.cmd 
+include ../../../Makefile.cmd
 
-CFLAGS += $(CCVERBOSE) 
+CFLAGS += $(CCVERBOSE)
 CFLAGS64 += $(CCVERBOSE)
 CPPFLAGS += -D_FILE_OFFSET_BITS=64
 
@@ -49,8 +49,6 @@
 
 lint:   lint_SRCS
 
-include ../../../Makefile.targ
-
 %.o:	../%.c
 	$(COMPILE.c) $<
 
@@ -68,3 +66,6 @@
 
 clean:
 	$(RM) $(PROG) $(OBJS)
+
+include ../../../Makefile.targ
+
--- old/usr/src/cmd/cmd-crypto/kmfcfg/Makefile	2018-09-19 23:19:24.330646658 +0000
+++ new/usr/src/cmd/cmd-crypto/kmfcfg/Makefile	2018-09-19 23:19:24.348173951 +0000
@@ -51,6 +51,7 @@
 		-I$(KMFDIR)/include -I.
 LDLIBS		+= -L$(ROOT)/usr/lib -lkmf -lcryptoutil
 XMLLIB		= -lxml2
+ADJUNCT_LIBS	= libxml2.so
 
 .KEEP_STATE:
 
--- old/usr/src/cmd/cmd-crypto/tpmadm/Makefile	2018-09-19 23:19:24.796161856 +0000
+++ new/usr/src/cmd/cmd-crypto/tpmadm/Makefile	2018-09-19 23:19:24.812353879 +0000
@@ -37,6 +37,7 @@
 CPPFLAGS += -xCC
 LINTFLAGS += -XCC  -L$(ADJUNCT_PROTO)/usr/lib
 LDLIBS += -ltspi -luuid
+ADJUNCT_LIBS = libtspi.so
 
 CLOBBERFILES = C.ln $(POFILE) $(POFILES)
 
--- old/usr/src/cmd/cmd-inet/sbin/dhcpagent/Makefile	2018-09-19 23:19:25.261363440 +0000
+++ new/usr/src/cmd/cmd-inet/sbin/dhcpagent/Makefile	2018-09-19 23:19:25.280234609 +0000
@@ -47,7 +47,7 @@
 
 CPPFLAGS  += -D_XOPEN_SOURCE=500 -D__EXTENSIONS__
 LDLIBS    += -lxnet -lnvpair -ldhcpagent -ldhcputil -linetutil -ldevinfo \
-	-ldlpi -lresolv -lsocket -lipadm
+	-ldlpi -lresolv -lipadm
 
 # Disable warnings that affect all XPG applications.
 LINTFLAGS += -erroff=E_INCONS_ARG_DECL2 -erroff=E_INCONS_VAL_TYPE_DECL2
--- old/usr/src/cmd/cmd-inet/usr.lib/wpad/Makefile	2018-09-19 23:19:25.708624517 +0000
+++ new/usr/src/cmd/cmd-inet/usr.lib/wpad/Makefile	2018-09-19 23:19:25.724101262 +0000
@@ -26,16 +26,17 @@
 MANIFEST =	wpa.xml
 OBJS =		wpa_supplicant.o wpa.o wpa_enc.o eloop.o \
 		driver_wifi.o l2_packet.o
-SRCS = 		$(OBJS:%.o=%.c)
+SRCS =		$(OBJS:%.o=%.c)
 
 include	../../../Makefile.cmd
 
 ROOTMANIFESTDIR = $(ROOTSVCNETWORK)
 
-LDLIBS    += 	-ldladm -ldlpi
+LDLIBS	  +=	-ldladm -ldlpi
 all install := LDLIBS += -lcrypto
+all install := ADJUNCT_LIBS = libcrypto.so
 
-LINTFLAGS += 	-u
+LINTFLAGS +=	-u
 
 .KEEP_STATE:
 
--- old/usr/src/cmd/cmd-inet/usr.sbin/in.routed/Makefile	2018-09-19 23:19:26.127973203 +0000
+++ new/usr/src/cmd/cmd-inet/usr.sbin/in.routed/Makefile	2018-09-19 23:19:26.144266922 +0000
@@ -11,7 +11,7 @@
 RTQUERYPROG=	rtquery
 RTQUERYOBJS=	common.o rtquery.o
 RTQUERYSRCS=	$(RTQUERYOBJS:.o=.c)
-POFILEOBJS=	$(ROUTEDOBJS) $(RTQUERYOBJS)	
+POFILEOBJS=	$(ROUTEDOBJS) $(RTQUERYOBJS)
 
 PROG=		$(ROUTEDPROG) $(RTQUERYPROG)
 SRCS=		$(ROUTEDSRCS) $(RTQUERYSRCS)
@@ -39,7 +39,7 @@
 CFLAGS +=	$(CCVERBOSE)
 CERRWARN +=	-_gcc=-Wno-parentheses
 CERRWARN +=	-_gcc=-Wno-uninitialized
-LDLIBS +=	-lxnet -lmd -lsocket
+LDLIBS +=	-lxnet -lmd
 CLEAN_FILES +=	$(ROUTEDOBJS) $(RTQUERYOBJS)
 CLOBBERFILES +=	$(ROUTEDPROG) $(RTQUERYPROG)
 #
--- old/usr/src/cmd/cmd-inet/usr.sbin/ipadm/Makefile	2018-09-19 23:19:26.592596477 +0000
+++ new/usr/src/cmd/cmd-inet/usr.sbin/ipadm/Makefile	2018-09-19 23:19:26.609251569 +0000
@@ -33,7 +33,7 @@
 include ../../../Makefile.cmd
 include ../../Makefile.cmd-inet
 
-XGETFLAGS += 	-a -x $(PROG).xcl
+XGETFLAGS +=	-a -x $(PROG).xcl
 LOCALSRCS=	$(LOCALOBJS:%.o=%.c)
 COMMONSRCS=	$(CMDINETCOMMONDIR)/$(COMMONOBJS:%.o=%.c)
 SRCS=		$(LOCALSRCS) $(COMMONSRCS)
@@ -46,12 +46,7 @@
 
 ROOTUSRSBINLINKS = $(PROG:%=$(ROOTUSRSBIN)/%)
 
-# ipadm uses the ancillary data feature which is available only through
-# UNIX 98 standards version of Socket interface. This interface is supposed to
-# be accessed by -lxnet. In addition -lsocket is used to capture new
-# not-yet-standard interfaces. Someday -lxnet alone should be enough when IPv6
-# inspired new interfaces are part of standards.
-LDLIBS +=	-lxnet -lsocket
+LDLIBS +=	-lxnet
 
 # these #defines are required to use UNIX 98 interfaces
 _D_UNIX98_EXTN= -D_XOPEN_SOURCE=500 -D__EXTENSIONS__
--- old/usr/src/cmd/cmd-inet/usr.sbin/ping/Makefile	2018-09-19 23:19:27.083054204 +0000
+++ new/usr/src/cmd/cmd-inet/usr.sbin/ping/Makefile	2018-09-19 23:19:27.100058762 +0000
@@ -33,7 +33,7 @@
 
 # Ping uses the ancillary data feature which is available only through
 # UNIX 98 standards version of Socket interface. This interface is supposed to
-# be accessed by -lxnet. In addition -lsocket and is used to
+# be accessed by -lxnet. In addition -lsocket is used to
 # capture new not-yet-standard interfaces. Someday -lxnet alone should be enough
 # when IPv6 inspired new interfaces are part of standards.
 LDLIBS +=	-lxnet -lsocket -lm -linetutil
--- old/usr/src/cmd/cmd-inet/usr.sbin/traceroute/Makefile	2018-09-19 23:19:27.534735469 +0000
+++ new/usr/src/cmd/cmd-inet/usr.sbin/traceroute/Makefile	2018-09-19 23:19:27.550060905 +0000
@@ -33,9 +33,9 @@
 
 # Traceroute uses the ancillary data feature which is available only through
 # UNIX 98 standards version of Socket interface. This interface is supposed to
-# be accessed by -lxnet. In addition -lsocket is used to
-# capture new not-yet-standard interfaces. Someday -lxnet alone should be enough
-# when IPv6 inspired new interfaces are part of standards.
+# be accessed by -lxnet. In addition -lsocket is used to capture new
+# not-yet-standard interfaces. Someday -lxnet alone should be enough when IPv6
+# inspired new interfaces are part of standards.
 LDLIBS +=	-lxnet -lsocket -linetutil
 
 # These #defines are required to use UNIX 98 interfaces
--- old/usr/src/cmd/dfs.cmds/sharemgr/Makefile.com	2018-09-19 23:19:27.946328101 +0000
+++ new/usr/src/cmd/dfs.cmds/sharemgr/Makefile.com	2018-09-19 23:19:27.962983244 +0000
@@ -41,6 +41,7 @@
 CPPFLAGS += $(MYCPPFLAGS)
 LDLIBS += -lshare -lscf -lsecdb -lumem
 all install := LDLIBS += -lxml2
+all install := ADJUNCT_LIBS = libxml2.so
 LINTFLAGS	+= -u
 
 CERRWARN	+= -_gcc=-Wno-uninitialized
--- old/usr/src/cmd/fm/modules/common/fabric-xlate/Makefile	2018-09-19 23:19:28.376709446 +0000
+++ new/usr/src/cmd/fm/modules/common/fabric-xlate/Makefile	2018-09-19 23:19:28.391498249 +0000
@@ -36,6 +36,7 @@
 LINTFLAGS += -I$(INCDIRS)
 
 LDFLAGS += -L$(ROOT)/usr/lib/fm -R/usr/lib/fm
+ADJUNCT_LIBS = libxml2.so
 LDLIBS += -luutil -lxml2 -L$(ROOTLIB)/fm -ltopo
 
 CERRWARN += -_gcc=-Wno-parentheses
--- old/usr/src/cmd/fm/notify/snmp-notify/Makefile.com	2018-09-19 23:19:28.786354584 +0000
+++ new/usr/src/cmd/fm/notify/snmp-notify/Makefile.com	2018-09-19 23:19:28.806550816 +0000
@@ -48,6 +48,7 @@
 LDLIBS += -L$(ROOT)/usr/lib/fm -lnvpair -lfmevent -lfmd_msg -lfmnotify \
 	-lumem -lnetsnmp -lnetsnmpagent
 LDFLAGS += -R/usr/lib/fm
+ADJUNCT_LIBS = libnetsnmp.so libnetsnmpagent.so
 LINTFLAGS += -mnu
 
 CERRWARN += -_gcc=-Wno-parentheses
--- old/usr/src/cmd/fm/schemes/cpu/amd64/Makefile	2018-09-19 23:19:29.304621279 +0000
+++ new/usr/src/cmd/fm/schemes/cpu/amd64/Makefile	2018-09-19 23:19:29.322348541 +0000
@@ -28,7 +28,7 @@
 include $(SRC)/Makefile.master.64
 
 SRCS = cpu.c
-LDFLAGS += -lkstat \
+LDLIBS += -lkstat \
 	-L$(ROOTLIB)/fm/$(MACH64) -ltopo
 LDFLAGS += -R/usr/lib/fm/$(MACH64)
 
--- old/usr/src/cmd/fs.d/nfs/nfsmapid/Makefile	2018-09-19 23:19:29.738687022 +0000
+++ new/usr/src/cmd/fs.d/nfs/nfsmapid/Makefile	2018-09-19 23:19:29.750868703 +0000
@@ -31,7 +31,6 @@
 include		../../Makefile.fstype
 
 LDLIBS   +=	-L$(ROOT)/usr/lib/nfs -R/usr/lib/nfs
-LDLIBS   +=	-lnsl -lmapid -ldtrace -lidmap
 COMMON    =	nfs_resolve.o
 SRCS	  =	nfsmapid.c ../lib/nfs_resolve.c nfsmapid_server.c
 DSRC	  =	nfsmapid_dt.d
@@ -44,6 +43,8 @@
 CERRWARN +=	-_gcc=-Wno-parentheses
 CERRWARN +=	-_gcc=-Wno-uninitialized
 
+$(TYPEPROG) := LDLIBS += -lnsl -lmapid -ldtrace -lidmap
+
 all:		$(TYPEPROG) $(TESTPROG)
 
 $(TYPEPROG):	$(OBJS) $(DSRC)
--- old/usr/src/cmd/geniconvtbl/Makefile.com	2018-09-19 23:19:30.197965968 +0000
+++ new/usr/src/cmd/geniconvtbl/Makefile.com	2018-09-19 23:19:30.215588680 +0000
@@ -74,13 +74,13 @@
 ROOTITM64 =	$(ROOTDIRS64)/$(ITM)
 
 #
-# definition for some useful target like clean, 
+# definition for some useful target like clean,
 OBJS	= $(SRCSC1:%.c=%.o) $(YTABC:.c=.o) $(LEXYY:.c=.o)
 
 CHECKHDRS = $(HDRS%.h=%.check)
 
 CLOBBERFILES=	$(ITM) $(SRCYC)
-CLEANFILES = 	$(OBJS) $(YTABC) $(YTABH) $(LEXYY) $(YOUT) \
+CLEANFILES =	$(OBJS) $(YTABC) $(YTABH) $(LEXYY) $(YOUT) \
 		$(POFILES) $(POFILE)
 
 CPPFLAGS	+= -I. -I..
@@ -90,17 +90,20 @@
 CERRWARN	+= -_gcc=-Wno-unused-variable
 CERRWARN	+= -_gcc=-Wno-implicit-function-declaration
 YFLAGS		+= -d -v
-CFLAGS 		+= -D_FILE_OFFSET_BITS=64
+CFLAGS		+= -D_FILE_OFFSET_BITS=64
 
 $(ITM) :=	CFLAGS += $(GSHARED) $(C_PICFLAGS) $(ZTEXT) -h $@
-$(ITM) :=	CPPFLAGS += -D_REENTRANT 
+$(ITM) :=	CPPFLAGS += -D_REENTRANT
 $(ITM) :=	sparc_CFLAGS += -xregs=no%appl
 $(ITM) :=	sparcv9_CFLAGS += -xregs=no%appl
 
 LDLIBS += -lgen
 
 MY_NATIVE_CPPFLAGS = -D_FILE_OFFSET_BITS=64 -I. -I..
-MY_NATIVE_LDFLAGS = $(MAPFILE.NES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%)
+MY_NATIVE_LDFLAGS = $(MAPFILE.NES:%=-M%) $(MAPFILE.PGA:%=-M%) \
+			$(MAPFILE.NED:%=-M%) -Bdirect \
+			-zassert-deflib=libgen.so \
+			-zassert-deflib=libc.so
 MY_NATIVE_LDLIBS = -lgen
 
 #
@@ -171,7 +174,7 @@
 	$(MAKE)	all COPTFLAG='' COPTFLAG64='' CFLAGS='-g -DDEBUG'
 
 
-%.o:	%.c 
+%.o:	%.c
 	$(COMPILE.c) $<
 
 %.o:	../%.c
@@ -180,7 +183,7 @@
 
 
 # install rule
-# 
+#
 $(ROOTDIRS32)/%: $(ROOTDIRS32) %
 	-$(INS.file)
 
--- old/usr/src/cmd/hal/addons/acpi/Makefile	2018-09-19 23:19:30.668595300 +0000
+++ new/usr/src/cmd/hal/addons/acpi/Makefile	2018-09-19 23:19:30.685815196 +0000
@@ -33,6 +33,7 @@
 ROOTCMDDIR =	$(ROOTLIB_HAL)
 
 LDLIBS +=	-lc -ldbus-1 -lhal -lglib-2.0
+ADJUNCT_LIBS =	libdbus-1.so libglib-2.0.so
 
 CPPFLAGS +=	$(HAL_DBUS_CPPFLAGS) $(HAL_GLIB_CPPFLAGS) $(HAL_CONFIG_CPPFLAGS)
 CPPFLAGS +=	-I$(ROOT)/usr/include/hal -I../../hald
--- old/usr/src/cmd/hal/addons/cpufreq/Makefile	2018-09-19 23:19:31.123008183 +0000
+++ new/usr/src/cmd/hal/addons/cpufreq/Makefile	2018-09-19 23:19:31.139064917 +0000
@@ -34,6 +34,7 @@
 ROOTCMDDIR =	$(ROOTLIB_HAL)
 
 LDLIBS +=	-lc -ldbus-1 -lhal -lglib-2.0 -ldbus-glib-1 -lpolkit -lbsm
+ADJUNCT_LIBS =	libdbus-1.so libglib-2.0.so libdbus-glib-1.so
 
 CPPFLAGS +=	$(HAL_DBUS_CPPFLAGS) $(HAL_GLIB_CPPFLAGS) $(HAL_CONFIG_CPPFLAGS)
 CPPFLAGS +=	-I$(ROOT)/usr/include/hal -I../../hald
--- old/usr/src/cmd/hal/addons/network-devices/Makefile	2018-09-19 23:19:31.544727821 +0000
+++ new/usr/src/cmd/hal/addons/network-devices/Makefile	2018-09-19 23:19:31.561943951 +0000
@@ -42,6 +42,7 @@
 LDLIBS +=	-lc -ldbus-1 -lhal -lglib-2.0 -ldbus-glib-1
 LDLIBS +=	-lnsl -lsocket
 LDLIBS +=	$(ZIGNORE) -lnetsnmp
+ADJUNCT_LIBS =	libdbus-1.so libglib-2.0.so libdbus-glib-1.so libnetsnmp.so
 
 CPPFLAGS +=	$(HAL_DBUS_CPPFLAGS) $(HAL_GLIB_CPPFLAGS) $(HAL_CONFIG_CPPFLAGS)
 CPPFLAGS +=	-I$(ROOT)/usr/include/hal -I../../hald -I../../utils
--- old/usr/src/cmd/hal/addons/storage/Makefile	2018-09-19 23:19:32.022418115 +0000
+++ new/usr/src/cmd/hal/addons/storage/Makefile	2018-09-19 23:19:32.039485475 +0000
@@ -33,6 +33,7 @@
 ROOTCMDDIR =	$(ROOTLIB_HAL)
 
 LDLIBS +=	-lc -ldbus-1 -lhal -lnvpair -lsysevent
+ADJUNCT_LIBS =	libdbus-1.so
 
 CPPFLAGS +=	$(HAL_DBUS_CPPFLAGS) $(HAL_CONFIG_CPPFLAGS)
 CPPFLAGS +=	-I$(ROOT)/usr/include/hal -I../../hald
--- old/usr/src/cmd/hal/hald-runner/Makefile	2018-09-19 23:19:32.468613348 +0000
+++ new/usr/src/cmd/hal/hald-runner/Makefile	2018-09-19 23:19:32.486442913 +0000
@@ -33,6 +33,7 @@
 ROOTCMDDIR =	$(ROOTLIB_HAL)
 
 LDLIBS +=	-lc -ldbus-1 -ldbus-glib-1 -lglib-2.0
+ADJUNCT_LIBS =	libdbus-1.so libdbus-glib-1.so libglib-2.0.so
 
 CPPFLAGS +=	$(HAL_DBUS_CPPFLAGS) $(HAL_GLIB_CPPFLAGS) $(HAL_CONFIG_CPPFLAGS)
 CPPFLAGS +=	-UDBUS_API_SUBJECT_TO_CHANGE
--- old/usr/src/cmd/hal/hald/Makefile	2018-09-19 23:19:32.907277071 +0000
+++ new/usr/src/cmd/hal/hald/Makefile	2018-09-19 23:19:32.922911455 +0000
@@ -42,8 +42,11 @@
 
 LDLIBS +=	-lc -lm -ldbus-1 -ldbus-glib-1 -lglib-2.0 -lgobject-2.0 \
 		-ldevinfo -lsysevent -lnvpair -lkstat -lcfgadm
+ADJUNCT_LIBS =	libdbus-1.so libdbus-glib-1.so libglib-2.0.so libgobject-2.0.so
+
 
 all install $(PROG) :=	LDLIBS += -lexpat
+all install $(PROG) :=	ADJUNCT_LIBS += libexpat.so
 
 CPPFLAGS +=	$(HAL_DBUS_CPPFLAGS) $(HAL_GLIB_CPPFLAGS) $(HAL_CONFIG_CPPFLAGS)
 CSTD =	$(CSTD_GNU99)
--- old/usr/src/cmd/hal/probing/acpi/Makefile	2018-09-19 23:19:33.348907568 +0000
+++ new/usr/src/cmd/hal/probing/acpi/Makefile	2018-09-19 23:19:33.365257431 +0000
@@ -33,6 +33,7 @@
 ROOTCMDDIR =	$(ROOTLIB_HAL)
 
 LDLIBS +=	-lc -ldbus-1 -lhal -lglib-2.0
+ADJUNCT_LIBS =	libdbus-1.so libglib-2.0.so
 
 CPPFLAGS +=	$(HAL_DBUS_CPPFLAGS) $(HAL_CONFIG_CPPFLAGS) $(HAL_GLIB_CPPFLAGS)
 CPPFLAGS +=	-I$(ROOT)/usr/include/hal -I../../utils -I../../hald
--- old/usr/src/cmd/hal/probing/network-printer/Makefile	2018-09-19 23:19:33.790272653 +0000
+++ new/usr/src/cmd/hal/probing/network-printer/Makefile	2018-09-19 23:19:33.806690740 +0000
@@ -35,6 +35,7 @@
 
 LDLIBS +=	-lc -ldbus-1 -lhal
 LDLIBS +=	$(ZIGNORE) -lnetsnmp
+ADJUNCT_LIBS =	libdbus-1.so libnetsnmp.so
 
 CPPFLAGS +=	$(HAL_DBUS_CPPFLAGS) $(HAL_CONFIG_CPPFLAGS)
 CPPFLAGS +=	-I$(ROOT)/usr/include/hal -I../../utils -I../../hald
--- old/usr/src/cmd/hal/probing/printer/Makefile	2018-09-19 23:19:34.257489935 +0000
+++ new/usr/src/cmd/hal/probing/printer/Makefile	2018-09-19 23:19:34.275456047 +0000
@@ -33,6 +33,7 @@
 ROOTCMDDIR =	$(ROOTLIB_HAL)
 
 LDLIBS +=	-lc -ldbus-1 -lhal
+ADJUNCT_LIBS =	libdbus-1.so
 
 CPPFLAGS +=	$(HAL_DBUS_CPPFLAGS) $(HAL_CONFIG_CPPFLAGS)
 CPPFLAGS +=	-I$(ROOT)/usr/include/hal -I../../utils -I../../hald
--- old/usr/src/cmd/hal/probing/storage/Makefile	2018-09-19 23:19:34.710944304 +0000
+++ new/usr/src/cmd/hal/probing/storage/Makefile	2018-09-19 23:19:34.727537675 +0000
@@ -33,6 +33,7 @@
 ROOTCMDDIR =	$(ROOTLIB_HAL)
 
 LDLIBS +=	-lc -ldbus-1 -lhal -ladm -lefi
+ADJUNCT_LIBS =	libdbus-1.so
 
 CPPFLAGS +=	-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
 CPPFLAGS +=	$(HAL_DBUS_CPPFLAGS) $(HAL_CONFIG_CPPFLAGS)
--- old/usr/src/cmd/hal/probing/volume/Makefile	2018-09-19 23:19:35.174171079 +0000
+++ new/usr/src/cmd/hal/probing/volume/Makefile	2018-09-19 23:19:35.190701082 +0000
@@ -33,6 +33,7 @@
 ROOTCMDDIR =	$(ROOTLIB_HAL)
 
 LDLIBS +=	-lc -ldbus-1 -lhal -lfstyp -lnvpair -ladm -lefi
+ADJUNCT_LIBS =	libdbus-1.so
 
 CPPFLAGS +=	-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
 CPPFLAGS +=	$(HAL_DBUS_CPPFLAGS) $(HAL_CONFIG_CPPFLAGS)
--- old/usr/src/cmd/hal/probing/xkb/Makefile	2018-09-19 23:19:35.627922593 +0000
+++ new/usr/src/cmd/hal/probing/xkb/Makefile	2018-09-19 23:19:35.645166687 +0000
@@ -34,6 +34,7 @@
 ROOTCMDDIR =	$(ROOTLIB_HAL)
 
 LDLIBS +=	-lc -ldbus-1 -lhal
+ADJUNCT_LIBS =	libdbus-1.so
 
 CPPFLAGS +=	$(HAL_DBUS_CPPFLAGS) $(HAL_CONFIG_CPPFLAGS)
 CPPFLAGS +=	-I$(ROOT)/usr/include/hal -I../../hald
--- old/usr/src/cmd/hal/tools/Makefile	2018-09-19 23:19:36.095120098 +0000
+++ new/usr/src/cmd/hal/tools/Makefile	2018-09-19 23:19:36.116636503 +0000
@@ -23,7 +23,7 @@
 # Use is subject to license terms.
 #
 
-SUBDIR =	sunos	
+SUBDIR =	sunos
 
 HAL_PROG =	hal-device hal-find-by-capability hal-find-by-property \
 		hal-get-property hal-set-property lshal
@@ -60,12 +60,16 @@
 include ../Makefile.hal
 
 $(HAL_PROG) :=		LDLIBS += -lc -ldbus-1 -lhal
+$(HAL_PROG) :=		ADJUNCT_LIBS = libdbus-1.so
 
 lshal :=		LDLIBS += -ldbus-glib-1 -lglib-2.0
+lshal :=		ADJUNCT_LIBS = libdbus-glib-1.so libdbus-1.so libglib-2.0.so
 
 $(HAL_LIB) :=	LDLIBS += -lc -ldbus-1 -lpolkit $(ZIGNORE) -lglib-2.0
+$(HAL_LIB) :=	ADJUNCT_LIBS = libdbus-1.so libglib-2.0.so
 
 $(STORAGE_PROG)	:=	LDLIBS += -lc -ldbus-1 -lglib-2.0 -lhal -lhal-storage -lbsm
+$(STORAGE_PROG) :=	ADJUNCT_LIBS = libdbus-1.so libglib-2.0.so
 
 $(STORAGE_METHOD_PROG) := LDLIBS += -lpolkit
 
--- old/usr/src/cmd/hal/tools/sunos/Makefile	2018-09-19 23:19:36.572488112 +0000
+++ new/usr/src/cmd/hal/tools/sunos/Makefile	2018-09-19 23:19:36.589016438 +0000
@@ -37,13 +37,14 @@
 include ../../Makefile.hal
 
 $(HAL_PROGS) :=		LDLIBS += -lc $(ZIGNORE) -lglib-2.0
+$(HAL_PROGS) :=		ADJUNCT_LIBS = libglib-2.0.so
 
 CPPFLAGS += $(HAL_DBUS_CPPFLAGS) $(HAL_GLIB_CPPFLAGS) $(HAL_CONFIG_CPPFLAGS)
 CPPFLAGS += -I$(ROOT)/usr/include/hal
 CPPFLAGS += -I$(ROOT)/usr/include/libpolkit
 CSTD = $(CSTD_GNU99)
 
-ROOTCMDDIR =		$(ROOTLIB_HAL)/sunos 
+ROOTCMDDIR =		$(ROOTLIB_HAL)/sunos
 ROOTCMD =		$(HAL_PROGS:%=$(ROOTCMDDIR)/%) \
 			$(HAL_SCRIPTS:%=$(ROOTCMDDIR)/%)
 
--- old/usr/src/cmd/isns/isnsadm/Makefile	2018-09-19 23:19:37.064244132 +0000
+++ new/usr/src/cmd/isns/isnsadm/Makefile	2018-09-19 23:19:37.081938186 +0000
@@ -30,6 +30,7 @@
 include ../../Makefile.cmd
 
 LDLIBS += -lxml2 -lscf -lc
+ADJUNCT_LIBS = libxml2.so
 CFLAGS += $(CCVERBOSE)
 CPPFLAGS += -I. -I$(ADJUNCT_PROTO)/usr/include/libxml2 -I../isnsd
 POFILE = isnsadm_all.po
--- old/usr/src/cmd/isns/isnsd/Makefile	2018-09-19 23:19:37.530260622 +0000
+++ new/usr/src/cmd/isns/isnsd/Makefile	2018-09-19 23:19:37.548142356 +0000
@@ -51,8 +51,8 @@
 ROOTMANIFESTDIR	= $(ROOTSVCNETWORK)
 $(ROOTSVCNETWORK)/isns_server.xml	:= FILEMODE = 0444
 
-CFLAGS 		+=	$(CCVERBOSE)
-CPPFLAGS 	+= -I./ -I$(ADJUNCT_PROTO)/usr/include/libxml2
+CFLAGS		+=	$(CCVERBOSE)
+CPPFLAGS	+= -I./ -I$(ADJUNCT_PROTO)/usr/include/libxml2
 CPPFLAGS	+= -DTARGET_DATA_STORE=$(DATA_STORE)
 CPPFLAGS	+= -D_POSIX_PTHREAD_SEMANTICS
 LINTFLAGS += -xerroff=E_BAD_PTR_CAST_ALIGN
@@ -70,6 +70,7 @@
 obj.o := CERRWARN += -erroff=E_IMPLICIT_DECL_FUNC_RETURN_INT
 
 LDLIBS		+= -lsecdb -lsocket -lnsl -lscf -lxml2
+ADJUNCT_LIBS	= libxml2.so
 
 .KEEP_STATE:
 
--- old/usr/src/cmd/latencytop/Makefile.com	2018-09-19 23:19:38.000270254 +0000
+++ new/usr/src/cmd/latencytop/Makefile.com	2018-09-19 23:19:38.018497021 +0000
@@ -39,6 +39,7 @@
 CSTD = $(CSTD_GNU99)
 LDLIBS += -lcurses -ldtrace
 all install	:= LDLIBS += -lglib-2.0
+all install	:= ADJUNCT_LIBS = libglib-2.0.so
 
 LINTFLAGS += -erroff=E_NAME_USED_NOT_DEF2
 LINTFLAGS += -erroff=E_FUNC_RET_ALWAYS_IGNOR2
--- old/usr/src/cmd/lp/filter/postscript/font/Makefile	2018-09-19 23:19:38.481741582 +0000
+++ new/usr/src/cmd/lp/filter/postscript/font/Makefile	2018-09-19 23:19:38.499802323 +0000
@@ -20,13 +20,11 @@
 # CDDL HEADER END
 #
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
+
 #
 # Copyright 1989-2002 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# cmd/lp/filter/postscript/font/Makefile
-#
 
 include			../../../Makefile.lp
 
@@ -51,6 +49,8 @@
 $(NATIVEPROG) :=	CC=$(NATIVECC)
 $(NATIVEPROG) :=	LDLIBS=
 $(NATIVEPROG) :=	CPPFLAGS.master=
+$(NATIVEPROG) :=	LDFLAGS= -Bdirect
+$(NATIVEPROG) :=	NATIVE_LIBS=libc.so
 
 .KEEP_STATE:
 
--- old/usr/src/cmd/mandoc/Makefile.common	2018-09-19 23:19:38.974577256 +0000
+++ new/usr/src/cmd/mandoc/Makefile.common	2018-09-19 23:19:38.992114253 +0000
@@ -85,3 +85,4 @@
 CPPFLAGS +=	-DOSNAME="\"illumos\"" -D_FILE_OFFSET_BITS=64
 
 LDLIBS +=	-lz
+ADJUNCT_LIBS += libz.so
--- old/usr/src/cmd/mdb/intel/amd64/dtrace/Makefile	2018-09-19 23:19:39.429423992 +0000
+++ new/usr/src/cmd/mdb/intel/amd64/dtrace/Makefile	2018-09-19 23:19:39.445686547 +0000
@@ -23,7 +23,6 @@
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"%Z%%M%	%I%	%E% SMI"
 
 MODULE = dtrace.so
 MDBTGT = kvm
--- old/usr/src/cmd/mdb/tools/setdynflag/Makefile.com	2018-09-19 23:19:39.885956994 +0000
+++ new/usr/src/cmd/mdb/tools/setdynflag/Makefile.com	2018-09-19 23:19:39.903246290 +0000
@@ -46,6 +46,8 @@
 CERRWARN += -_gcc=-Wno-uninitialized
 LDFLAGS =
 LDLIBS	= -lelf
+LDFLAGS += -Bdirect
+NATIVE_LIBS = libelf.so libc.so
 
 LINTFILES = $(SRCS:%.c=%.ln)
 
--- old/usr/src/cmd/oawk/Makefile	2018-09-19 23:19:40.368186359 +0000
+++ new/usr/src/cmd/oawk/Makefile	2018-09-19 23:19:40.384810766 +0000
@@ -50,13 +50,13 @@
 $(MAKEPRCTAB) :=	CC = $(NATIVECC)
 $(MAKEPRCTAB) :=	POST_PROCESS=
 $(MAKEPRCTAB) :=	POST_PROCESS_O=
+$(MAKEPRCTAB) :=	NATIVE_LIBS = libc.so
 
 CLEANFILES =	proctab.c y.tab.h y.tab.c awk.h awk.g.c		\
 		tmptoken.c awk.lx.c $(NATIVEOBJS) $(MAKEPRCTAB)	\
 		temp
 
 YFLAGS =	-d
-XLDLIBS5CC +=	-lm 
 LDLIBS +=	-lm
 CPPFLAGS =      -I. $(CPPFLAGS.master)
 CPPFLAGS +=	-D_FILE_OFFSET_BITS=64
@@ -79,7 +79,7 @@
 
 $(POFILE):      $(POFILES)
 		$(RM)	$@
-		$(CAT) 	$(POFILES)      > $@
+		$(CAT)	$(POFILES)	> $@
 
 awk.g.c + awk.h :	awk.g.y
 		$(RM) awk.g.c awk.h
@@ -99,9 +99,9 @@
 		$(MAKEPRCTAB) > $@
 
 $(MAKEPRCTAB) :	$(NATIVEDIR) $(NATIVEOBJS)
-		$(LINK.c) $(NATIVEOBJS) -o $@ $(XLDLIBS5CC)
+		$(LINK.c) $(NATIVEOBJS) -o $@
 
-install : 	all $(ROOTPROG) $(ROOTLINK)
+install :	all $(ROOTPROG) $(ROOTLINK)
 
 $(NATIVEDIR) :
 		-@mkdir -p $(NATIVEDIR)
--- old/usr/src/cmd/picl/plugins/common/piclevent/Makefile	2018-09-19 23:19:40.819728230 +0000
+++ new/usr/src/cmd/picl/plugins/common/piclevent/Makefile	2018-09-19 23:19:40.836463017 +0000
@@ -64,6 +64,7 @@
 CPPFLAGS +=	-D_REENTRANT
 LDLIBS +=	-L$(SRC)/lib/libsysevent -L$(SRC)/lib/libpicltree/$(MACH)
 LDLIBS +=	-lc -lpicltree -lnvpair
+LDFLAGS +=	-Bdirect
 
 LINTFLAGS +=	-L$(SRC)/lib/libpicltree/$(MACH) -lpicltree
 
--- old/usr/src/cmd/policykit/Makefile	2018-09-19 23:19:41.287072210 +0000
+++ new/usr/src/cmd/policykit/Makefile	2018-09-19 23:19:41.303458333 +0000
@@ -31,6 +31,7 @@
 include $(SRC)/lib/policykit/Makefile.policykit
 
 LDLIBS +=	-lpolkit $(POLICYKIT_GLIB_LDLIBS)
+ADJUNCT_LIBS +=	$(POLICYKIT_GLIB_EXTERNS)
 
 CPPFLAGS +=	-I$(ROOT)/usr/include/libpolkit
 CPPFLAGS +=	$(POLICYKIT_DBUS_CPPFLAGS) $(POLICYKIT_GLIB_CPPFLAGS)
--- old/usr/src/cmd/rcm_daemon/Makefile.com	2018-09-19 23:19:41.744516040 +0000
+++ new/usr/src/cmd/rcm_daemon/Makefile.com	2018-09-19 23:19:41.761338763 +0000
@@ -129,18 +129,26 @@
 
 LINTFLAGS += -u -erroff=E_FUNC_ARG_UNUSED
 
-LDLIBS_MODULES =
-SUNW_pool_rcm.so := LDLIBS_MODULES += -L$(ROOT)/usr/lib -lpool
-SUNW_network_rcm.so := LDLIBS_MODULES += -L$(ROOT)/lib -ldladm
-SUNW_vlan_rcm.so := LDLIBS_MODULES += -L$(ROOT)/lib -ldladm
-SUNW_vnic_rcm.so := LDLIBS_MODULES += -L$(ROOT)/lib -ldladm
-SUNW_ibpart_rcm.so := LDLIBS_MODULES += -L$(ROOT)/lib -ldladm
-SUNW_aggr_rcm.so := LDLIBS_MODULES += -L$(ROOT)/lib -ldladm
-SUNW_ip_rcm.so := LDLIBS_MODULES += -L$(ROOT)/lib -linetutil -ldladm -lipmp -lipadm
-SUNW_ip_anon_rcm.so := LDLIBS_MODULES += -L$(ROOT)/lib -linetutil
-SUNW_bridge_rcm.so := LDLIBS_MODULES += -L$(ROOT)/lib -ldladm
+#
+# All of the module plugins leverage the LDLIBS_MODULES, but not LDLIBS. As such
+# we define a base set for all modules that we know they need due to -zguidance
+# and only append extra libraries that individual modules need.
+#
+LDLIBS_MODULES = -L$(ROOT)/lib -L$(ROOT)/usr/lib -lc -lrcm
+SUNW_pool_rcm.so := LDLIBS_MODULES += -lpool -lnvpair
+SUNW_svm_rcm.so	:= LDLIBS_MODULES += -lmeta
+SUNW_network_rcm.so := LDLIBS_MODULES += -ldladm -lnvpair -ldevinfo
+SUNW_vlan_rcm.so := LDLIBS_MODULES += -ldladm -lnvpair
+SUNW_vnic_rcm.so := LDLIBS_MODULES += -ldladm -lnvpair
+SUNW_ibpart_rcm.so := LDLIBS_MODULES += -ldladm -lnvpair
+SUNW_aggr_rcm.so := LDLIBS_MODULES +=  -ldladm -lnvpair
+SUNW_ip_rcm.so := LDLIBS_MODULES += -linetutil -ldladm -lipmp -lipadm -lnvpair \
+				    -lgen -lsocket
+SUNW_ip_anon_rcm.so := LDLIBS_MODULES +=  -linetutil -lnsl
+SUNW_bridge_rcm.so := LDLIBS_MODULES += -ldladm -lnvpair
+SUNW_mpxio_rcm.so := LDLIBS_MODULES += -ldevinfo
 
-LDLIBS += -lgen -lelf -lrcm -lnvpair -ldevinfo -lnsl -lsocket
+LDLIBS += -lrcm -lnvpair
 
 SRCS = $(RCM_SRC) $(COMMON_MOD_SRC)
 
--- old/usr/src/cmd/rmmount/Makefile	2018-09-19 23:19:42.234695484 +0000
+++ new/usr/src/cmd/rmmount/Makefile	2018-09-19 23:19:42.251395646 +0000
@@ -34,7 +34,9 @@
 include $(SRC)/cmd/Makefile.cmd
 include $(SRC)/cmd/hal/Makefile.hal
 
-LDLIBS +=	-ldbus-1 -ldbus-glib-1 -lglib-2.0 -lhal -lhal-storage -lcontract
+LDLIBS +=	-ldbus-1 -ldbus-glib-1 -lglib-2.0 -lhal -lhal-storage \
+		    -lcontract
+ADJUNCT_LIBS =	libdbus-1.so libdbus-glib-1.so libglib-2.0.so
 
 CPPFLAGS +=	$(HAL_DBUS_CPPFLAGS) $(HAL_GLIB_CPPFLAGS)
 CPPFLAGS +=	-I$(ROOT)/usr/include/hal
--- old/usr/src/cmd/rmvolmgr/Makefile	2018-09-19 23:19:42.671397056 +0000
+++ new/usr/src/cmd/rmvolmgr/Makefile	2018-09-19 23:19:42.681030354 +0000
@@ -36,17 +36,19 @@
 POFILE=rmvolmgr_all.po
 POFILES=$(OBJS:%.o=%.po)
 
-LDLIBS +=	-ldbus-1 -ldbus-glib-1 -lglib-2.0 -lhal -lhal-storage -lcontract -lscf
+LDLIBS +=	-ldbus-1 -ldbus-glib-1 -lglib-2.0 -lhal -lhal-storage \
+		    -lcontract -lscf
+ADJUNCT_LIBS =	libdbus-1.so libdbus-glib-1.so libglib-2.0.so
 
 CPPFLAGS +=	$(HAL_DBUS_CPPFLAGS) $(HAL_GLIB_CPPFLAGS)
 CPPFLAGS +=	-I$(ROOT)/usr/include/hal
 CSTD =	$(CSTD_GNU99)
 
-CERRWARN += 	-_gcc=-Wno-switch
-CERRWARN += 	-_gcc=-Wno-uninitialized
-CERRWARN += 	-_gcc=-Wno-unused-variable
-CERRWARN += 	-_gcc=-Wno-parentheses
-CERRWARN += 	-_gcc=-Wno-unused-function
+CERRWARN +=	-_gcc=-Wno-switch
+CERRWARN +=	-_gcc=-Wno-uninitialized
+CERRWARN +=	-_gcc=-Wno-unused-variable
+CERRWARN +=	-_gcc=-Wno-parentheses
+CERRWARN +=	-_gcc=-Wno-unused-function
 
 ROOTCMDDIR =		$(ROOTLIB)
 ROOTMANIFESTDIR =	$(ROOTSVCSYSTEMFILESYSTEM)
--- old/usr/src/cmd/sendmail/src/Makefile	2018-09-19 23:19:43.040338995 +0000
+++ new/usr/src/cmd/sendmail/src/Makefile	2018-09-19 23:19:43.056430864 +0000
@@ -30,8 +30,8 @@
 
 PROG=	sendmail
 
-include 	../../Makefile.cmd
-include 	../Makefile.cmd
+include		../../Makefile.cmd
+include		../Makefile.cmd
 
 OBJS= alias.o arpadate.o bf.o collect.o conf.o control.o convtime.o daemon.o \
 	deliver.o domain.o envelope.o err.o headers.o macro.o main.o map.o \
@@ -44,9 +44,10 @@
 MAPFILES =	$(MAPFILE.INT) $(MAPFILE.NGB)
 LDFLAGS +=	$(MAPFILES:%=-M%)
 
-LDLIBS += 	../libsmutil/libsmutil.a ../libsm/libsm.a -lresolv -lsocket \
+LDLIBS +=	../libsmutil/libsmutil.a ../libsm/libsm.a -lresolv -lsocket \
 		-lnsl ../db/libdb.a -lldap -lsldap -lwrap -lumem \
 		-lssl -lcrypto -lsasl
+ADJUNCT_LIBS =	libssl.so libcrypto.so
 
 INCPATH=	-I. -I../include -I../db
 
@@ -55,9 +56,9 @@
 		-DSUN_INIT_DOMAIN -DSUN_SIMPLIFIED_LDAP -D_FFR_LOCAL_DAEMON \
 		-D_FFR_MAIL_MACRO
 
-CPPFLAGS = 	$(INCPATH) $(ENVDEF) $(SUNENVDEF) $(DBMDEF) $(CPPFLAGS.sm)
+CPPFLAGS =	$(INCPATH) $(ENVDEF) $(SUNENVDEF) $(DBMDEF) $(CPPFLAGS.sm)
 
-FILEMODE= 	2555
+FILEMODE=	2555
 
 ROOTSYMLINKS=	$(ROOTLIBSMTPSM)/newaliases
 
--- old/usr/src/cmd/sgs/elfdump/Makefile.com	2018-09-19 23:19:43.487917782 +0000
+++ new/usr/src/cmd/sgs/elfdump/Makefile.com	2018-09-19 23:19:43.506834730 +0000
@@ -30,8 +30,8 @@
 
 COMOBJ =	main.o			corenote.o \
 		dwarf.o			struct_layout.o \
-		struct_layout_i386.o 	struct_layout_amd64.o \
-		struct_layout_sparc.o 	struct_layout_sparcv9.o
+		struct_layout_i386.o	struct_layout_amd64.o \
+		struct_layout_sparc.o	struct_layout_sparcv9.o
 
 COMOBJ32 =	elfdump32.o fake_shdr32.o
 
@@ -55,6 +55,8 @@
 LDLIBS +=	$(ELFLIBDIR) -lelf $(LDDBGLIBDIR) $(LDDBG_LIB) \
 		    $(CONVLIBDIR) $(CONV_LIB)
 
+NATIVE_LDFLAGS = $(LDCHECKS) -Bdirect -zassert-deflib=libc.so
+
 LINTFLAGS +=	-x
 LINTFLAGS64 +=	-x
 
--- old/usr/src/cmd/sgs/ld/i386/Makefile	2018-09-19 23:19:43.950296741 +0000
+++ new/usr/src/cmd/sgs/ld/i386/Makefile	2018-09-19 23:19:43.970986473 +0000
@@ -20,13 +20,14 @@
 # CDDL HEADER END
 #
 #
-#ident	"%Z%%M%	%I%	%E% SMI"
-#
 # Copyright (c) 1996 by Sun Microsystems, Inc.
 # All rights reserved.
 
 include		../Makefile.com
 
+native :=	NATIVE_LIBS= libc.so
+native :=	LDFLAGS += -Bdirect
+
 .KEEP_STATE:
 
 include		../Makefile.targ
--- old/usr/src/cmd/sgs/link_audit/Makefile.com	2018-09-19 23:19:44.429857662 +0000
+++ new/usr/src/cmd/sgs/link_audit/Makefile.com	2018-09-19 23:19:44.446738130 +0000
@@ -49,7 +49,7 @@
 
 USRSCRIPTS=	sotruss whocalls
 CCSLIBS=	$(TRUSSLIB) $(WHOLIB)
- 
+
 PICDIR=		pics
 OBJDIR=		objs
 
@@ -87,6 +87,8 @@
 $(SYMBINDREP):=	MAPFILES = ../common/mapfile-vers-symbindrep
 $(BINDLIB):=	MAPFILES = ../common/mapfile-vers-bindings
 
+$(ONPROGS):=	LDFLAGS += -Bdirect
+
 $(ROOTCCSLIB) :=	DIRMODE =	755
 
 CPPFLAGS +=	-D_REENTRANT
--- old/usr/src/cmd/sgs/tools/Makefile.com	2018-09-19 23:19:44.899122322 +0000
+++ new/usr/src/cmd/sgs/tools/Makefile.com	2018-09-19 23:19:44.916751878 +0000
@@ -44,6 +44,8 @@
 NATOBJS=	piglatin.o
 
 OBJECTS=	$(COMOBJS)  $(NATOBJS)
+NATIVECC_CFLAGS = -O
+NATIVE_LDFLAGS = $(LDCHECKS) -zassert-deflib=libc.so -Bdirect
 
 AVLOBJ=		avl.o
 TOOL_OBJS=	sgsmsg.o string_table.o findprime.o assfail.o
--- old/usr/src/cmd/sgs/tools/Makefile.targ	2018-09-19 23:19:45.386179727 +0000
+++ new/usr/src/cmd/sgs/tools/Makefile.targ	2018-09-19 23:19:45.403157959 +0000
@@ -48,7 +48,7 @@
 		    $(VAR_AVLDIR)/avl.c
 
 piglatin:	../common/piglatin.c
-		$(NATIVECC) $(NATIVE_CFLAGS) -o $@ ../common/piglatin.c
+		$(NATIVECC) $(NATIVECC_CFLAGS) $(NATIVE_LDFLAGS) -o $@ ../common/piglatin.c
 
 %:		%.o
 		$(LINK.c) -o $@ $< $(LDLIBS)
--- old/usr/src/cmd/smbsrv/smbstat/Makefile	2018-09-19 23:19:45.847479208 +0000
+++ new/usr/src/cmd/smbsrv/smbstat/Makefile	2018-09-19 23:19:45.864821483 +0000
@@ -32,5 +32,6 @@
 include ../Makefile.smbsrv.defs
 
 LDLIBS += -lkstat -lm -lumem
+
 include ../Makefile.smbsrv.targ
 include ../../Makefile.targ
--- old/usr/src/cmd/spell/Makefile	2018-09-19 23:19:46.316980322 +0000
+++ new/usr/src/cmd/spell/Makefile	2018-09-19 23:19:46.333909743 +0000
@@ -74,17 +74,25 @@
 $(ROOTSPELLD)/hlista :=	FILEMODE =	0644
 $(ROOTVARADMF) :=	FILEMODE =	0666
 
+#
+# The native versions of these share targets with the target ones. Because of
+# that it is important that we override these variables. For example, LDLIBS
+# will add in the default LDLIBS.cmd which means that we'll link against the
+# wrong versions of libc.
+#
 spellin1 hashmk1 := CC = $(NATIVECC)
 spellin1 hashmk1 := POST_PROCESS =
 spellin1 hashmk1 := CPPFLAGS =
-spellin1 hashmk1 := LDFLAGS =
+spellin1 hashmk1 := LDFLAGS = -Bdirect
+spellin1 hashmk1 := NATIVE_LIBS = libc.so
+spellin1 hashmk1 := LDLIBS =
 
 $(ROOTSPELLD)/% $(ROOTVARADMD)/% : %
 	$(INS.file)
 
 .KEEP_STATE:
 
-all: 	$(PROG) $(TXTS)
+all:	$(PROG) $(TXTS)
 
 spellprog:		$(SPELLPROGOBJ)
 			$(LINK.c) $(SPELLPROGOBJ) -o $@ $(LDLIBS)
--- old/usr/src/cmd/svc/configd/Makefile	2018-09-19 23:19:46.762936092 +0000
+++ new/usr/src/cmd/svc/configd/Makefile	2018-09-19 23:19:46.778535064 +0000
@@ -80,7 +80,8 @@
 $(NATIVE_BUILD)CFLAGS =	$(NATIVE_CFLAGS)
 $(NATIVE_BUILD)CPPFLAGS = $(MYCPPFLAGS) -I$(LIBUUTIL)/common -I$(LIBSCF)/inc
 $(NATIVE_BUILD)CPPFLAGS += -DNATIVE_BUILD
-$(NATIVE_BUILD)LDFLAGS =
+$(NATIVE_BUILD)LDFLAGS += -Bdirect
+$(NATIVE_BUILD)NATIVE_LIBS = libumem.so libbsm.so libc.so
 $(NATIVE_BUILD)LDLIBS = -L$(ADJUNCT_PROTO)/usr/lib -R$(ADJUNCT_PROTO)/usr/lib \
 			-L$(LIBUUTIL)/native -R $(LIBUUTIL)/native $(MYLDLIBS)
 
--- old/usr/src/cmd/svc/svccfg/Makefile	2018-09-19 23:19:47.216111908 +0000
+++ new/usr/src/cmd/svc/svccfg/Makefile	2018-09-19 23:19:47.231309456 +0000
@@ -47,7 +47,7 @@
 		notify_params.o
 OBJS =		$(MYOBJS)
 
-POFILES = 	$(SRCS:%.c=%.po) \
+POFILES =	$(SRCS:%.c=%.po) \
 		svccfg_grammar.po \
 		svccfg_lex.po \
 		../common/manifest_find.po \
@@ -89,6 +89,7 @@
 
 SVCCFG_EXTRA_LIBS = -lxml2 -lscf -ll -luutil -lumem -lmd5 -lnvpair
 $(NOT_NATIVE)SVCCFG_EXTRA_LIBS += -ltecla
+$(NOT_NATIVE)ADJUNCT_LIBS += libxml2.so
 
 LIBSCF		= $(SRC)/lib/libscf
 LIBTECLA	= $(SRC)/lib/libtecla		# just for the header
@@ -110,7 +111,8 @@
 	-I$(LIBSCF)/inc \
 	-I$(LIBTECLA) \
 	-I$(LIBUUTIL)/common
-$(NATIVE_BUILD)LDFLAGS =
+$(NATIVE_BUILD)LDFLAGS =	-Bdirect
+$(NATIVE_BUILD)NATIVE_LIBS = libxml2.so libl.so libumem.so libmd5.so libnvpair.so libc.so
 $(NATIVE_BUILD)LDLIBS = \
 	-L$(LIBUUTIL)/native -R $(LIBUUTIL)/native \
 	-L$(LIBSCF)/native -R $(LIBSCF)/native \
--- old/usr/src/cmd/volcheck/Makefile	2018-09-19 23:19:47.631211963 +0000
+++ new/usr/src/cmd/volcheck/Makefile	2018-09-19 23:19:47.646866294 +0000
@@ -35,6 +35,7 @@
 include $(SRC)/cmd/hal/Makefile.hal
 
 LDLIBS +=	-ldbus-1 -ldbus-glib-1 -lglib-2.0 -lhal -lhal-storage -lcontract
+ADJUNCT_LIBS =	libdbus-1.so libdbus-glib-1.so libglib-2.0.so
 
 CPPFLAGS +=	$(HAL_DBUS_CPPFLAGS) $(HAL_GLIB_CPPFLAGS)
 CPPFLAGS +=	-I$(ROOT)/usr/include/hal
--- old/usr/src/cmd/volrmmount/Makefile	2018-09-19 23:19:48.035642072 +0000
+++ new/usr/src/cmd/volrmmount/Makefile	2018-09-19 23:19:48.050735531 +0000
@@ -35,6 +35,7 @@
 include $(SRC)/cmd/hal/Makefile.hal
 
 LDLIBS +=	-ldbus-1 -ldbus-glib-1 -lglib-2.0 -lhal -lhal-storage -lcontract
+ADJUNCT_LIBS =	libdbus-1.so libdbus-glib-1.so libglib-2.0.so
 
 CPPFLAGS +=	$(HAL_DBUS_CPPFLAGS) $(HAL_GLIB_CPPFLAGS)
 CPPFLAGS +=	-I$(ROOT)/usr/include/hal
--- old/usr/src/cmd/vt/Makefile	2018-09-19 23:19:48.445348583 +0000
+++ new/usr/src/cmd/vt/Makefile	2018-09-19 23:19:48.459045222 +0000
@@ -38,9 +38,10 @@
 vtdaemon := LDLIBS += -lpam -lbsm
 lint_vtdaemon := LDLIBS += -lpam -lbsm
 
+
 .KEEP_STATE:
 
-all: $(PROG) 
+all: $(PROG)
 
 vtdaemon: $(VTDAEMON_SRC)
 	$(LINK.c) -o $@ $(VTDAEMON_SRC) $(LDLIBS)
--- old/usr/src/cmd/ypcmd/Makefile	2018-09-19 23:19:48.841876757 +0000
+++ new/usr/src/cmd/ypcmd/Makefile	2018-09-19 23:19:48.857616047 +0000
@@ -60,6 +60,19 @@
 makedbm :=	MAPFILES = $(MAPFILE.INT) $(MAPFILE.NGB)
 makedbm :=	LDFLAGS += $(MAPFILES:%=-M%)
 
+# These things link with libnisdb, and thus are 'C++', but are otherwise
+# entirely C.  A result of this is they probably don't _actually_ use the C++
+# runtime, but may in future (depending on compiler implementation)
+#
+# Give up.
+ypxfr :=	ZGUIDANCE= -zguidance=nounused
+ypxfrd :=	ZGUIDANCE= -zguidance=nounused
+ypserv :=	ZGUIDANCE= -zguidance=nounused
+
+$(__SUNC)ypxfr :=	ADJUNCT_LIBS = libC.so
+$(__SUNC)ypxfrd :=	ADJUNCT_LIBS = libC.so
+$(__SUNC)ypserv :=	ADJUNCT_LIBS = libC.so
+
 $(ROOTVAR_YP)/aliases :=	FILEMODE=555
 
 YPFILES = Makefile aliases nicknames updaters
@@ -72,10 +85,10 @@
 
 YPBINDOBJ= yp_b_svc.o yp_b_subr.o rpc_bootstrap.o getlist.o
 #
-# Some sort of obsolete idea of common files which are only now used by a 
+# Some sort of obsolete idea of common files which are only now used by a
 # few minor utilities
 #
-COMMONOBJ= getlist.o yp_getalias.o 
+COMMONOBJ= getlist.o yp_getalias.o
 
 #
 # Objects shared between all the major components
@@ -127,19 +140,19 @@
 
 YPALLSRC =	$(YPALLOBJ:.o=.c)
 
-COMMONSRC = 	$(COMMONOBJ:.o=.c)
+COMMONSRC =	$(COMMONOBJ:.o=.c)
 
 #COMMONCLNTSRC =	$(COMMONCLNTOBJ:.o=.c)
 
 SRCS = $(BINSRC) $(SBINSRC) $(NETYPSRC) \
 	$(COMMONSRC) $(SHAREDSRC)
 
-CLEANFILES =	ypxfrd.h ypxfrd_xdr.c 
+CLEANFILES =	ypxfrd.h ypxfrd_xdr.c
 
 IBINPROG=		$(BINPROG:%=$(ROOTBIN)/%)
 ISBINPROG=		$(SBINPROG:%=$(ROOTUSRSBIN)/%)
 INETYPPROG=		$(NETYPPROG:%=$(NETYP)/%)
-INIS2LDAPPROG = 	$(NIS2LDAPPROG:%=$(NETYP)/%)
+INIS2LDAPPROG =		$(NIS2LDAPPROG:%=$(NETYP)/%)
 
 NIS2LDAPINC =		-I$(SRC)/lib/libnisdb/yptol
 
@@ -177,7 +190,7 @@
 lint:=		TARGET= lint
 cstyle :=	TARGET= cstyle
 
-all: $(SHAREDOBJ) $(SUBDIRS) $(PROG) $(TXTS) 
+all: $(SHAREDOBJ) $(SUBDIRS) $(PROG) $(TXTS)
 
 # install rules
 $(ROOTVAR_YP)/% \
--- old/usr/src/cmd/ypcmd/yppasswd/Makefile	2018-09-19 23:19:49.329920651 +0000
+++ new/usr/src/cmd/ypcmd/yppasswd/Makefile	2018-09-19 23:19:49.345896315 +0000
@@ -44,6 +44,15 @@
 MAPFILES =	$(MAPFILE.INT) $(MAPFILE.NGB)
 LDFLAGS +=	$(MAPFILES:%=-M%)
 
+# This links with libnisdb, and thus is 'C++', but is otherwise entirely C.  A
+# result of this is that it probably doesn't _actually_ use the C++ runtime, but
+# may in future (depending on compiler implementation)
+#
+# Give up.
+ZGUIDANCE= -zguidance=nounused
+
+$(__SUNC)ADJUNCT_LIBS =	libC.so
+
 # Pick up includes from library
 CPPFLAGS += -I$(SRC)/lib/libnisdb/yptol
 
@@ -65,7 +74,7 @@
 #
 SHAREDOBJ= ../shared/utils.o ../shared/lockmap.o ../shared/ancil.o
 
-OBJS = 			$(RPCYPPASSWDDOBJ) \
+OBJS =			$(RPCYPPASSWDDOBJ) \
 			$(COMMONOBJ)
 			# $(YPPWCONVOBJ) $(YPPASSMGMTOBJ)
 
--- old/usr/src/common/mapfiles/gen/Makefile	2018-09-19 23:19:49.809167465 +0000
+++ new/usr/src/common/mapfiles/gen/Makefile	2018-09-19 23:19:49.827934929 +0000
@@ -31,6 +31,9 @@
 		$(MACH)_cc_map.noexeglobs \
 		$(MACH)_gcc_map.noexeglobs
 
+NATIVE_LIBS =	libc.so
+LDFLAGS +=	-B direct
+
 $(BUILD64)FILES += \
 		$(MACH64)_cc_map.noexeglobs \
 		$(MACH64)_gcc_map.noexeglobs
@@ -78,7 +81,7 @@
 $(MACH)_gcc_map.noexeglobs :=	LINK =	$(LINK.c)
 $(MACH64)_gcc_map.noexeglobs :=	CC =	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
 $(MACH64)_gcc_map.noexeglobs :=	LINK =	$(LINK64.c)
- 
+
 # This generic target creates two dynamic executables from an empty "main"
 # program.  These objects are not executed, but are analyzed to determine the
 # global symbols each provides.
--- old/usr/src/lib/Makefile	2018-09-19 23:19:50.306518968 +0000
+++ new/usr/src/lib/Makefile	2018-09-19 23:19:50.323846013 +0000
@@ -569,7 +569,7 @@
 cfgadm_plugins:	libdevice libdevinfo libhotplug librcm hbaapi libkstat libscf
 fm:		libexacct libipmi libzfs scsi libdevinfo libdevid libcfgadm \
 		libcontract libsysevent ../cmd/sgs/libelf libdladm libsff \
-		libpcidb
+		libpcidb libdiskmgt
 $(SPARC_BLD)fm:	libpri
 gss_mechs/mech_dh: libgss
 gss_mechs/mech_dummy: libgss
--- old/usr/src/lib/libc/amd64/Makefile	2018-09-19 23:19:50.791272711 +0000
+++ new/usr/src/lib/libc/amd64/Makefile	2018-09-19 23:19:50.807894888 +0000
@@ -1259,10 +1259,11 @@
 # assym.h build rules
 
 GENASSYM_C = genassym.c
+LDFLAGS.native = $(LDCHECKS) -zassert-deflib=libc.so -Bdirect
 
 genassym: $(GENASSYM_C)
 	$(NATIVECC) $(NATIVE_CFLAGS) -Iinc -I$(LIBCDIR)/inc $(CPPFLAGS.native) \
-		-o $@ $(GENASSYM_C)
+		$(LDFLAGS.native) -o $@ $(GENASSYM_C)
 
 OFFSETS = $(LIBCDIR)/$(MACH)/offsets.in
 
--- old/usr/src/lib/libc/i386/Makefile.com	2018-09-19 23:19:51.291183440 +0000
+++ new/usr/src/lib/libc/i386/Makefile.com	2018-09-19 23:19:51.308018902 +0000
@@ -1340,10 +1340,12 @@
 # assym.h build rules
 
 GENASSYM_C = $(LIBCDIR)/$(MACH)/genassym.c
+LDFLAGS.native = $(LDCHECKS) -zassert-deflib=libc.so -Bdirect
 
 genassym: $(GENASSYM_C)
 	$(NATIVECC) $(NATIVE_CFLAGS) -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc	\
-		-D__EXTENSIONS__ $(CPPFLAGS.native) -o $@ $(GENASSYM_C)
+		-D__EXTENSIONS__ $(CPPFLAGS.native) $(LDFLAGS.native) \
+		-o $@ $(GENASSYM_C)
 
 OFFSETS = $(LIBCDIR)/$(MACH)/offsets.in
 
--- old/usr/src/lib/libc/sparc/Makefile.com	2018-09-19 23:19:51.828565121 +0000
+++ new/usr/src/lib/libc/sparc/Makefile.com	2018-09-19 23:19:51.850366550 +0000
@@ -1411,10 +1411,11 @@
 assym.h := CFLAGS += -g
 
 GENASSYM_C = $(LIBCDIR)/$(MACH)/genassym.c
+LDFLAGS.native = $(LDCHECKS) -zassert-deflib=libc.so -Bdirect
 
 genassym: $(GENASSYM_C)
 	$(NATIVECC) $(NATIVE_CFLAGS) -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc \
-		$(CPPFLAGS.native) -o $@ $(GENASSYM_C)
+		$(CPPFLAGS.native) $(LDFLAGS.native) -o $@ $(GENASSYM_C)
 
 OFFSETS = $(LIBCDIR)/$(MACH)/offsets.in
 
--- old/usr/src/lib/libc/sparcv9/Makefile.com	2018-09-19 23:19:52.375560294 +0000
+++ new/usr/src/lib/libc/sparcv9/Makefile.com	2018-09-19 23:19:52.393944814 +0000
@@ -1325,10 +1325,11 @@
 assym.h := CFLAGS64 += -g
 
 GENASSYM_C = $(LIBCDIR)/$(MACH)/genassym.c
+LDFLAGS.native = $(LDCHECKS) -zassert-deflib=libc.so -Bdirect
 
 genassym: $(GENASSYM_C)
 	$(NATIVECC) $(NATIVE_CFLAGS) -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc \
-		$(CPPFLAGS.native) -o $@ $(GENASSYM_C)
+		$(CPPFLAGS.native) $(LDFLAGS.native) -o $@ $(GENASSYM_C)
 
 OFFSETS = $(LIBCDIR)/$(MACH)/offsets.in
 
--- old/usr/src/lib/libfru/Makefile.flag	2018-09-19 23:19:52.874692235 +0000
+++ new/usr/src/lib/libfru/Makefile.flag	2018-09-19 23:19:52.891190205 +0000
@@ -35,12 +35,14 @@
 CPPFLAGS +=	-I../include -I$(SRC)/lib/libpicl
 CPPFLAGS +=	-I$(SRC)/lib/libfruutils
 CPPFLAGS +=	-I$(SRC)/cmd/picl/plugins/inc
-CPPFLAGS += 	-D_REENTRANT
+CPPFLAGS +=	-D_REENTRANT
 CFLAGS +=	$(CCVERBOSE)
-CCFLAGS64 += 	-mt
+CCFLAGS64 +=	-mt
 CCFLAGS +=	-mt
 LDLIBS +=	-lc
 
+$(__SUNC)ADJUNCT_LIBS =	libC.so
+
 CLEANFILES +=	pics/lex.fru.cc pics/y.tab.cc pics/y.tab.h
 
 $(LINTLIB) :=	SRCS = ../llib-lfru
--- old/usr/src/lib/libsqlite/Makefile.com	2018-09-19 23:19:53.353167544 +0000
+++ new/usr/src/lib/libsqlite/Makefile.com	2018-09-19 23:19:53.369717848 +0000
@@ -129,7 +129,7 @@
 	$(SRCDIR)/test1.c	\
 	$(SRCDIR)/test2.c	\
 	$(SRCDIR)/test3.c	\
-	$(SRCDIR)/md5.c	
+	$(SRCDIR)/md5.c
 
 TESTOBJS = $(TESTSRC:$(SRCDIR)/%.c=%.o)
 
@@ -148,7 +148,8 @@
 $(NATIVETARGETS) :=	LD = $(NATIVELD)
 $(NATIVETARGETS) :=	CFLAGS = $(NATIVE_CFLAGS)
 $(NATIVETARGETS) :=	CPPFLAGS = $(MYCPPFLAGS)
-$(NATIVETARGETS) :=	LDFLAGS =
+$(NATIVETARGETS) :=	LDFLAGS = -B direct
+$(NATIVETARGETS) :=	NATIVE_LIBS = libc.so
 $(NATIVETARGETS) :=	LDLIBS = -lc
 
 $(OBJS) :=		CFLAGS += $(CTF_FLAGS)
--- old/usr/src/lib/libxnet/common/llib-lxnet	2018-09-19 23:19:53.815189308 +0000
+++ new/usr/src/lib/libxnet/common/llib-lxnet	2018-09-19 23:19:53.831930534 +0000
@@ -24,8 +24,6 @@
  * All rights reserved.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 /* LINTLIBRARY */
 /* PROTOLIB1 */
 
@@ -42,3 +40,4 @@
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <netdb.h>
+#include <net/if.h>
--- old/usr/src/lib/policykit/Makefile.policykit	2018-09-19 23:19:54.273989763 +0000
+++ new/usr/src/lib/policykit/Makefile.policykit	2018-09-19 23:19:54.291263464 +0000
@@ -30,8 +30,10 @@
 POLICYKIT_DBUS_CPPFLAGS =	-DDBUS_API_SUBJECT_TO_CHANGE \
 				-I$(ADJUNCT_PROTO)/usr/include/dbus-1.0 \
 				-I$(ADJUNCT_PROTO)/usr/lib/dbus-1.0/include
-POLICYKIT_GLIB_CPPFLAGS = 	-I$(ADJUNCT_PROTO)/usr/include/glib-2.0 \
+POLICYKIT_GLIB_CPPFLAGS =	-I$(ADJUNCT_PROTO)/usr/include/glib-2.0 \
 				-I$(ADJUNCT_PROTO)/usr/lib/glib-2.0/include
 
 POLICYKIT_DBUS_LDLIBS =	-ldbus-1
+POLICYKIT_DBUS_EXTERNS = libdbus-1.so
 POLICYKIT_GLIB_LDLIBS =	-lglib-2.0
+POLICYKIT_GLIB_EXTERNS = libglib-2.0.so
--- old/usr/src/tools/Makefile.tools	2018-09-19 23:19:54.797631812 +0000
+++ new/usr/src/tools/Makefile.tools	2018-09-19 23:19:54.816679743 +0000
@@ -53,7 +53,9 @@
 ELFSIGN_O=		$(TRUE)
 LDLIBS=
 LDFLAGS=		$(MAPFILE.NES:%=-M%) $(MAPFILE.NED:%=-M%) \
-			    $(MAPFILE.PGA:%=-M%)
+			    $(MAPFILE.PGA:%=-M%) \
+			    -B direct
+NATIVE_LIBS=		libc.so
 
 ROOTONBLDPROG=		$(PROG:%=$(ROOTONBLDBIN)/%)
 ROOTONBLDMACHPROG=	$(PROG:%=$(ROOTONBLDBINMACH)/%)
--- old/usr/src/tools/btxld/Makefile	2018-09-19 23:19:55.288552463 +0000
+++ new/usr/src/tools/btxld/Makefile	2018-09-19 23:19:55.306158858 +0000
@@ -30,6 +30,8 @@
 CSTD=	$(CSTD_GNU99)
 CPPFLAGS +=	-I$(SRC)/uts/common -I$(COMMON_SRC)
 
+NATIVE_LIBS +=	libmd5.so
+
 $(ROOTONBLDMAN1ONBLDFILES)	:= FILEMODE=	644
 
 all: $(PROG) $(MAN1ONBLDFILES)
--- old/usr/src/tools/cscope-fast/Makefile	2018-09-19 23:19:55.753319030 +0000
+++ new/usr/src/tools/cscope-fast/Makefile	2018-09-19 23:19:55.770896585 +0000
@@ -27,7 +27,7 @@
 
 PROG= cscope-fast
 
-OBJS= 	main.o dir.o crossref.o scanner.o lookup.o command.o display.o \
+OBJS=	main.o dir.o crossref.o scanner.o lookup.o command.o display.o \
 	find.o edit.o exec.o help.o history.o input.o menu.o alloc.o \
 	cgrep.o compath.o invlib.o logdir.o \
 	mouse.o mygetenv.o mygetwd.o mypopen.o \
@@ -52,6 +52,7 @@
 
 CFLAGS +=	$(CCVERBOSE)
 LDLIBS +=	-lcurses -ll
+NATIVE_LIBS += libcurses.so libl.so
 
 .KEEP_STATE:
 
--- old/usr/src/tools/ctf/cvt/Makefile.com	2018-09-19 23:19:56.230848151 +0000
+++ new/usr/src/tools/ctf/cvt/Makefile.com	2018-09-19 23:19:56.247468990 +0000
@@ -78,6 +78,7 @@
 CPPFLAGS	+= -D_REENTRANT
 CFLAGS		+= $(CTF_FLAGS)
 LINTFLAGS	+= -mnux
+NATIVE_LIBS	+= libz.so libelf.so
 
 CERRWARN	+= -_gcc=-Wno-unused
 CERRWARN	+= -_gcc=-Wno-uninitialized
--- old/usr/src/tools/ctf/dump/Makefile.com	2018-09-19 23:19:56.695985001 +0000
+++ new/usr/src/tools/ctf/dump/Makefile.com	2018-09-19 23:19:56.712803599 +0000
@@ -38,6 +38,7 @@
 LINTFILES = $(SRCS:%.c=%.ln)
 
 CERRWARN += -_gcc=-Wno-uninitialized
+NATIVE_LIBS	+= libz.so libelf.so
 
 .NO_PARALLEL:
 .PARALLEL: $(OBJS) $(LINTFILES)
--- old/usr/src/tools/ctf/stabs/Makefile.com	2018-09-19 23:19:57.201874635 +0000
+++ new/usr/src/tools/ctf/stabs/Makefile.com	2018-09-19 23:19:57.219884058 +0000
@@ -39,6 +39,7 @@
 include ../../Makefile.ctf
 
 LDLIBS += -lctf
+NATIVE_LIBS += libctf.so
 
 OBJS = $(SRCS:%.c=%.o)
 LINTFILES = $(SRCS:%.c=%.ln)
--- old/usr/src/tools/cw/Makefile	2018-09-19 23:19:57.679185829 +0000
+++ new/usr/src/tools/cw/Makefile	2018-09-19 23:19:57.695536671 +0000
@@ -43,9 +43,12 @@
 $(__SUNC)CFLAGS=	-xspace -Xa  -xildoff -errtags=yes -errwarn=%all \
 			-xc99=%none    -W0,-xglobalstatic -v
 
-
 $(__GNUC)LDLIBS +=	-lc
-$(__GNUC)LDFLAGS= 	$(MAPFILE.NES:%=-Wl,-M%)
+$(__GNUC)LDFLAGS =	$(MAPFILE.NES:%=-Wl,-M%)
+$(__GNUC)ZASSERTDEFLIB = -Wl,-zassert-deflib
+$(__GNUC)ZFATALWARNINGS = -Wl,-zfatal-warnings
+$(__GNUC)ZGUIDANCE = -Wl,-zguidance
+LDFLAGS += -Wl,$(ZDIRECT)
 
 CPPFLAGS += -DDEFAULT_CC_DIR='"$(SPRO_VROOT)/bin"'
 CPPFLAGS += -DDEFAULT_GCC_DIR='"$(GNUC_ROOT)/bin"'
--- old/usr/src/tools/install.bin/Makefile	2018-09-19 23:19:58.151056074 +0000
+++ new/usr/src/tools/install.bin/Makefile	2018-09-19 23:19:58.167798235 +0000
@@ -34,6 +34,7 @@
 CERRWARN += -_gcc=-Wno-type-limits
 CPPFLAGS += -I../protocmp
 LDLIBS += -lgen
+NATIVE_LIBS += libgen.so
 CLEANFILES += $(OBJS)
 
 # Assume we don't have the install.bin available yet
--- old/usr/src/tools/make/bin/Makefile	2018-09-19 23:19:58.622441428 +0000
+++ new/usr/src/tools/make/bin/Makefile	2018-09-19 23:19:58.639234416 +0000
@@ -43,6 +43,8 @@
 ROOTLINKS = $(ROOTONBLDBINMACH)/dmake
 ROOTRULES = $(ROOTONBLDSHARE)/make.rules
 
+NATIVE_LIBS += libnsl.so libumem.so
+
 all:	$(PROG)
 
 install: all $(ROOTONBLDMACHPROG) $(ROOTLINKS) $(ROOTRULES)
--- old/usr/src/tools/makesoftcore/Makefile	2018-09-19 23:19:59.084650689 +0000
+++ new/usr/src/tools/makesoftcore/Makefile	2018-09-19 23:19:59.102346693 +0000
@@ -22,6 +22,7 @@
 OBJS=		makesoftcore.o lz4.o
 SRCS=		makesoftcore.c lz4.c
 LDLIBS=		-lumem
+NATIVE_LIBS +=	libumem.so
 
 .KEEP_STATE:
 
--- old/usr/src/tools/tic/Makefile	2018-09-19 23:19:59.548560528 +0000
+++ new/usr/src/tools/tic/Makefile	2018-09-19 23:19:59.565345911 +0000
@@ -32,6 +32,8 @@
 
 MAPFILES=	$(CMDDIR)/$(MAPFILE.INT)
 
+NATIVE_LIBS += libcurses.so
+
 .KEEP_STATE:
 
 all:		$(PROG)
--- old/usr/src/tools/vtfontcvt/Makefile	2018-09-19 23:20:00.013648378 +0000
+++ new/usr/src/tools/vtfontcvt/Makefile	2018-09-19 23:20:00.032769440 +0000
@@ -18,6 +18,8 @@
 include		../Makefile.tools
 include		$(CMDDIR)/Makefile.common
 
+NATIVE_LIBS += libumem.so
+
 .KEEP_STATE:
 
 all:		$(PROG)
--- old/usr/src/ucbcmd/Makefile.ucbcmd	2018-09-19 23:20:00.529596435 +0000
+++ new/usr/src/ucbcmd/Makefile.ucbcmd	2018-09-19 23:20:00.546139330 +0000
@@ -64,7 +64,8 @@
 
 LDFLAGS.cmd = \
 	$(ENVLDFLAGS1) $(ENVLDFLAGS2) $(ENVLDFLAGS3) \
-	$(MAPFILE.NES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%)
+	$(MAPFILE.NES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%) \
+	-Bdirect
 
 LDFLAGS =       $(LDFLAGS.cmd)
 
--- old/usr/src/uts/intel/ath/Makefile	2018-09-19 23:20:01.060510396 +0000
+++ new/usr/src/uts/intel/ath/Makefile	2018-09-19 23:20:01.080495253 +0000
@@ -98,12 +98,10 @@
 #	it yourself.
 #
 #	The amd64 version of this object has the .eh_frame section tagged
-#	as SHT_PROGBITS, while the ABI requires SHT_AMD64_UNWIND. The Solaris
-#	ld enforces this, so use elfedit to bring the object in line with
-#	this requirement.
+#	as SHT_PROGBITS. Historically ld did not support this and instead we
+#	used elfedit to transform it. The reason why we don't have the source to
+#	this and instead a uuencoded .o is all together another mystery.
 #
 ATHEROS_HAL=$(UTSBASE)/common/io/ath/hal_x86_$(CLASS).o.uu
 $(OBJS_DIR)/hal.o:     $(ATHEROS_HAL)
 	uudecode -o $@ $(ATHEROS_HAL)
-	if [ `elfedit -r -e 'ehdr:e_machine' $@` = EM_AMD64 ]; \
-		then elfedit -e 'shdr:sh_type .eh_frame SHT_AMD64_UNWIND' $@; fi
