From owner-freebsd-hackers@FreeBSD.ORG Tue Aug 3 15:47:01 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 72371106566B; Tue, 3 Aug 2010 15:47:01 +0000 (UTC) (envelope-from kabaev@gmail.com) Received: from mail-qy0-f182.google.com (mail-qy0-f182.google.com [209.85.216.182]) by mx1.freebsd.org (Postfix) with ESMTP id 0A1638FC12; Tue, 3 Aug 2010 15:47:00 +0000 (UTC) Received: by qyk32 with SMTP id 32so3498415qyk.13 for ; Tue, 03 Aug 2010 08:47:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type; bh=Xgi9bS3xSwUTjlrVj1xjhbvAGXoC3WYyZB3c/s4P6Ks=; b=v7TJBWL9s5qKfIfUTmMoLY7Bgp3q7xsrAyEaew6QYkdHW8pJFPmlWAbt8YZumjvMb9 nY7NDov0nOCW56jcKvOu5gP+hOzh453wvWVOSOwKqDiiMshKXeswIYOXewqt9Zfe9dap 7kzVeBkwArfVSMbTHXqtwg0Nl2X2hsHvoe5XE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type; b=M3vzms+PAlFZm+kUIOkYl7AlXDotBRGeNmrNw43R/+tjevUEWLo/SmHn41GAz2OMU0 FF721+5VfvNFCZ7J44MQE6IvNpMcRjfsHncV7HMaQ8kqNlM67+M09hIsz1BcNUZEWkpL nX9Af/mYgToZUcUBIGcXQTXwfI6pWISx8NR94= Received: by 10.224.29.16 with SMTP id o16mr2665808qac.294.1280850419895; Tue, 03 Aug 2010 08:46:59 -0700 (PDT) Received: from kan.dnsalias.net (c-24-63-226-98.hsd1.ma.comcast.net [24.63.226.98]) by mx.google.com with ESMTPS id r1sm1595523qcq.10.2010.08.03.08.46.57 (version=SSLv3 cipher=RC4-MD5); Tue, 03 Aug 2010 08:46:58 -0700 (PDT) Date: Tue, 3 Aug 2010 11:46:51 -0400 From: Alexander Kabaev To: Jeremie Le Hen Message-ID: <20100803114651.651e0ea4@kan.dnsalias.net> In-Reply-To: <20100803150545.GH14016@felucia.tataz.chchile.org> References: <20100803150545.GH14016@felucia.tataz.chchile.org> X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; amd64-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/0t_hMcEHU0cI.CHRt8b+CRZ"; protocol="application/pgp-signature" Cc: kan@FreeBSD.org, freebsd-hackers@FreeBSD.org Subject: Re: 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: Tue, 03 Aug 2010 15:47:01 -0000 --Sig_/0t_hMcEHU0cI.CHRt8b+CRZ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Tue, 3 Aug 2010 17:05:46 +0200 Jeremie Le Hen wrote: > Hi, >=20 > Currenty, -lssp_nonshared is appended at the link stage only when > -fstack-protector is used on the gcc command-line. The problem I > would like to fix is a library (static or shared) compiled with > -fstack-protector being linked in without using the same flag: >=20 > mygeeto# cc -I /usr/local/include -L /usr/local/lib -lintl > conftest.c /usr/local/lib/libintl.so: undefined reference to > `__stack_chk_fail_local' >=20 > Since world is now compiled by default with -fstack-protector, this > may happen to everyone naively compiling a source file like above. >=20 > I therefore propose the following change to always link in > libssp_nonshared.a. I think this change is harmless when the symbol > is not needed in one of the objects linked together since the linker > won't pull in the library member "ssp-local.o" in the target object. >=20 > Index: freebsd-spec.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS > file: /data/repos/freebsd-cvsroot/src/contrib/gcc/config/freebsd-spec.h,v > retrieving revision 1.26.2.2 diff -u -r1.26.2.2 freebsd-spec.h > --- freebsd-spec.h 27 Dec 2009 20:39:58 -0000 1.26.2.2 > +++ freebsd-spec.h 3 Aug 2010 10:18:08 -0000 > @@ -168,7 +168,7 @@ > %{pg: %{pthread:-lpthread_p} > -lc_p}} \ > %{shared: > \ %{pthread:-lpthread} -lc} \ > - > %{fstack-protector|fstack-protector-all:-lssp_nonshared} \ > + > -lssp_nonshared > \ " #endif > #endif >=20 >=20 > This change is also important because I've submitted a PR (138228) to > compile ports with SSP. Of course many of them (although relatively > few) break. If we eventually want this feature to reach the ports > tree, it is necessary to fix as much problems as possible. I've > already provided a few patches in the PR, but sometimes it is > exaggeratedly difficult to fix the problem. For instance, > devel/p5-Locale-gettext tests the existence of libintl.so with a > naively compiled source file which doesn't link because of this > error. The easiest way after the one proposed above would be to > apply a patch conditionnaly. >=20 > Thank you. > Regards, > --=20 > Jeremie Le Hen >=20 > Coluche 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 ) ) --=20 Alexander Kabaev --Sig_/0t_hMcEHU0cI.CHRt8b+CRZ Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (FreeBSD) iD8DBQFMWDnwQ6z1jMm+XZYRAttCAJ4ukd9FnlO98RZ4tqlNSTvRQnMcVACgoof4 Xo6xjP6GIF/cfSacFtOxx4o= =X8/a -----END PGP SIGNATURE----- --Sig_/0t_hMcEHU0cI.CHRt8b+CRZ--