From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22253 invoked by alias); 25 Jun 2018 13:12:12 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 22240 invoked by uid 89); 25 Jun 2018 13:12:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=mcmodel X-HELO: mout.kundenserver.de Received: from mout.kundenserver.de (HELO mout.kundenserver.de) (212.227.17.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 25 Jun 2018 13:12:02 +0000 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.183]) with ESMTPSA (Nemesis) id 0MFcKD-1fLbS61XJV-00Ebta; Mon, 25 Jun 2018 15:11:59 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id EC439A81974; Mon, 25 Jun 2018 15:11:58 +0200 (CEST) Date: Mon, 25 Jun 2018 18:33:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Cc: JonY <10walls@gmail.com>, Yaakov Selkowitz Subject: Re: linker error with gcc flag -mfunction-return=thunk Message-ID: <20180625131158.GB30295@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com, JonY <10walls@gmail.com>, Yaakov Selkowitz References: <67f4ac9a-5fe8-14d2-031f-288bbfccfc7a@ssi-schaefer.com> <20180625121613.GL28757@calimero.vinschen.de> <20180625124135.GA30295@calimero.vinschen.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6sX45UoQRIJXqkqR" Content-Disposition: inline In-Reply-To: <20180625124135.GA30295@calimero.vinschen.de> User-Agent: Mutt/1.9.2 (2017-12-15) X-SW-Source: 2018-06/txt/msg00278.txt.bz2 --6sX45UoQRIJXqkqR Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 4003 [Cc'ing JonY and Yaakov, just for pinging] On Jun 25 14:41, Corinna Vinschen wrote: > On Jun 25 14:16, Corinna Vinschen wrote: > > On Jun 25 14:08, Michael Haubenwallner wrote: > > > Hi, > > >=20 > > > I'm encountering a package's configure script (openssh-7.7p1) that > > > successfully tests for the compiler flag "-mfunction-return=3Dthunk", > > > which causes subsequent linker errors (and fails to identify zlib): > > > relocation truncated to fit: R_X86_64_32S against `.text' > > >=20 > > > The compiler used is gcc-7.3.0 with binutils-2.29.1.20171006 (current= ), > > > and the easiest test case here is: > > >=20 > > > $ echo 'int main() { return 0; }' > conftest.c > > > $ gcc -mfunction-return=3Dthunk conftest.c > > > /tmp/ccv1Ird0.o:conftest.c:(.text+0x1a): relocation truncated to fit:= R_X86_64_32S against `.text' > > > collect2: error: ld returned 1 exit status > > >=20 > > > Not sure though where to finally report this problem: > > > * openssh, as they should do a link-test rather than compile-test > > > * gcc, as their generated code is wrong for cygwin > > > * binutils, as their ld is unable to link that code > > > * cygwin, as the maintainers of cygwin support in binutils+gcc > > >=20 > > > After all, openssh-7.7p1-1.src cygwin package currently fails to comp= ile. > >=20 > > configure with --without-hardening for the time being. >=20 > First of all, I think this needs fixing in gcc/binutils. >=20 > However, interesting problem! I just tested this with your above > testcase and it failed, as expected. Then I tweaked the openssh > configure.ac file to use OSSH_CHECK_CFLAG_LINK rather than > OSSH_CHECK_CFLAG_COMPILE and to my surprise the link stage > succeeded! So I tried this again with the conftest.c file used > by the OpenSSH configure.ac and yes, it works! >=20 > $ cat > conftest.c < #include > #include > int main(int argc, char **argv) { > /* Some math to catch -ftrapv problems in the toolchain */ > int i =3D 123 * argc, j =3D 456 + argc, k =3D 789 - argc; > float l =3D i * 2.1; > double m =3D l / 0.5; > long long int n =3D argc * 12345LL, o =3D 12345LL * (long long int)= argc; > printf("%d %d %d %f %f %lld %lld\n", i, j, k, l, m, n, o); > exit(0); > } > EOF > $ gcc -o conftest.exe -ggdb -O2 -pipe -Wall -Werror=3Dformat-security -Wp= ,-D_FORTIFY_SOURCE=3D2 -fstack-protector-strong --param=3Dssp-buffer-size= =3D4 -fdebug-prefix-map=3D/cygwin/src/openssh/openssh-7.7p1/openssh-7.7p1-1= .x86_64/build=3D/usr/src/debug/openssh-7.7p1-1 -fdebug-prefix-map=3D/cygwin= /src/openssh/openssh-7.7p1/openssh-7.7p1-1.x86_64/src/openssh-7.7p1=3D/usr/= src/debug/openssh-7.7p1-1 -pipe -Wall -Wpointer-arith -Wuninitialized -Wsig= n-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -W= no-unused-result -fno-strict-aliasing -Werror -mfunction-return=3Dthunk con= ftest.c > $ >=20 > Yes, no error. The reason is that the code never returns due to calling > exit(0), rather than return 0. Given that exit is a noreturn function, > the thunking doesn't take place in the testcase. Worse, -mindirect-branch=3Dthunk appears to result in the same problem for more complex code, but works fine for the conftest testcase, even with exit(0) replace by return 0. There's the following info in the gcc manual: Note that '-mcmodel=3Dlarge' is incompatible with '-mindirect-branch=3Dthunk' nor '-mindirect-branch=3Dthunk-extern' since the thunk function may not be reachable in large code model. [...] Note that '-mcmodel=3Dlarge' is incompatible with '-mfunction-return=3Dthunk' nor '-mfunction-return=3Dthunk-extern' since the thunk function may not be reachable in large code model. Is it possible that the gcc devs forgot the -mcmodel=3Dmedium case which is used by Cygwin?!? Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --6sX45UoQRIJXqkqR Content-Type: application/pgp-signature; name="signature.asc" Content-length: 833 -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlsw6h4ACgkQ9TYGna5E T6BMEQ/7BgrJA/dhZ2hX2KABv1q+1RCHLquEcuiUQeJZAiOCxG8oBKBwrgm7ivhM zAL0F/wfBd3XvwbPxyoOuLrsvCTI9wnhtknXNJtE9JBTllycxgucU7ZzGDUU5diK w+UCc1caswPUYo5m06z01CWVnrZwMSA8RomkhjfD8LheR4cBBkOiXiyP81OxZzqV 75meEFGJPH0OmLP2ane/JzgakGUWtzsjAi0po0RNT+y4zmprbxL01d141P5Y3TUO VdlEwoNHN61nthTwZrlkshNT5tsLxwyGkvpyueI7n7ci3j1UAFo6FGkrtPIc0oeI WE9ueGZkBekVAZp5wQgvj91NhIkSJC4o7ZIcfd6D9Kj821XuoVYnE5gDZF/E2xH2 MZVf94JGQ2lD/EIl0wnVxXipQtRaTziD3K2lMS5MBsytI2brpS/+6cX/5lH8nKw2 exjmcR71lY9r9mmPlwbN1FpWMVFj02vAJF//VEWr6W/mD/Y8WnumTx5mSTSipRbQ 5rg1H2W5fltmNwdslckvSrcu9mEkr2Y9VFN27oViHCcSx4SKJ/9U2WMFx/yaXPCe tAO0ULX/HoGA68kqJKg+HUoZAZlVzJjJITgT9yYkBd+qj6IaP4N4JFk50VHYfmrq rLaW7ch8VYBXZ1oPTIasl3wKTZZCPdv1YdeOO12JYGyKafFr16g= =y3qd -----END PGP SIGNATURE----- --6sX45UoQRIJXqkqR--