This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libc git tst-array checks fail


On Sat, Nov 3, 2012 at 5:44 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sat, Nov 3, 2012 at 11:38 AM, Klaus Dittrich <kladit@arcor.de> wrote:
>> Am 11/03/12 17:57, schrieb Ryan S. Arnold:
>>
>>> On Sat, Nov 3, 2012 at 11:54 AM, Ryan S. Arnold <ryan.arnold@gmail.com>
>>> wrote:
>>>>
>>>> Hi Klaus,
>>>>
>>>> I believe this is due to a bug in GCC which has been fixed upstream in
>>>> 4.8.  I believe it will be back ported to 4.7 in the next few days.
>>>
>>>
>>> For reference:
>>>
>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53708
>>>
>>> We encountered this on PowerPC as well.
>>>
>>> Ryan S. Arnold
>>>
>>
>> Ryan, thank you for this hint.
>>
>> I compiled with -O3 and gcc version 4.6.4 20121102.
>>
>> So I hope it will be fixed in gcc-4.6 as well.
>>
>> I just verified it, with -02 the bug also shows up.
>>
>> Is except for this bug gcc-4.7 recommended/required for libc?
>>
>
> Both results are correct.  Before GCC 4.7, we use.ctors/.dtors.
> Starting from GCC 4.7, we only use .init_array/.fini_array
> sections.  Without priority, the order between .ctors and init_array
> sections are undefined.
>

Here is a patch.  Tested with GCC 4.6.  OK to install?

Thanks.

-- 
H.J.
--
2012-11-03  H.J. Lu  <hongjiu.lu@intel.com>

	* elf/tst-array1.c (init): Set constructor priority to 1000.
	(fini): Set destructor priority to 1000.
	* elf/tst-array2dep.c: Likewise.
diff --git a/elf/tst-array1.c b/elf/tst-array1.c
index ca9bdf4..a839f5c 100644
--- a/elf/tst-array1.c
+++ b/elf/tst-array1.c
@@ -1,6 +1,6 @@
 #include <unistd.h>

-static void init (void) __attribute__ ((constructor));
+static void init (void) __attribute__ ((constructor (1000)));

 static void
 init (void)
@@ -8,7 +8,7 @@ init (void)
   write (STDOUT_FILENO, "init\n", 5);
 }

-static void fini (void) __attribute__ ((destructor));
+static void fini (void) __attribute__ ((destructor (1000)));

 static void
 fini (void)
diff --git a/elf/tst-array2dep.c b/elf/tst-array2dep.c
index 2812761..bd71dbd 100644
--- a/elf/tst-array2dep.c
+++ b/elf/tst-array2dep.c
@@ -1,6 +1,6 @@
 #include <unistd.h>

-static void init (void) __attribute__ ((constructor));
+static void init (void) __attribute__ ((constructor (1000)));

 static void
 init (void)
@@ -8,7 +8,7 @@ init (void)
   write (STDOUT_FILENO, "DSO init\n", 9);
 }

-static void fini (void) __attribute__ ((destructor));
+static void fini (void) __attribute__ ((destructor (1000)));

 static void
 fini (void)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]