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 Sun, Nov 4, 2012 at 1:04 AM, Roland McGrath <roland@hack.frob.com> wrote:
> When was the priority field in the attribute syntax introduced?  If it was

I found:

Mon Oct 12 19:57:34 1998  Jason Merrill  <jason@yorick.cygnus.com>

        * collect2.c (extract_init_priority): No priority is 65535.

It looks like that it was added before Oct., 1998.

> after our minimum supported compiler version for building libc, then you
> need to conditionalize the use of that syntax.  At any rate, it merits a
> comment in the uses about why the priority matters to the test.
>

Sure.  Done.

-- 
H.J.
--
2012-11-04  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..e998932 100644
--- a/elf/tst-array1.c
+++ b/elf/tst-array1.c
@@ -1,6 +1,7 @@
 #include <unistd.h>

-static void init (void) __attribute__ ((constructor));
+/* Give init non-default priority so that it runs before init_array.  */
+static void init (void) __attribute__ ((constructor (1000)));

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

-static void fini (void) __attribute__ ((destructor));
+/* Give fini the same priority as init.  */
+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..2f920cd 100644
--- a/elf/tst-array2dep.c
+++ b/elf/tst-array2dep.c
@@ -1,6 +1,7 @@
 #include <unistd.h>

-static void init (void) __attribute__ ((constructor));
+/* Give init non-default priority so that it runs before init_array.  */
+static void init (void) __attribute__ ((constructor (1000)));

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

-static void fini (void) __attribute__ ((destructor));
+/* Give fini the same priority as init.  */
+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]