From owner-freebsd-hackers@FreeBSD.ORG Tue Aug 3 15:22:00 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 00628106566C; Tue, 3 Aug 2010 15:21:59 +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 162EE8FC08; Tue, 3 Aug 2010 15:21:57 +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 CBAC6CA8F17; Tue, 3 Aug 2010 17:05:55 +0200 (CEST) Received: from endor.tataz.chchile.org (unknown [82.233.239.98]) by smtp5-g21.free.fr (Postfix) with ESMTP id 4AD0AD480F0; Tue, 3 Aug 2010 17:05:47 +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 35CA233F19; Tue, 3 Aug 2010 15:05:46 +0000 (UTC) Received: by felucia.tataz.chchile.org (Postfix, from userid 1000) id 251D8A10F5; Tue, 3 Aug 2010 15:05:46 +0000 (UTC) Date: Tue, 3 Aug 2010 17:05:46 +0200 From: Jeremie Le Hen To: freebsd-hackers@FreeBSD.org Message-ID: <20100803150545.GH14016@felucia.tataz.chchile.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Cc: kan@FreeBSD.org Subject: 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:22:00 -0000 Hi, 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: 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' Since world is now compiled by default with -fstack-protector, this may happen to everyone naively compiling a source file like above. 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. Index: freebsd-spec.h =================================================================== 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 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. Thank you. Regards, -- Jeremie Le Hen Humans are born free and equal. But some are more equal than others. Coluche