On Solaris 11 OpenIndiana, I see this test failure:
FAIL: test-sd-dlopen.sh ======================= test-sd-dlopen.sh: failed test: .note.dlopen section is missing FAIL test-sd-dlopen.sh (exit status: 1) The problem here is that I have disabled the asm instructions on Solaris, due to the linker error mentioned in [1], but the unit test is not in sync with that. Looking into this linker error more in detail, it is caused by the section flag 'R'. But this section flag is optional. Therefore the better fix for Solaris is to just not use the section flag 'R'. With that change, the unit test passes also on Solaris OpenIndiana. [1] https://lists.gnu.org/archive/html/bug-gnulib/2026-07/msg00142.html 2026-08-31 Bruno Haible <[email protected]> sd-dlopen: Fix test failure on Solaris 11 OpenIndiana. * m4/sd-dlopen.m4 (gl_SD_DLOPEN): On Solaris, avoid the section flag R, even if the assembler supports it. * lib/sd-dlopen.h: Reenable the asm macros on Solaris. diff --git a/lib/sd-dlopen.h b/lib/sd-dlopen.h index 57b7554754..b3e36ccd77 100644 --- a/lib/sd-dlopen.h +++ b/lib/sd-dlopen.h @@ -52,8 +52,7 @@ extern "C" { #define SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED "suggested" #if defined __ELF__ && (defined __GNUC__ || defined __clang__) \ - && defined HAVE_ASM_IFNDEF_ENDIF_BALIGN && HAVE_ASM_IFNDEF_ENDIF_BALIGN \ - && !defined __sun /* Avoid linker error "wrong ELF OSABI: ELFOSABI_GNU" */ + && defined HAVE_ASM_IFNDEF_ENDIF_BALIGN && HAVE_ASM_IFNDEF_ENDIF_BALIGN /* The "R" (SHF_GNU_RETAIN) flag is only understood by binutils >= 2.36, so it can be disabled by defining * _SD_ELF_NOTE_DLOPEN_SECTION_FLAGS as 'aG' manually, but note that if --gc-sections is used when linking, diff --git a/m4/sd-dlopen.m4 b/m4/sd-dlopen.m4 index d9214b08bb..1b84836cb2 100644 --- a/m4/sd-dlopen.m4 +++ b/m4/sd-dlopen.m4 @@ -1,5 +1,5 @@ # sd-dlopen.m4 -# serial 3 +# serial 4 dnl Copyright (C) 2026 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,6 +9,7 @@ AC_DEFUN([gl_SD_DLOPEN], [ AC_REQUIRE([gl_LIBDL]) + AC_REQUIRE([AC_CANONICAL_HOST]) AC_CACHE_CHECK([whether the assembler supports .ifndef, .endif, and .balign], [gl_cv_asm_ifndef_endif_balign], @@ -50,7 +51,15 @@ AC_DEFUN([gl_SD_DLOPEN] ]])], [gl_cv_asm_section_R=yes], [gl_cv_asm_section_R=no])]) - if test $gl_cv_asm_section_R = yes; then + dnl On Solaris 11.4 (machines cfarm215.cfarm.net, cfarm216.cfarm.net), + dnl the use of the section flag R causes the assembler to mark the object + dnl file with ELF OS/ABI "UNIX - GNU" rather than "UNIX - System V", + dnl which then leads to an error + dnl ld: fatal: file test-sd-dlopen.o: wrong ELF OSABI: ELFOSABI_GNU + dnl Therefore, on Solaris, avoid the section flag R, even if the assembler + dnl supports it. + if test $gl_cv_asm_section_R = yes \ + && case "$host_os" in solaris*) false;; *) true;; esac; then gl_sd_dlopen_section_flags='"aGR"' else gl_sd_dlopen_section_flags='"aG"'
