Mail Archives: cygwin/2018/06/25/08:41:57
--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 -