While I'd successfully bootstrapped gcc trunk with binutils from the 2.39 branch on Solaris 11.4/x86 some time ago,trying the same with the actual release broke: genmatch fails to link with /vol/gcc/bin/gld-2.39: ../libcpp/libcpp.a(macro.o): non-canonical reference to canonical protected function `gmtime@@SYSVABI_1.3' in /lib/libc.so /vol/gcc/bin/gld-2.39: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status make[3]: *** [Makefile:3040: build/genmatch] Error 1 From the description of the patch introducing this (late in the 2.39 release cycle), I get the impression that this imposes a glibc requirement on all x86 ELF targets. By disabling the check in bfd/elf32-i386.c and bfd/elf64-x86-64.c, I managed to finish the bootstrap successfully.
The code in question is struct tm *tb = (kind == CPP_time_kind::FIXED ? gmtime : localtime) (&tt); There is no pointer comparison here. We can ignore protected visibility in shared libraries on Solaris.
Created attachment 14288 [details] A patch Try this.
> --- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> --- > Created attachment 14288 [details] > --> https://sourceware.org/bugzilla/attachment.cgi?id=14288&action=edit > A patch > > Try this. I've just successfully completed a i386-pc-solaris2.11 bootstrap. Looks good to go. Thanks.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2c43d202aefb2b6f202a44bbb8a0baf251aae845 commit 2c43d202aefb2b6f202a44bbb8a0baf251aae845 Author: H.J. Lu <hjl.tools@gmail.com> Date: Mon Aug 22 10:26:17 2022 -0700 x86: Ignore protected visibility in shared libraries on Solaris On x86, the PLT entry in executable may be used as function address for functions in shared libraries. If functions are protected, the function address used in executable can be different from the function address used in shared library. This will lead to incorrect run-time behavior if function pointer equality is needed. By default, x86 linker issues an error in this case. On Solaris, linker issued an error for struct tm *tb = (kind == CPP_time_kind::FIXED ? gmtime : localtime) (&tt); where gmtime is a protected function in libc.so. Use gmtime's PLT entry in executable as function address is safe since function pointer equality isn't needed. Ignore protected visibility in shared libraries on Solaris to disable linker error. If function pointer equality is needed, linker will silently generate executable with incorrect run-time behavior on Solaris. PR ld/29512 * elf32-i386.c (elf_i386_scan_relocs): Ignore protected visibility in shared libraries on Solaris. * elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.
Fixed