From owner-freebsd-hackers@FreeBSD.ORG Sun Sep 19 08:32:53 2010 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 05A0C106566B; Sun, 19 Sep 2010 08:32:53 +0000 (UTC) (envelope-from jeremie@le-hen.org) Received: from smtpfb2-g21.free.fr (smtpfb2-g21.free.fr [212.27.42.10]) by mx1.freebsd.org (Postfix) with ESMTP id A7B3E8FC12; Sun, 19 Sep 2010 08:32:49 +0000 (UTC) Received: from smtp5-g21.free.fr (smtp5-g21.free.fr [212.27.42.5]) by smtpfb2-g21.free.fr (Postfix) with ESMTP id 5C499D1AA9A; Sun, 19 Sep 2010 10:14:17 +0200 (CEST) Received: from endor.tataz.chchile.org (unknown [82.233.239.98]) by smtp5-g21.free.fr (Postfix) with ESMTP id 37946D4808E; Sun, 19 Sep 2010 10:14:08 +0200 (CEST) Received: from felucia.tataz.chchile.org (felucia.tataz.chchile.org [192.168.1.9]) by endor.tataz.chchile.org (Postfix) with ESMTP id C480533D77; Sun, 19 Sep 2010 08:14:06 +0000 (UTC) Received: by felucia.tataz.chchile.org (Postfix, from userid 1000) id B19B5A1247; Sun, 19 Sep 2010 08:14:06 +0000 (UTC) Date: Sun, 19 Sep 2010 10:14:06 +0200 From: Jeremie Le Hen To: Alexander Kabaev Message-ID: <20100919081406.GH6864@felucia.tataz.chchile.org> References: <20100803150545.GH14016@felucia.tataz.chchile.org> <20100803114651.651e0ea4@kan.dnsalias.net> <20100805191446.GJ14016@felucia.tataz.chchile.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="qD3brAgIG4LbUq6d" Content-Disposition: inline In-Reply-To: <20100805191446.GJ14016@felucia.tataz.chchile.org> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: kan@FreeBSD.org, freebsd-hackers@FreeBSD.org, Jeremie Le Hen Subject: Re: [PATCH] Add -lssp_nonshared to GCC's LIB_SPEC unconditionally X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Sep 2010 08:32:53 -0000 --qD3brAgIG4LbUq6d Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Alexander, On Thu, Aug 05, 2010 at 09:14:46PM +0200, Jeremie Le Hen wrote: > On Tue, Aug 03, 2010 at 11:46:51AM -0400, Alexander Kabaev wrote: > > > > I have no objection, but think we should cave in and investigate the > > possibility of using linker script wrapping libc.so in FreeBSD-9.0: > > > > Below is Linux' counterpart: > > > > /* GNU ld script > > Use the shared library, but some functions are only in > > the static library, so try that secondarily. */ > > OUTPUT_FORMAT(elf32-i386) > > GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED > > ( /lib/ld-linux.so.2 ) ) > > Ok. For now can you commit the proposed modification. I'll try to make > a patch with your proposal. The attached patch does two things: It modifies bsd.lib.mk to support ld scripts for shared libraries and adds such a script to replace the /usr/lib/libc.so symlink to /lib/libc.so.X. Basically, SHLIB_LDSCRIPT is defined in lib/libc/Makefile and points to the file containing the script itself: GROUP ( @@SHLIB@@ /usr/lib/libssp_nonshared.a ) During make install, @@SHLIB@@ will be replaced by the real path of the shared library. Thanks. Regards, -- Jeremie Le Hen Humans are born free and equal. But some are more equal than others. Coluche --qD3brAgIG4LbUq6d Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="ld_ssp_nonshared.diff" diff -urNp src.orig/Makefile.inc1 src/Makefile.inc1 --- src.orig/Makefile.inc1 2010-07-15 13:21:25.000000000 +0000 +++ src/Makefile.inc1 2010-08-19 17:27:30.000000000 +0000 @@ -256,6 +256,7 @@ WMAKEENV= ${CROSSENV} \ _SHLIBDIRPREFIX=${WORLDTMP} \ VERSION="${VERSION}" \ INSTALL="sh ${.CURDIR}/tools/install.sh" \ + NO_LDSCRIPT_INSTALL=1 \ PATH=${TMPPATH} .if ${MK_CDDL} == "no" WMAKEENV+= NO_CTF=1 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-08-11 17:36:15.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-08-09 11:12:13.000000000 +0000 @@ -0,0 +1 @@ +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-08-22 13:00:15.000000000 +0000 @@ -216,6 +216,14 @@ ${SHLIB_NAME}: ${SOBJS} @[ -z "${CTFMERGE}" -o -n "${NO_CTF}" ] || \ (${ECHO} ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS} && \ ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}) + +.if defined(SHLIB_LINK) && defined(SHLIB_LDSCRIPT) && !empty(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT}) +_LIBS+= lib${LIB}.ld + +lib${LIB}.ld: ${.CURDIR}/${SHLIB_LDSCRIPT} + sed 's,@@SHLIB@@,${SHLIBDIR}/${SHLIB_NAME},g' \ + ${.CURDIR}/${SHLIB_LDSCRIPT} > lib${LIB}.ld +.endif .endif .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no" @@ -293,9 +301,17 @@ _libinstall: ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \ ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR} .if defined(SHLIB_LINK) +.if defined(SHLIB_LDSCRIPT) && !empty(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT}) && empty(NO_LDSCRIPT_INSTALL) + @echo "DEBUG: install lib${LIB}.ld to ${DESTDIR}${LIBDIR}/${SHLIB_LINK}" + ${INSTALL} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${_INSTALLFLAGS} lib${LIB}.ld ${DESTDIR}${LIBDIR} + ln -fs 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 +319,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 +389,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) --qD3brAgIG4LbUq6d--