diff --git a/BUILDING b/BUILDING index 6759d8ebd0e..ac637145b9d 100644 --- a/BUILDING +++ b/BUILDING @@ -396,6 +396,18 @@ CONFIGURATION Default: ``no'' + MKSTRIPSYM Can be set to ``yes'' or ``no''. Indicates whether all local + symbols should be stripped from shared libraries. If ``yes'', + strip all local symbols from shared libraries; the affect is + equivalent to -x option of ld(1). If ``no'', strip only + temporary local symbols; the affect is equivalent to -X + option of ld(1). Keeping non-temporary local symbols such as + static function names is useful on using DTrace for userland + libraries and getting a backtrace from a rump kernel loading + shared libraries. + + Default: ``yes'' + MKUNPRIVED Can be set to ``yes'' or ``no''. Indicates whether an unprivileged install will occur. The user, group, permissions, and file flags, will not be set on the installed diff --git a/doc/BUILDING.mdoc b/doc/BUILDING.mdoc index 40a811cde17..3d8fa35d698 100644 --- a/doc/BUILDING.mdoc +++ b/doc/BUILDING.mdoc @@ -33,7 +33,7 @@ .\" Toolchain prefix for commands .ds toolprefix nb . -.Dd February 20, 2017 +.Dd April 13, 2017 .Dt BUILDING 8 .Os NetBSD . @@ -697,6 +697,21 @@ Indicates whether RCS IDs, for use with should be stripped from program binaries and shared libraries. .DFLTn . +.It Sy MKSTRIPSYM +.YorN +Indicates whether all local symbols should be stripped from shared libraries. +If +.Dq yes , +strip all local symbols from shared libraries; +the affect is equivalent to -x option of ld(1). If +.Dq no , +strip only temporary local symbols; the affect is equivalent +to -X option of ld(1). Keeping non-temporary local symbols +such as static function names is useful on using DTrace for +userland libraries and getting a backtrace from a rump kernel +loading shared libraries. +.DFLTy +. .It Sy MKUNPRIVED .YorN Indicates whether an unprivileged install will occur. diff --git a/share/man/man5/mk.conf.5 b/share/man/man5/mk.conf.5 index a1f9c772c1c..5a58c93e978 100644 --- a/share/man/man5/mk.conf.5 +++ b/share/man/man5/mk.conf.5 @@ -783,6 +783,21 @@ Indicates whether RCS IDs, for use with should be stripped from program binaries and shared libraries. .DFLTn . +.It Sy MKSTRIPSYM +.YorN +Indicates whether all local symbols should be stripped from shared libraries. +If +.Dq yes , +strip all local symbols from shared libraries; +the affect is equivalent to -x option of ld(1). If +.Dq no , +strip only temporary local symbols; the affect is equivalent +to -X option of ld(1). Keeping non-temporary local symbols +such as static function names is useful on using DTrace for +userland libraries and getting a backtrace from a rump kernel +loading shared libraries. +.DFLTy +. .It Sy MKUNPRIVED .YorN Indicates whether an unprivileged install will occur. diff --git a/share/mk/bsd.README b/share/mk/bsd.README index e2c40b08d32..ca10157b920 100644 --- a/share/mk/bsd.README +++ b/share/mk/bsd.README @@ -409,6 +409,15 @@ MKSTATICLIB If "no", don't build or install the normal static (*.a) libraries. Default: yes +MKSTRIPSYM If "yes", strip all local symbols from shared libraries; + the affect is equivalent to -x option of ld(1). If "no", + strip only temporary local symbols; the affect is equivalent + to -X option of ld(1). Keeping non-temporary local symbols + such as static function names is useful on using DTrace for + userland libraries and getting a backtrace from a rump kernel + loading shared libraries. + Default: yes + MKTOOLSDEBUG If "yes" build the tools with debugging symbols. Default: no diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index b657c7b9eea..869dbd8eba6 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -577,6 +577,11 @@ _LIBLDOPTS+= -Wl,-rpath,${SHLIBDIR} \ _LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR} \ -L=${SHLIBINSTALLDIR} .endif +.if ${MKSTRIPSYM:Uyes} == "yes" +_LIBLDOPTS+= -Wl,-x +.else +_LIBLDOPTS+= -Wl,-X +.endif # gcc -shared now adds -lc automatically. For libraries other than libc and # libgcc* we add as a dependency the installed shared libc. For libc and @@ -635,7 +640,7 @@ ${_LIB.so.full}: ${_MAINLIBDEPS} .endif ${_MKTARGET_BUILD} rm -f ${.TARGET} - ${LIBCC} ${LDLIBC} -Wl,-x -shared ${SHLIB_SHFLAGS} \ + ${LIBCC} ${LDLIBC} -shared ${SHLIB_SHFLAGS} \ ${_LDFLAGS.${_LIB}} -o ${.TARGET} ${_LIBLDOPTS} \ -Wl,--whole-archive ${SOLIB} \ -Wl,--no-whole-archive ${_LDADD.${_LIB}} diff --git a/share/mk/bsd.lua.mk b/share/mk/bsd.lua.mk index 3b790099885..06ce4057412 100644 --- a/share/mk/bsd.lua.mk +++ b/share/mk/bsd.lua.mk @@ -128,6 +128,13 @@ CLEANFILES+=${LUA_OBJS.${_M}} ${LUA_LOBJ.${_M}} ${LUA_TARG.${_M}} DPSRCS+=${LUA_SRCS.${_M}} SRCS+=${LUA_SRCS.${_M}} +LUA_LDOPTS= -Wl,--warn-shared-textrel +.if ${MKSTRIPSYM:Uyes} == "yes" +LUA_LDOPTS+= -Wl,-x +.else +LUA_LDOPTS+= -Wl,-X +.endif + .NOPATH: ${LUA_OBJS.${_M}} ${LUA_LOBJ.${_M}} ${LUA_TARG.${_M}} .if ${MKLINT} != "no" ${LUA_TARG.${_M}}: ${LUA_LOBJ.${_M}} @@ -137,8 +144,7 @@ lua-all: ${LUA_TARG.${_M}} ${LUA_TARG.${_M}}: ${LUA_OBJS.${_M}} ${DPADD} ${DPADD.${_M}} ${_MKTARGET_BUILD} rm -f ${.TARGET} - ${CC} -Wl,--warn-shared-textrel \ - -Wl,-x -shared ${LUA_OBJS.${_M}} \ + ${CC} ${LUA_LDOPTS} -shared ${LUA_OBJS.${_M}} \ -Wl,-soname,${LUA_NAME.${_M}} -o ${.TARGET} \ ${LDADD} ${LDADD.${_M}} ${LDFLAGS} ${LDFLAGS.${_M}} diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index 35c11f569ca..23830d2cfa6 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -308,6 +308,11 @@ OBJCOPYLIBFLAGS_EXTRA=-w -K '[$$][dx]' -K '[$$][dx]\.*' # ARM big endian needs to preserve $a/$d/$t symbols for the linker. OBJCOPYLIBFLAGS_EXTRA=-w -K '[$$][adt]' -K '[$$][adt]\.*' .endif + +.if ${MKSTRIPSYM:Uyes} == "yes" OBJCOPYLIBFLAGS?=${"${.TARGET:M*.po}" != "":?-X:-x} ${OBJCOPYLIBFLAGS_EXTRA} +.else +OBJCOPYLIBFLAGS?=-X ${OBJCOPYLIBFLAGS_EXTRA} +.endif .endif # !defined(_BSD_SYS_MK_)