[binutils-gdb] init-mixed.c count

Alan Modra via Binutils-cvs <[email protected]> Sun, 19 Jul 2026 08:29:15 +0000 (GMT)
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3De325e994e8fb=
63b6b1fa7e0b70b783fe8ff69dd2

commit e325e994e8fb63b6b1fa7e0b70b783fe8ff69dd2
Author: Alan Modra <[email protected]>
Date:   Sun Jul 19 17:42:39 2026 +0930

    init-mixed.c count
   =20
    The variable isn't a counter so rename it, and use small values that
    won't overflow a target with 16-bit int.  Since commit 2e806738bd
    there is a possibility of running tests on such targets.
   =20
            * testsuite/ld-elf/init-mixed.c: Rename "count" to "order"
            and use values of 0 to 6 when checking init/fini order.

Diff:
---
 ld/testsuite/ld-elf/init-mixed.c | 48 ++++++++++++++++++++----------------=
----
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/ld/testsuite/ld-elf/init-mixed.c b/ld/testsuite/ld-elf/init-mi=
xed.c
index f401ded4d70..7aeebca1389 100644
--- a/ld/testsuite/ld-elf/init-mixed.c
+++ b/ld/testsuite/ld-elf/init-mixed.c
@@ -3,14 +3,14 @@
 #include <stdlib.h>
=20
 #ifdef HAVE_INITFINI_ARRAY
-static int count;
+static int order;
=20
 static void
 init1005 ()
 {
-  if (count !=3D 0)
+  if (order !=3D 0)
     abort ();
-  count =3D 1005;
+  order =3D 1;
 }
 void (*const init_array1005[]) ()
   __attribute__ ((section (".init_array.01005"), aligned (sizeof (void *))=
))
@@ -18,7 +18,7 @@ void (*const init_array1005[]) ()
 static void
 fini1005 ()
 {
-  if (count !=3D 1005)
+  if (order !=3D 1)
     abort ();
 }
 void (*const fini_array1005[]) ()
@@ -28,16 +28,16 @@ void (*const fini_array1005[]) ()
 static void
 ctor1007a ()
 {
-  if (count !=3D 1005)
+  if (order !=3D 1)
     abort ();
-  count =3D 1006;
+  order =3D 2;
 }
 static void
 ctor1007b ()
 {
-  if (count !=3D 1006)
+  if (order !=3D 2)
     abort ();
-  count =3D 1007;
+  order =3D 3;
 }
 void (*const ctors1007[]) ()
   __attribute__ ((section (".ctors.64528"), aligned (sizeof (void *))))
@@ -45,16 +45,16 @@ void (*const ctors1007[]) ()
 static void
 dtor1007a ()
 {
-  if (count !=3D 1006)
+  if (order !=3D 2)
     abort ();
-  count =3D 1005;
+  order =3D 1;
 }
 static void
 dtor1007b ()
 {
-  if (count !=3D 1007)
+  if (order !=3D 3)
     abort ();
-  count =3D 1006;
+  order =3D 2;
 }
 void (*const dtors1007[]) ()
   __attribute__ ((section (".dtors.64528"), aligned (sizeof (void *))))
@@ -63,9 +63,9 @@ void (*const dtors1007[]) ()
 static void
 init65530 ()
 {
-  if (count !=3D 1007)
+  if (order !=3D 3)
     abort ();
-  count =3D 65530;
+  order =3D 4;
 }
 void (*const init_array65530[]) ()
   __attribute__ ((section (".init_array.65530"), aligned (sizeof (void *))=
))
@@ -73,9 +73,9 @@ void (*const init_array65530[]) ()
 static void
 fini65530 ()
 {
-  if (count !=3D 65530)
+  if (order !=3D 4)
     abort ();
-  count =3D 1007;
+  order =3D 3;
 }
 void (*const fini_array65530[]) ()
   __attribute__ ((section (".fini_array.65530"), aligned (sizeof (void *))=
))
@@ -84,16 +84,16 @@ void (*const fini_array65530[]) ()
 static void
 ctor65535a ()
 {
-  if (count !=3D 65530)
+  if (order !=3D 4)
     abort ();
-  count =3D 65535;
+  order =3D 5;
 }
 static void
 ctor65535b ()
 {
-  if (count !=3D 65535)
+  if (order !=3D 5)
     abort ();
-  count =3D 65536;
+  order =3D 6;
 }
 void (*const ctors65535[]) ()
   __attribute__ ((section (".ctors"), aligned (sizeof (void *))))
@@ -101,16 +101,16 @@ void (*const ctors65535[]) ()
 static void
 dtor65535b ()
 {
-  if (count !=3D 65536)
+  if (order !=3D 6)
     abort ();
-  count =3D 65535;
+  order =3D 5;
 }
 static void
 dtor65535a ()
 {
-  if (count !=3D 65535)
+  if (order !=3D 5)
     abort ();
-  count =3D 65530;
+  order =3D 4;
 }
 void (*const dtors65535[]) ()
   __attribute__ ((section (".dtors"), aligned (sizeof (void *))))