[UBUNTU 23.04] S390: static-PIE programs segfaults if libc6-dev-s390x-cross package is installed
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ubuntu on IBM z Systems |
New
|
Undecided
|
Unassigned | ||
gcc-12 (Ubuntu) |
New
|
Undecided
|
Unassigned | ||
gcc-13 (Ubuntu) |
New
|
Undecided
|
Unassigned | ||
linux (Ubuntu) |
New
|
Undecided
|
Skipper Bug Screeners |
Bug Description
== by Stefan <email address hidden> ==
A simple helloworld program build and linked as static-PIE segfaults while startup in __libc_setup_tls:
$ gcc -c -fPIE -static-pie -o hello.o hello.c
$ gcc -o hello hello.o -static-pie
Note:
If only libc6-dev package is installed, all is fine.
If both libc6-dev and libc6-dev-
Linking with "-Wl,-v" dumps the used linker command and it shows the used startup-files:
/usr/lib/
/usr/s390x-
/usr/lib/
/usr/lib/
/usr/s390x-
Linking as static-PIE requires the rcrt1.o file, which is not available in libc6-dev-
This issue can be fixed by enabling static-PIE also in the libc6-dev-
commit "S390: Enable static PIE" (in glibc 2.36)
https:/
There is a configure check which do a link-test to ensure that a suitable binutils(ld) version is used. Afterwards static-PIE is automatically enabled. The required binutils-patches are first included in binutils 2.39.
According to the build log of package cross-toolchain
running configure fragment for sysdeps/
checking for s390-specific static PIE requirements... no
In this cross build, glibc is configured in order to first build the crt-startup-files, which are needed to complete the cross-gcc build. At this time, the sysroot does not contain the crt-files or libc.so itself. Thus the "linking" configure check is failing. After building the cross-gcc, glibc is build without re-configuring. Thus static-PIE is not enabled.
In glibc-upstream, this configure check is now adjusted and it allows checking binutils by version number:
commit "s390x: Fix static PIE condition for toolchain bootstrapping." (will be in glibc 2.39)
https:/
Perhaps you also have to pick the following commits by Sam James which adjusted the tests in between (both are in glibc 2.36):
- commit "s390: use $READELF"
https:/
- commit "s390: use LC_ALL=C for readelf call"
https:/
In addition to the static-PIE configure-checks, there are those other s390-specific configure-checks to determine which IFUNC-optimizations can be build and used as default. Those also fail for libc6-dev-
running configure fragment for sysdeps/s390
checking for __builtin_tbegin... yes
checking for S390 vector instruction support... no
configure: WARNING: Use binutils with vector-support in order to use optimized implementations.
checking for S390 vector support in gcc... no
checking for S390 arch13 zarch instruction support... no
checking for S390 z10 zarch instruction support as default... no
checking for S390 z196 zarch instruction support as default... no
checking for S390 z13 zarch instruction support as default... no
checking for S390 arch13 zarch instruction support as default... no
Those checks were also adjusted in glibc-upstream. Please also pick this commits:
commit "S390: Use compile-only instead of also link-tests in configure." (in glibc 2.38)
https:/
I've observed this issue on Ubuntu 23.04 with glibc 2.37 and binutils 2.40:
binutils/
libc6-dev-
libc6-dev/lunar,now 2.37-0ubuntu2 s390x [installed]
libc6-s390x-
libc6/lunar,now 2.37-0ubuntu2 s390x [installed]
I think Ubuntu 22.10 is already out of support and Ubuntu 22.04 has no support for static-PIE on s390x as using too old glibc 2.35 and binutils 2.38.
tags: | added: architecture-s39064 bugnameltc-203393 severity-medium targetmilestone-inin2304 |
Changed in ubuntu: | |
assignee: | nobody → Skipper Bug Screeners (skipper-screen-team) |
affects: | ubuntu → linux (Ubuntu) |
what is the rationale of having the libc6-dev- s390x-cross package installed on s390x?