From 858ed9bfe38682274cfa58948c79d4854abd80c4 Mon Sep 17 00:00:00 2001 From: Rainer Orth Date: Fri, 22 Aug 2025 11:04:51 +0200 Subject: [PATCH] ld: testsuite: Only xfail "shared (non PIC)" etc. on 64-bit Solaris Once the ld-shared tests run on both Solaris/SPARC and x86, two tests XPASS on 32-bit Solaris, both SPARC and x86 (pre-existing on SPARC, newly revealed on x86): XPASS: shared (non PIC) XPASS: shared (PIC main, non PIC so) Consequently, this patch restricts xfailing them to 64-bit Solaris. There now remain 1 (32-bit) or 3 (64-bit) XFAILs. I've checked the reasons and found all comments in shared.exp are wrong: * The common one (SPARC and x86, 32 and 64-bit) is XFAIL: shared (non PIC, load offset) The error is always the same: ld.so.1: shnp: fatal: tmpdir/shnp.so: unknown file type Running shnp under truss reveals 26170: openat(AT_FDCWD, "tmpdir/shnp.so", O_RDONLY) = 3 26170: mmapobj(3, MMOBJ_INTERPRET, 0xFFFFFFFF7F5D0058, 0xFFFFFFFF7FFFE8A0, 0x00000000) Err#48 ENOTSUP which can be traced in the mmapobj(2) implementation to the requirement that a shared object's p_vaddr needs to be 0, which in this test is intentionally not the case. * The other two XFAIL's are 64-bit only and for another reason: XFAIL: shared (non PIC) XFAIL: shared (PIC main, non PIC so) On sparcv9, shnp execution fails: ld.so.1: shnp: fatal: relocation error: R_SPARC_H44: file tmpdir/shnp.so: symbol shlibvar2: value 0x3fffffffb9c does not fit On amd64, shmpnp.so fails to link: ld/tmpdir/ld/collect-ld: tmpdir/sh1np.o: relocation R_X86_64_32S against symbol `shlib_shlibvar1' can not be used when making a shared object; recompile with -fPIC ld/tmpdir/ld/collect-ld: failed to set dynamic section sizes: bad value In both cases, this happens with -z text, too, so the comments are bogus. Instead, the issue that the code needs to be PIC. So I'm updating the comments accordingly. Tested on sparc{v9,}-sun-solaris2.11 and {amd64,i386}-pc-solaris2.11. 2025-07-30 Rainer Orth ld: * testsuite/ld-shared/shared.exp (shared (non PIC)): Update comment. xfail on 64-bit Solaris only. (shared (PIC main, non PIC so)): Likewise. (shared (non PIC, load offset)): Update comment. --- ld/ChangeLog | 7 +++++++ ld/testsuite/ld-shared/shared.exp | 12 +++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 1cb8e89079c..175aea6a7a6 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,10 @@ +2025-08-22 Rainer Orth + + * testsuite/ld-shared/shared.exp (shared (non PIC)): Update + comment. xfail on 64-bit Solaris only. + (shared (PIC main, non PIC so)): Likewise. + (shared (non PIC, load offset)): Update comment. + 2025-08-22 Rainer Orth * testsuite/ld-shared/shared.exp: Enable on *-*-solaris2* rather diff --git a/ld/testsuite/ld-shared/shared.exp b/ld/testsuite/ld-shared/shared.exp index 6aa7ca937e2..c67084c0cf6 100644 --- a/ld/testsuite/ld-shared/shared.exp +++ b/ld/testsuite/ld-shared/shared.exp @@ -230,8 +230,9 @@ if ![ld_compile "$CC_FOR_TARGET $NOPIE_CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $ } else { if { [is_xcoff_format] } { shared_test shnp "shared (non PIC)" mainnp.o sh1np.o sh2np.o xcoff "" $NOPIE_LDFLAGS } else { - # Solaris defaults to -z text. - setup_xfail "*-*-solaris2*" + # 64-bit Solaris requires PIC. + setup_xfail "sparcv9*-*-solaris2*" + setup_xfail "x86_64-*-solaris2*" setup_xfail "ia64-*-linux*" setup_xfail "alpha*-*-linux*" setup_xfail "powerpc-*-linux-musl" @@ -277,7 +278,7 @@ if ![ld_compile "$CC_FOR_TARGET $NOPIE_CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $ setup_xfail "arm*-*-linux*" } setup_xfail "aarch64*-*-linux*" - # Solaris defaults to -z text. + # Solaris refuses to map shared objects with non-zero load addresses. setup_xfail "*-*-solaris2*" shared_test shnp "shared (non PIC, load offset)" \ mainnp.o sh1np.o sh2np.o shared \ @@ -312,8 +313,9 @@ if ![ld_compile "$CC_FOR_TARGET $SHCFLAG $picflag" $srcdir/$subdir/main.c $tmpdi if { [is_xcoff_format] } { shared_test shmpnp "shared (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o xcoff "" $NOPIE_LDFLAGS } else { - # Solaris defaults to -z text. - setup_xfail "*-*-solaris2*" + # 64-bit Solaris requires PIC. + setup_xfail "sparcv9*-*-solaris2*" + setup_xfail "x86_64-*-solaris2*" setup_xfail "ia64-*-linux*" setup_xfail "alpha*-*-linux*" setup_xfail "powerpc-*-linux-musl" -- 2.47.2