GNU bug report logs - #15793
Bug: linking shared libraries on Cygwin results in undefined references to __stack_chck_guard for code compiled with -fstack-protector

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: libtool; Reported by: Richard PALO <richard.palo@HIDDEN>; dated Sat, 2 Nov 2013 23:16:01 UTC; Maintainer for libtool is bug-libtool@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 24 Sep 2015 16:46:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 24 12:46:04 2015
Received: from localhost ([127.0.0.1]:42010 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Zf9el-0005rI-NI
	for submit <at> debbugs.gnu.org; Thu, 24 Sep 2015 12:46:04 -0400
Received: from eggs.gnu.org ([208.118.235.92]:53802)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <richard@HIDDEN>) id 1Zf6OA-0000o7-PQ
 for submit <at> debbugs.gnu.org; Thu, 24 Sep 2015 09:16:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <richard@HIDDEN>) id 1Zf6O9-0003p0-Im
 for submit <at> debbugs.gnu.org; Thu, 24 Sep 2015 09:16:42 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled
 version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:44775)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <richard@HIDDEN>) id 1Zf6O9-0003ot-GP
 for submit <at> debbugs.gnu.org; Thu, 24 Sep 2015 09:16:41 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:35551)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <richard@HIDDEN>) id 1Zf6O8-0000hm-6e
 for bug-libtool@HIDDEN; Thu, 24 Sep 2015 09:16:41 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <richard@HIDDEN>) id 1Zf6O4-0003mU-0a
 for bug-libtool@HIDDEN; Thu, 24 Sep 2015 09:16:40 -0400
Received: from smtp2-g21.free.fr ([2a01:e0c:1:1599::11]:58568)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <richard@HIDDEN>)
 id 1Zf6O3-0003kG-QT; Thu, 24 Sep 2015 09:16:35 -0400
Received: from [192.168.0.6] (unknown [78.228.114.66])
 (Authenticated sender: richard.palo)
 by smtp2-g21.free.fr (Postfix) with ESMTPSA id D72564B0089;
 Thu, 24 Sep 2015 15:16:29 +0200 (CEST)
Message-ID: <5603F78D.4060202@HIDDEN>
Date: Thu, 24 Sep 2015 15:15:57 +0200
From: Richard PALO <richard@HIDDEN>
User-Agent: Mozilla/5.0 (X11; SunOS i86pc;
 rv:) Gecko/20100101 Thunderbird/24.8.1
MIME-Version: 1.0
Newsgroups: gmane.comp.gnu.libtool.patches,gmane.comp.gnu.libtool.bugs
To: libtool-patches@HIDDEN
Subject: Re: Bug: linking shared libraries on Cygwin results in undefined
 references to __stack_chck_guard for code compiled with -fstack-protector
References: <AANLkTimBUMzojnf9RAqAowJGGG_B8c8o-R5Aq9bjWvYs@HIDDEN>	<20100601222415.23d4ea46@YAAKOV04>
 <l53v9v$gjn$1@HIDDEN>
In-Reply-To: <l53v9v$gjn$1@HIDDEN>
Content-Type: multipart/mixed; boundary="------------010200060800090705000308"
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Thu, 24 Sep 2015 12:46:01 -0400
Cc: bug-libtool@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

This is a multi-part message in MIME format.
--------------010200060800090705000308
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Le 02/11/13 23:45, Richard PALO a =C3=A9crit :
> Le 02/06/10 05:24, Yaakov (Cygwin/X) a =C3=A9crit :
>> On Sat, 15 May 2010 09:07:49 +0200
>> Bart Van Assche <bvanassche@HIDDEN> wrote:
>>> This behavior has been observed with libtool version 2.2.6.
>>
>> Bug confirmed.  When code is compiled with -fstack-protector{,-all},
>> GCC "emits extra code to check for buffer overflows, such as stack
>> smashing attacks".  This extra code uses symbols from libssp, and
>> therefore (at least) Cygwin's GCC specs contain:
>>
>> *link_ssp:
>> %{fstack-protector|fstack-protector-all:-lssp_nonshared -lssp}
>>
>> Therefore, when libtool fails to pass -fstack-protector{,-all} at link
>> stage, the link fails.
>>
>> Patch attached.  (Yes, I have a copyright assignment on file.)
>>
>>
>> Yaakov
>> Cygwin/X
>>
>=20
> I've done some limited testing of this patch on a SunOS distro with=20
> pkgsrc, and it certainly helps a number of cases since it is gcc that=20
> generates the necessary '-lssp_nonshared -lssp' libs for linking (at=20
> least in absence of '-nostdlib').
>=20
> Please include in the upcoming version.
>=20
>=20
>=20
>=20

I'd like to propose a slight modification this which, in addition, seems =
to get over the
issue (at least on solaris) of c++ shared libraries linking '-nostdlib'. =
=20

This could easily be adapted for other hosts using g++. Note, it is harml=
ess if '-dumpspecs'
or no spec with fstack-protector* is available.

It appears there was no warm welcome in tossing the '-nostdlib' setup for=
 g++ shared libraries=20
for solaris, so this seems to be a reasonable workaround.

--=20
Richard PALO


--------------010200060800090705000308
Content-Type: text/x-patch;
 name="0001-workaround-for-nostdlib-with-fstack-protector-on-sol.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0001-workaround-for-nostdlib-with-fstack-protector-on-sol.pa";
 filename*1="tch"

From 5dfcf84c8243441f30a3c852791b8d46bc4d2c53 Mon Sep 17 00:00:00 2001
From: Richard PALO <richard@HIDDEN>
Date: Thu, 24 Sep 2015 13:23:56 +0200
Subject: [PATCH] workaround for -nostdlib with -fstack-protector on solaris

---
 build-aux/ltmain.in | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index 0c40da0..7a6356b 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -5364,8 +5364,7 @@ func_mode_link ()
       # -stdlib=*            select c++ std lib with clang
       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
-      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
-      -specs=*)
+      -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-stdlib=*|-specs=*)
         func_quote_for_eval "$arg"
 	arg=$func_quote_for_eval_result
         func_append compile_command " $arg"
@@ -5374,6 +5373,25 @@ func_mode_link ()
         continue
         ;;
 
+      -fstack-protector*)
+        func_quote_for_eval "$arg"
+        arg=$func_quote_for_eval_result
+        func_append compile_command " $arg"
+        func_append finalize_command " $arg"
+        func_append compiler_flags " $arg"
+
+        # Explicitly add solaris ssp libs to postdeps to counter
+        # linking with g++ -nostdlib when supplied -fstack-protector*
+        test CXX = "$tagname" && {
+          case $host_os in
+          solaris*)
+            func_append postdeps " `$compile_command -dumpspecs 2>/dev/null | $SED -n '/fstack-protector/{s/^.*://;s/}$//;p;}'`"
+            ;;
+          esac
+        }
+        continue
+        ;;
+
       -Z*)
         if test os2 = "`expr $host : '.*\(os2\)'`"; then
           # OS/2 uses -Zxxx to specify OS/2-specific options
-- 
2.5.2


--------------010200060800090705000308--




Information forwarded to bug-libtool@HIDDEN:
bug#15793; Package libtool. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 2 Nov 2013 23:15:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 02 19:15:32 2013
Received: from localhost ([127.0.0.1]:60140 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1VckPj-00029J-Qq
	for submit <at> debbugs.gnu.org; Sat, 02 Nov 2013 19:15:32 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48166)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <gnu-bug-libtool@HIDDEN>) id 1Vck6O-0001e9-Co
 for submit <at> debbugs.gnu.org; Sat, 02 Nov 2013 18:55:33 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <gnu-bug-libtool@HIDDEN>) id 1Vck6C-0003Py-Fr
 for submit <at> debbugs.gnu.org; Sat, 02 Nov 2013 18:55:26 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:49486)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <gnu-bug-libtool@HIDDEN>) id 1Vck6C-0003Pu-CM
 for submit <at> debbugs.gnu.org; Sat, 02 Nov 2013 18:55:20 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:49870)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <gnu-bug-libtool@HIDDEN>) id 1Vck66-0008Jp-Ei
 for bug-libtool@HIDDEN; Sat, 02 Nov 2013 18:55:20 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <gnu-bug-libtool@HIDDEN>) id 1Vck5x-0003L6-O8
 for bug-libtool@HIDDEN; Sat, 02 Nov 2013 18:55:14 -0400
Received: from plane.gmane.org ([80.91.229.3]:37513)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <gnu-bug-libtool@HIDDEN>) id 1Vck5x-0003GE-Hs
 for bug-libtool@HIDDEN; Sat, 02 Nov 2013 18:55:05 -0400
Received: from list by plane.gmane.org with local (Exim 4.69)
 (envelope-from <gnu-bug-libtool@HIDDEN>) id 1Vck5v-0005TY-2I
 for bug-libtool@HIDDEN; Sat, 02 Nov 2013 23:55:03 +0100
Received: from pig83-1-78-228-114-66.fbx.proxad.net ([78.228.114.66])
 by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
 id 1AlnuQ-0007hv-00
 for <bug-libtool@HIDDEN>; Sat, 02 Nov 2013 23:55:03 +0100
Received: from richard.palo by pig83-1-78-228-114-66.fbx.proxad.net with local
 (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00
 for <bug-libtool@HIDDEN>; Sat, 02 Nov 2013 23:55:03 +0100
X-Injected-Via-Gmane: http://gmane.org/
To: bug-libtool@HIDDEN
From: Richard PALO <richard.palo@HIDDEN>
Subject: Re: Bug: linking shared libraries on Cygwin results in undefined
 references to __stack_chck_guard for code compiled with -fstack-protector
Date: Sat, 02 Nov 2013 23:45:29 +0100
Lines: 30
Message-ID: <l53v9v$gjn$1@HIDDEN>
References: <AANLkTimBUMzojnf9RAqAowJGGG_B8c8o-R5Aq9bjWvYs@HIDDEN>
 <20100601222415.23d4ea46@YAAKOV04>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
X-Complaints-To: usenet@HIDDEN
X-Gmane-NNTP-Posting-Host: pig83-1-78-228-114-66.fbx.proxad.net
User-Agent: Mozilla/5.0 (X11; SunOS i86pc;
 rv:24.0) Gecko/20100101 Thunderbird/24.0.1
In-Reply-To: <20100601222415.23d4ea46@YAAKOV04>
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.1 (----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Sat, 02 Nov 2013 19:15:30 -0400
Cc: libtool-patches@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.1 (----)

Le 02/06/10 05:24, Yaakov (Cygwin/X) a écrit :
> On Sat, 15 May 2010 09:07:49 +0200
> Bart Van Assche <bvanassche@HIDDEN> wrote:
>> This behavior has been observed with libtool version 2.2.6.
>
> Bug confirmed.  When code is compiled with -fstack-protector{,-all},
> GCC "emits extra code to check for buffer overflows, such as stack
> smashing attacks".  This extra code uses symbols from libssp, and
> therefore (at least) Cygwin's GCC specs contain:
>
> *link_ssp:
> %{fstack-protector|fstack-protector-all:-lssp_nonshared -lssp}
>
> Therefore, when libtool fails to pass -fstack-protector{,-all} at link
> stage, the link fails.
>
> Patch attached.  (Yes, I have a copyright assignment on file.)
>
>
> Yaakov
> Cygwin/X
>

I've done some limited testing of this patch on a SunOS distro with 
pkgsrc, and it certainly helps a number of cases since it is gcc that 
generates the necessary '-lssp_nonshared -lssp' libs for linking (at 
least in absence of '-nostdlib').

Please include in the upcoming version.






Acknowledgement sent to Richard PALO <richard.palo@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-libtool@HIDDEN. Full text available.
Report forwarded to bug-libtool@HIDDEN:
bug#15793; Package libtool. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.