[v2,2/2] s390: Skip non-PIC shared library visibility linker tests
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_binutils_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_binutils_check--master-arm |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 |
success
|
Test passed
|
Commit Message
Some of the "visibility" linker tests that use a non-PIC shared library
with load offset (first load segment has a non-zero virtual address)
XPASS on s390 64-bit (s390x):
PASS: visibility (hidden) (non PIC, load offset)
XFAIL: visibility (hidden_normal) (non PIC, load offset)
PASS: visibility (hidden_undef) (non PIC, load offset)
PASS: visibility (hidden_undef_def) (non PIC, load offset)
XPASS: visibility (hidden_weak) (non PIC, load offset)
XPASS: visibility (protected) (non PIC, load offset)
PASS: visibility (protected_undef) (non PIC, load offset)
XPASS: visibility (protected_undef_def) (non PIC, load offset)
XPASS: visibility (protected_weak) (non PIC, load offset)
XFAIL: visibility (normal) (non PIC, load offset)
This is due to Alan Modra's commit 125c64931b97 from 2006, which moved
overriddenvar, shlib_overriddencall2, and shared_data from sh1.c to
sh2.c, if the shared library is build non-PIC. This prevents GCC from
treating them as local symbols, preventing the executable from
overriding them, causing the tests to fail because interposition did
not work.
This actually only became visible due to H.J. Lu's commit fd7728c8a4aa
("ld: Update function prototypes for compilers defaulting to -std=gnu23")
from 2025, that fixed the visibility test's function prototypes.
Previously all of the "visibility" tests would appear as UNSUPPORTED, as
the prerequisite compile of main.c would fail due to the function
prototypes not matching with their definitions.
In general creating shared libraries from non-PIC compiled code is not
supported on s390 64-bit (s390x). This is because shared libraries are
inherently position independent. The Glibc dynamic loader common code
passes the virtual address from the first load segment as hint to
mmap(). As a result a shared library with "load offset" may be loaded
at the virtual address used at link-time, but this is not guaranteed.
The following visibility tests using a non-PIC shared library with
load offset XPASS, if the non-PIC shared library is loaded at its link-
time "load offset". This causes the tests to PASS by chance.
XPASS: visibility (hidden_weak) (non PIC, load offset)
XPASS: visibility (protected) (non PIC, load offset)
XPASS: visibility (protected_undef_def) (non PIC, load offset)
XPASS: visibility (protected_weak) (non PIC, load offset)
The following visibility tests using a non-PIC shared library with
load offset still XFAIL:
XFAIL: visibility (hidden_normal) (non PIC, load offset)
XFAIL: visibility (normal) (non PIC, load offset)
This is because visibility_var is local in sh1.c, preventing the
executable from overriding it, causing the tests to fail because
interposition does not work.
Note that all of the visibility tests using a non-PIC shared library
without load offset XFAIL, as they are loaded at a random address, which
is incompatible with non-PIC code.
Skip all non-PIC shared library "visibility" linker tests on s390 64-bit
(s390x) as unsupported. In contrast to PowerPC and MIPS do not skip
all of the "visibility" linker tests.
ld/testsuite/
* ld-vsb/vsb.exp: Skip non-PIC shared library "visibility" tests
on s390 64-bit (s390x).
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
Notes (jremus):
Changes in v2:
- Skip non-PIC shared library "visibility" linker tests on s390 64-bit
(s390x), as these is not supported. (Alan)
- Reword commit subject and message accordingly.
ld/testsuite/ld-vsb/vsb.exp | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
@@ -297,6 +297,18 @@ proc visibility_run {visibility} {
unsupported "visibility ($visibility) (non PIC, load offset)"
unsupported "visibility ($visibility)"
} else {
+ # Non-PIC shared libraries are not supported on s390 64-bit (s390x).
+ # When compiling without -fpic or -fPIC, GCC will assume quite
+ # reasonably that it is not compiling for a shared library. It
+ # can then make optimisations that result in shared library
+ # functions and variables not being overridable or reachable.
+ # N.B.: Skipping the non-PIC shared library tests (non-PIC main)
+ # here will also cause skipping of likewise tests (PIC main)
+ # further down below.
+ if { [istarget s390x-*-linux*] } {
+ unsupported "visibility ($visibility) (non PIC)"
+ unsupported "visibility ($visibility) (non PIC, load offset)"
+ } else {
# The shared library is composed of two files. First compile them
# without using -fpic. That should work on an ELF system,
# although it will be less efficient because the dynamic linker
@@ -406,7 +418,7 @@ proc visibility_run {visibility} {
mainnp.o sh1np.o sh2np.o $datfile \
"-Wl,-T,$srcdir/$subdir/elf-offset.ld,--hash-style=sysv" $NOPIE_LDFLAGS
}
- }
+ }}
# Now compile the code using -fpic.