Date: Sun, 19 Sep 2010 10:14:06 +0200 From: Jeremie Le Hen <jeremie@le-hen.org> To: Alexander Kabaev <kabaev@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: <20100919081406.GH6864@felucia.tataz.chchile.org> In-Reply-To: <20100805191446.GJ14016@felucia.tataz.chchile.org> References: <20100803150545.GH14016@felucia.tataz.chchile.org> <20100803114651.651e0ea4@kan.dnsalias.net> <20100805191446.GJ14016@felucia.tataz.chchile.org>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
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
[-- Attachment #2 --]
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)
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100919081406.GH6864>
