delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/06/25/08:41:57

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=E4bUncsIXvvAtzhRb4Kn5zT66wKm9ObZ4o7SWl4ekR/j4MNXGTOZG
n/9BZfQZVJkfGTVQ2nrqcubr3VumCi7O0lys7iCE3hgdSXKPDnUzFwPOe3qNGZLJ
yM38xOolLoWceEWw/Vxqgts8kmh6DxbHua2FGmd+JWi9+k42T/FpwM=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=Aa2fALG3ym3FxxtCfigYKYQluKQ=; b=diWeX4XWDDu9VH+2Dujd0Tb34fHO
yfDuRaQ+QyPKwkzgiVe2Lfsq2Tgxe/iWY8hctXybJ8kt3qDCnXGwuexZs234unGE
iDGOg7p4MoQmbft8/h/0gavefFFqJteMcQJV2b4vwarRlPvIwLsVXchOcLJ19A8i
FT6fRAjg3pQYieE=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
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
Date: Mon, 25 Jun 2018 14:41:35 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: linker error with gcc flag -mfunction-return=thunk
Message-ID: <20180625124135.GA30295@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <67f4ac9a-5fe8-14d2-031f-288bbfccfc7a AT ssi-schaefer DOT com> <20180625121613 DOT GL28757 AT calimero DOT vinschen DOT de>
MIME-Version: 1.0
In-Reply-To: <20180625121613.GL28757@calimero.vinschen.de>
User-Agent: Mutt/1.9.2 (2017-12-15)

--lrZ03NoBR/3+SXJZ
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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 <<EOF
#include <stdlib.h>
#include <stdio.h>
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"

-----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--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019