[PATCH 1/1] s390: Un-XFAIL some non-PIC load offset ELF visibility tests
Jens Remus
jremus@linux.ibm.com
Fri Mar 13 15:11:19 GMT 2026
Some of the ELF visibility 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 ELF 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 ELF 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. Un-XFAIL
them.
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 ELF 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 ELF 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.
ld/testsuite/
* ld-vsb/vsb.exp: Un-XFAIL some non-PIC load offset ELF
visibility tests on s390 64-bit (s390x).
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
ld/testsuite/ld-vsb/vsb.exp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/ld/testsuite/ld-vsb/vsb.exp b/ld/testsuite/ld-vsb/vsb.exp
index 03bfd1b241fa..b48e6353eb07 100644
--- a/ld/testsuite/ld-vsb/vsb.exp
+++ b/ld/testsuite/ld-vsb/vsb.exp
@@ -370,11 +370,14 @@ proc visibility_run {visibility} {
|| [ string match $visibility "protected_weak" ]
|| [ string match $visibility "normal" ] } {
setup_xfail "powerpc-*-linux*"
- setup_xfail "s390x-*-linux*"
if { [istarget sparc*-*-linux*] && [is_elf64 $tmpdir/mainnp.o] } {
setup_xfail "sparc*-*-linux*"
}
}
+ if { [ string match $visibility "hidden_normal" ]
+ || [ string match $visibility "normal" ] } {
+ setup_xfail "s390x-*-linux*"
+ }
if { ![ string match $visibility "hidden_undef" ]
&& ![ string match $visibility "protected_undef" ] } {
setup_xfail "ia64-*-linux*"
--
2.51.0
More information about the Binutils
mailing list