From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 38941 invoked by alias); 25 Jun 2018 12:41:46 -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 38928 invoked by uid 89); 25 Jun 2018 12:41:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-101.3 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=0.5 X-HELO: mout.kundenserver.de Received: from mout.kundenserver.de (HELO mout.kundenserver.de) (217.72.192.75) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 25 Jun 2018 12:41:39 +0000 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.183]) with ESMTPSA (Nemesis) id 0LZvrB-1g1FGP1L9p-00llde for ; Mon, 25 Jun 2018 14:41:36 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id 2F6ABA81974; Mon, 25 Jun 2018 14:41:35 +0200 (CEST) Date: Mon, 25 Jun 2018 14:25:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: linker error with gcc flag -mfunction-return=thunk Message-ID: <20180625124135.GA30295@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <67f4ac9a-5fe8-14d2-031f-288bbfccfc7a@ssi-schaefer.com> <20180625121613.GL28757@calimero.vinschen.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lrZ03NoBR/3+SXJZ" Content-Disposition: inline In-Reply-To: <20180625121613.GL28757@calimero.vinschen.de> User-Agent: Mutt/1.9.2 (2017-12-15) X-SW-Source: 2018-06/txt/msg00277.txt.bz2 --lrZ03NoBR/3+SXJZ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 3162 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 compil= e. >=20 > configure with --without-hardening for the time being. First of all, I think this needs fixing in gcc/binutils. 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! $ cat > conftest.c < #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)ar= gc; 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 -Wsign-co= mpare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-u= nused-result -fno-strict-aliasing -Werror -mfunction-return=3Dthunk conftes= t.c $ 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. I check with OpenSSH upstream if this cqan be fixed from their side as well somehow. Thanks, Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --lrZ03NoBR/3+SXJZ Content-Type: application/pgp-signature; name="signature.asc" Content-length: 833 -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlsw4v4ACgkQ9TYGna5E T6DcQg/8DdNWecTj+QV9qW+nQTTKa99V55v+XmClJMnkUJ9opcjNinL2HkPApX5N ZKsNypezH4N8TTxxemabEjpa71SC7LiYZwXyzHSf9F8Ft0BLe02s37PjzRUa1BrJ L4I8CtJkB3AkGjC4xp/RuaO0Jgho36RO+4Tqz4+QPNMEvOe+G7IqsIA1upqg3dr9 sJA7i2yxhBBM/7sjTv6mW70zYHA91AZpsCmA0OLSZEQ8PXibdaikKf/5kJMKHfnv mnRlzeeuLDyIFX1WIJAYB++H56UsBJuGnIUaYDf4Uyf0yvveMOgMMzeAu9+inibc GkYAaqsxAFLEEcRjhHTFSVF0F6VBnrn6B7nySE5Vv4SOr8hTh8GztK5R9ZmoF8ev HWtajRjSyslL7kEh4zBOaWqBO0uEqar7i5d+K56W5juMgUzIH9KeFmxL+hYlSuvF bLu7+efnOWkMI0wWFib/yue7RJzh+5evlfNUsbjK+9rQB4BgT2B/NgpXUfkEBlPg rxELt+s05mIii74EMKxHUz5DZUR4kcxeaLd8YOWNXXsdtwsdmnib0GsHRP6uKH9A pUP2AOt0JtX0EPWff4rdpf3tfSAnXrfgoOzsa+wkCWN8HN57RLLiVuVvaAv25ndc /WZtxFFRE2pf1O7Js7tFJ+ZMG2NEE4iBNVnW7zwis4214JqsfCw= =wYUI -----END PGP SIGNATURE----- --lrZ03NoBR/3+SXJZ--