I noticed that HAVE_INITFINI_ARRAY_SUPPORT wasn't properly detected on
Solaris 11.4 and up in 64-bit-default configurations when using gas
(2.32) and Solaris ld.
Closer inspection revealed the following: both Solaris as and gas <=
2.28 emit
Section Header[7]: sh_name: .init_array.01005
sh_addr: 0 sh_flags: [ SHF_ALLOC ]
sh_size: 0x4 sh_type: [ SHT_PROGBITS ]
sh_offset: 0x4c sh_entsize: 0
sh_link: 0 sh_info: 0
sh_addralign: 0x4
while since gas 2.29 one gets both a warning
initfini.s:1: Warning: ignoring incorrect section type for .init_array.01005
and
Section Header[7]: sh_name: .init_array.01005
sh_addr: 0 sh_flags: [ SHF_WRITE SHF_ALLOC ]
sh_size: 0x4 sh_type: [ SHT_INIT_ARRAY ]
sh_offset: 0x4c sh_entsize: 0x8 (0 entries)
sh_link: 0 sh_info: 0
sh_addralign: 0x4
Since sh_size < sh_entsize, when the resulting object is linked into an
executable, the latter lacks the .init_array section completely. This
seems a plausible thing to do and the workaround is easy: just double
the size of test strings. The following patch does just that.
Tested on {i386,amd64}-pc-solaris2.11 and sparc{,v9}-sun-solaris2.11
without regressions and proper HAVE_INITFINI_ARRAY_SUPPORT detection.
Since this only affects Solaris ld, I've checked it in.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
2019-02-10 Rainer Orth <[email protected]>
* acinclude.m4 (gcc_AC_INITFINI_ARRAY): Use 8-byte strings with
Solaris ld.
* configure: Regenerate.
# HG changeset patch
# Parent 7f704296017d34ec13aa97b574555028c8a81ca6
Restore .init_array detection on 64-bit Solaris/x86
diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4
--- a/gcc/acinclude.m4
+++ b/gcc/acinclude.m4
@@ -374,16 +374,16 @@ EOF
cat > conftest.s <<EOF
.section $sh_quote.fini_array.65530$sh_quote,$sh_flags,$sh_type
.align 4
-.byte 'C', 'C', 'C', 'C'
+.byte 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C'
.section $sh_quote.init_array.65530$sh_quote,$sh_flags,$sh_type
.align 4
-.byte 'D', 'D', 'D', 'D'
+.byte 'D', 'D', 'D', 'D', 'D', 'D', 'D', 'D'
.section $sh_quote.fini_array.01005$sh_quote,$sh_flags,$sh_type
.align 4
-.byte 'G', 'G', 'G', 'G'
+.byte 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G'
.section $sh_quote.init_array.01005$sh_quote,$sh_flags,$sh_type
.align 4
-.byte 'H', 'H', 'H', 'H'
+.byte 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H'
.text
.globl _start
_start:
@@ -391,9 +391,9 @@ EOF
if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
&& $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
&& $gcc_cv_objdump -s -j .init_array conftest \
- | grep HHHHDDDD > /dev/null 2>&1 \
+ | grep HHHHHHHHDDDDDDDD > /dev/null 2>&1 \
&& $gcc_cv_objdump -s -j .fini_array conftest \
- | grep GGGGCCCC > /dev/null 2>&1; then
+ | grep GGGGGGGGCCCCCCCC > /dev/null 2>&1; then
gcc_cv_initfini_array=yes
fi
;;