Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Sep 2010 11:46:51 +0200
From:      Jeremie Le Hen <jeremie@le-hen.org>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        kan@freebsd.org, freebsd-hackers@freebsd.org, Jeremie Le Hen <jeremie@le-hen.org>
Subject:   Re: [PATCH] Add -lssp_nonshared to GCC's LIB_SPEC unconditionally
Message-ID:  <20100927094651.GB57265@felucia.tataz.chchile.org>
In-Reply-To: <20100920192708.GK2389@deviant.kiev.zoral.com.ua>
References:  <20100803150545.GH14016@felucia.tataz.chchile.org> <20100803114651.651e0ea4@kan.dnsalias.net> <20100805191446.GJ14016@felucia.tataz.chchile.org> <20100919081406.GH6864@felucia.tataz.chchile.org> <20100919184146.GE2389@deviant.kiev.zoral.com.ua> <20100920162925.GL6864@felucia.tataz.chchile.org> <20100920192708.GK2389@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

--h31gzZEtNLTqOjlF
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi Kostik,

On Mon, Sep 20, 2010 at 10:27:08PM +0300, Kostik Belousov wrote:
> 
> You make the script only useful for the stack protection. If build process
> does not use libc.so script, but installed system does, you
> - require to maintain two places where (not much) hypothetical libc
>   changes should go;
> - make it very puzzling to debug the issues with the build of the usermode.
> 
> Please, do this in the consistent manner, so that the script can be adopted
> for other uses.

I've updated the patch.  I think it will fulfill your requirements.  Now
the ld script is generated on the fly during the install step.

The patch probably needs some polishing such as removing debugging
leftovers.  Can you tell me if it looks of for you now?

Regards,
-- 
Jeremie Le Hen

Humans are born free and equal.  But some are more equal than others.
					    Coluche

--h31gzZEtNLTqOjlF
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="ld_ssp_nonshared.diff"

diff -urNp src.orig/lib/libc/Makefile src/lib/libc/Makefile
--- src.orig/lib/libc/Makefile	2010-08-01 12:35:01.000000000 +0000
+++ src/lib/libc/Makefile	2010-09-21 23:40:51.000000000 +0000
@@ -20,6 +20,7 @@ CFLAGS+=-DNLS
 CLEANFILES+=tags
 INSTALL_PIC_ARCHIVE=
 PRECIOUSLIB=
+SHLIB_LDSCRIPT=libc.ldscript
 
 #
 # Only link with static libgcc.a (no libgcc_eh.a).
diff -urNp src.orig/lib/libc/libc.ldscript src/lib/libc/libc.ldscript
--- src.orig/lib/libc/libc.ldscript	1970-01-01 00:00:00.000000000 +0000
+++ src/lib/libc/libc.ldscript	2010-09-24 21:56:57.000000000 +0000
@@ -0,0 +1,2 @@
+/* $FreeBSD */
+GROUP ( @@SHLIB@@ /usr/lib/libssp_nonshared.a )
diff -urNp src.orig/share/mk/bsd.lib.mk src/share/mk/bsd.lib.mk
--- src.orig/share/mk/bsd.lib.mk	2010-07-30 15:25:57.000000000 +0000
+++ src/share/mk/bsd.lib.mk	2010-09-24 22:01:04.000000000 +0000
@@ -293,9 +293,19 @@ _libinstall:
 	    ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
 	    ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}
 .if defined(SHLIB_LINK)
+.if defined(SHLIB_LDSCRIPT) && !empty(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT})
+	@echo "DEBUG: install lib${LIB}.ld to ${DESTDIR}${LIBDIR}/${SHLIB_LINK}"
+	sed -e 's,@@SHLIB@@,${SHLIBDIR}/${SHLIB_NAME},g' \
+	    ${.CURDIR}/${SHLIB_LDSCRIPT} > lib${LIB}.ld
+	${INSTALL} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+	    ${_INSTALLFLAGS} lib${LIB}.ld ${DESTDIR}${LIBDIR}
+	ln -sf lib${LIB}.ld ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
+.else
 .if ${SHLIBDIR} == ${LIBDIR}
+	@echo "DEBUG: symlink (1) ${DESTDIR}${LIBDIR}/${SHLIB_LINK} to ${SHLIB_NAME}"
 	ln -fs ${SHLIB_NAME} ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
 .else
+	@echo "DEBUG: symlink (2) ${DESTDIR}${LIBDIR}/${SHLIB_LINK} to ${_SHLIBDIRPREFIX}${SHLIBDIR}/${SHLIB_NAME}"
 	ln -fs ${_SHLIBDIRPREFIX}${SHLIBDIR}/${SHLIB_NAME} \
 	    ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
 .if exists(${DESTDIR}${LIBDIR}/${SHLIB_NAME})
@@ -303,8 +313,9 @@ _libinstall:
 	rm -f ${DESTDIR}${LIBDIR}/${SHLIB_NAME}
 .endif
 .endif
-.endif
-.endif
+.endif # SHLIB_LDSCRIPT
+.endif # SHLIB_LINK
+.endif # SHIB_NAME
 .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
 	${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
 	    ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
@@ -372,6 +383,9 @@ clean:
 .endif
 .if defined(SHLIB_NAME)
 .if defined(SHLIB_LINK)
+.if defined(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT})
+	rm -f lib${LIB}.ld
+.endif
 	rm -f ${SHLIB_LINK}
 .endif
 .if defined(LIB) && !empty(LIB)

--h31gzZEtNLTqOjlF--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100927094651.GB57265>