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
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)
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to