diff mbox

Fix .init_array/.fini_array testcase (PR target/50166)

Message ID ydd62lkp7fd.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth Aug. 26, 2011, 2:35 p.m. UTC
As detailed in the PR, H.J.'s .init_array/.fini_array patch

2011-08-20  H.J. Lu  <hongjiu.lu@intel.com>

	PR other/46770
	* config.gcc (tm_file): Add initfini-array.h if
	.init_arrary/.fini_array are supported.

broke Solaris bootstrap since the testcase incorrectly succeeds on
Solaris, failing to notice that none of the constructors and destructors
were ever run.

The following patch fixes that, allows i386-pc-solaris2.11 bootstrap to
succeed and was also bootstrapped on x86_64-unknown-linux-gnu (CentOS
5.5 with gas/gld 2.21).  The testcase still fails on my Linux system, so
I'm uncertain if the fix is right.

Ok for mainline?

	Rainer


2011-08-26  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR target/50166
	* acinclude.m4 (gcc_AC_INITFINI_ARRAY): Check count in main.
	* configure: Regenerate.

Comments

H.J. Lu Aug. 26, 2011, 2:41 p.m. UTC | #1
On Fri, Aug 26, 2011 at 7:35 AM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
> As detailed in the PR, H.J.'s .init_array/.fini_array patch
>
> 2011-08-20  H.J. Lu  <hongjiu.lu@intel.com>
>
>        PR other/46770
>        * config.gcc (tm_file): Add initfini-array.h if
>        .init_arrary/.fini_array are supported.
>
> broke Solaris bootstrap since the testcase incorrectly succeeds on
> Solaris, failing to notice that none of the constructors and destructors
> were ever run.
>
> The following patch fixes that, allows i386-pc-solaris2.11 bootstrap to
> succeed and was also bootstrapped on x86_64-unknown-linux-gnu (CentOS
> 5.5 with gas/gld 2.21).  The testcase still fails on my Linux system, so
> I'm uncertain if the fix is right.
>
> Ok for mainline?
>
>        Rainer
>
>
> 2011-08-26  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>
>        PR target/50166
>        * acinclude.m4 (gcc_AC_INITFINI_ARRAY): Check count in main.
>        * configure: Regenerate.
>
>

That explains why init_array was enabled on AIX.  It looks good to me and
still works on Fedora 15.

Thanks.
Rainer Orth Aug. 26, 2011, 2:45 p.m. UTC | #2
"H.J. Lu" <hjl.tools@gmail.com> writes:

>> 2011-08-26  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>>
>>        PR target/50166
>>        * acinclude.m4 (gcc_AC_INITFINI_ARRAY): Check count in main.
>>        * configure: Regenerate.
>
> That explains why init_array was enabled on AIX.  It looks good to me and
> still works on Fedora 15.

What support do you need on the Linux side for .init_array/.fini_array
to work?  I'd have expected that gld 2.21 is enough, or is ld-linux.so.2
support required, too?

Thanks.
        Rainer
H.J. Lu Aug. 26, 2011, 2:52 p.m. UTC | #3
On Fri, Aug 26, 2011 at 7:45 AM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
>>> 2011-08-26  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>>>
>>>        PR target/50166
>>>        * acinclude.m4 (gcc_AC_INITFINI_ARRAY): Check count in main.
>>>        * configure: Regenerate.
>>
>> That explains why init_array was enabled on AIX.  It looks good to me and
>> still works on Fedora 15.
>
> What support do you need on the Linux side for .init_array/.fini_array
> to work?  I'd have expected that gld 2.21 is enough, or is ld-linux.so.2
> support required, too?

You need the latest Linux binutils. Mixing init_array/,ctors sections support
was added after binutils 2.21 was released:

http://sourceware.org/git/?p=binutils.git;a=commit;h=30dfd0308a8551174634494822e194fcf24a7ddb
Rainer Orth Aug. 26, 2011, 3:01 p.m. UTC | #4
"H.J. Lu" <hjl.tools@gmail.com> writes:

>> What support do you need on the Linux side for .init_array/.fini_array
>> to work?  I'd have expected that gld 2.21 is enough, or is ld-linux.so.2
>> support required, too?
>
> You need the latest Linux binutils. Mixing init_array/,ctors sections support
> was added after binutils 2.21 was released:
>
> http://sourceware.org/git/?p=binutils.git;a=commit;h=30dfd0308a8551174634494822e194fcf24a7ddb

I see, thanks.

	Rainer
Jakub Jelinek Aug. 26, 2011, 3:03 p.m. UTC | #5
On Fri, Aug 26, 2011 at 04:35:18PM +0200, Rainer Orth wrote:
> Ok for mainline?

Yes.
> 
> 2011-08-26  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
> 
> 	PR target/50166
> 	* acinclude.m4 (gcc_AC_INITFINI_ARRAY): Check count in main.
> 	* configure: Regenerate.
> 

	Jakub
diff mbox

Patch

# HG changeset patch
# Parent f622b6f398b4f552dcc1450c8caf6368a5937748
Disable .init_array/.fini_array support on Solaris (PR target/50166)

diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4
--- a/gcc/acinclude.m4
+++ b/gcc/acinclude.m4
@@ -477,6 +477,8 @@  void (*const dtors65535[]) ()
 int
 main ()
 {
+  if (count != 65535)
+    abort ();
   return 0;
 }
 #endif
diff --git a/gcc/configure b/gcc/configure
--- a/gcc/configure
+++ b/gcc/configure
@@ -10888,6 +10888,8 @@  void (*const dtors65535) ()
 int
 main ()
 {
+  if (count != 65535)
+    abort ();
   return 0;
 }
 #endif
@@ -17913,7 +17915,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17916 "configure"
+#line 17918 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18019,7 +18021,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18022 "configure"
+#line 18024 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H