077c9d
commit e5d262effe3a87164308a3f37e61b32d0348692a
077c9d
Author: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
077c9d
Date:   Fri Nov 30 18:05:32 2018 -0200
077c9d
077c9d
    Fix _dl_profile_fixup data-dependency issue (Bug 23690)
077c9d
    
077c9d
    There is a data-dependency between the fields of struct l_reloc_result
077c9d
    and the field used as the initialization guard. Users of the guard
077c9d
    expect writes to the structure to be observable when they also observe
077c9d
    the guard initialized. The solution for this problem is to use an acquire
077c9d
    and release load and store to ensure previous writes to the structure are
077c9d
    observable if the guard is initialized.
077c9d
    
077c9d
    The previous implementation used DL_FIXUP_VALUE_ADDR (l_reloc_result->addr)
077c9d
    as the initialization guard, making it impossible for some architectures
077c9d
    to load and store it atomically, i.e. hppa and ia64, due to its larger size.
077c9d
    
077c9d
    This commit adds an unsigned int to l_reloc_result to be used as the new
077c9d
    initialization guard of the struct, making it possible to load and store
077c9d
    it atomically in all architectures. The fix ensures that the values
077c9d
    observed in l_reloc_result are consistent and do not lead to crashes.
077c9d
    The algorithm is documented in the code in elf/dl-runtime.c
077c9d
    (_dl_profile_fixup). Not all data races have been eliminated.
077c9d
    
077c9d
    Tested with build-many-glibcs and on powerpc, powerpc64, and powerpc64le.
077c9d
    
077c9d
            [BZ #23690]
077c9d
            * elf/dl-runtime.c (_dl_profile_fixup): Guarantee memory
077c9d
            modification order when accessing reloc_result->addr.
077c9d
            * include/link.h (reloc_result): Add field init.
077c9d
            * nptl/Makefile (tests): Add tst-audit-threads.
077c9d
            (modules-names): Add tst-audit-threads-mod1 and
077c9d
            tst-audit-threads-mod2.
077c9d
            Add rules to build tst-audit-threads.
077c9d
            * nptl/tst-audit-threads-mod1.c: New file.
077c9d
            * nptl/tst-audit-threads-mod2.c: Likewise.
077c9d
            * nptl/tst-audit-threads.c: Likewise.
077c9d
            * nptl/tst-audit-threads.h: Likewise.
077c9d
    
077c9d
    Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
077c9d
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
077c9d
077c9d
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
077c9d
index 63bbc89776..3d2f4a7a76 100644
077c9d
--- a/elf/dl-runtime.c
077c9d
+++ b/elf/dl-runtime.c
077c9d
@@ -183,10 +183,36 @@ _dl_profile_fixup (
077c9d
   /* This is the address in the array where we store the result of previous
077c9d
      relocations.  */
077c9d
   struct reloc_result *reloc_result = &l->l_reloc_result[reloc_index];
077c9d
-  DL_FIXUP_VALUE_TYPE *resultp = &reloc_result->addr;
077c9d
 
077c9d
-  DL_FIXUP_VALUE_TYPE value = *resultp;
077c9d
-  if (DL_FIXUP_VALUE_CODE_ADDR (value) == 0)
077c9d
+ /* CONCURRENCY NOTES:
077c9d
+
077c9d
+  Multiple threads may be calling the same PLT sequence and with
077c9d
+  LD_AUDIT enabled they will be calling into _dl_profile_fixup to
077c9d
+  update the reloc_result with the result of the lazy resolution.
077c9d
+  The reloc_result guard variable is reloc_init, and we use
077c9d
+  acquire/release loads and store to it to ensure that the results of
077c9d
+  the structure are consistent with the loaded value of the guard.
077c9d
+  This does not fix all of the data races that occur when two or more
077c9d
+  threads read reloc_result->reloc_init with a value of zero and read
077c9d
+  and write to that reloc_result concurrently.  The expectation is
077c9d
+  generally that while this is a data race it works because the
077c9d
+  threads write the same values.  Until the data races are fixed
077c9d
+  there is a potential for problems to arise from these data races.
077c9d
+  The reloc result updates should happen in parallel but there should
077c9d
+  be an atomic RMW which does the final update to the real result
077c9d
+  entry (see bug 23790).
077c9d
+
077c9d
+  The following code uses reloc_result->init set to 0 to indicate if it is
077c9d
+  the first time this object is being relocated, otherwise 1 which
077c9d
+  indicates the object has already been relocated.
077c9d
+
077c9d
+  Reading/Writing from/to reloc_result->reloc_init must not happen
077c9d
+  before previous writes to reloc_result complete as they could
077c9d
+  end-up with an incomplete struct.  */
077c9d
+  DL_FIXUP_VALUE_TYPE value;
077c9d
+  unsigned int init = atomic_load_acquire (&reloc_result->init);
077c9d
+
077c9d
+  if (init == 0)
077c9d
     {
077c9d
       /* This is the first time we have to relocate this object.  */
077c9d
       const ElfW(Sym) *const symtab
077c9d
@@ -346,19 +372,31 @@ _dl_profile_fixup (
077c9d
 
077c9d
       /* Store the result for later runs.  */
077c9d
       if (__glibc_likely (! GLRO(dl_bind_not)))
077c9d
-	*resultp = value;
077c9d
+	{
077c9d
+	  reloc_result->addr = value;
077c9d
+	  /* Guarantee all previous writes complete before
077c9d
+	     init is updated.  See CONCURRENCY NOTES earlier  */
077c9d
+	  atomic_store_release (&reloc_result->init, 1);
077c9d
+	}
077c9d
+      init = 1;
077c9d
     }
077c9d
+  else
077c9d
+    value = reloc_result->addr;
077c9d
 
077c9d
   /* By default we do not call the pltexit function.  */
077c9d
   long int framesize = -1;
077c9d
 
077c9d
+
077c9d
 #ifdef SHARED
077c9d
   /* Auditing checkpoint: report the PLT entering and allow the
077c9d
      auditors to change the value.  */
077c9d
-  if (DL_FIXUP_VALUE_CODE_ADDR (value) != 0 && GLRO(dl_naudit) > 0
077c9d
+  if (GLRO(dl_naudit) > 0
077c9d
       /* Don't do anything if no auditor wants to intercept this call.  */
077c9d
       && (reloc_result->enterexit & LA_SYMB_NOPLTENTER) == 0)
077c9d
     {
077c9d
+      /* Sanity check:  DL_FIXUP_VALUE_CODE_ADDR (value) should have been
077c9d
+	 initialized earlier in this function or in another thread.  */
077c9d
+      assert (DL_FIXUP_VALUE_CODE_ADDR (value) != 0);
077c9d
       ElfW(Sym) *defsym = ((ElfW(Sym) *) D_PTR (reloc_result->bound,
077c9d
 						l_info[DT_SYMTAB])
077c9d
 			   + reloc_result->boundndx);
077c9d
diff --git a/include/link.h b/include/link.h
077c9d
index 5924594548..83b1c34b7b 100644
077c9d
--- a/include/link.h
077c9d
+++ b/include/link.h
077c9d
@@ -216,6 +216,10 @@ struct link_map
077c9d
       unsigned int boundndx;
077c9d
       uint32_t enterexit;
077c9d
       unsigned int flags;
077c9d
+      /* CONCURRENCY NOTE: This is used to guard the concurrent initialization
077c9d
+	 of the relocation result across multiple threads.  See the more
077c9d
+	 detailed notes in elf/dl-runtime.c.  */
077c9d
+      unsigned int init;
077c9d
     } *l_reloc_result;
077c9d
 
077c9d
     /* Pointer to the version information if available.  */
077c9d
diff --git a/nptl/Makefile b/nptl/Makefile
077c9d
index 982e43adfa..98b0aa01c7 100644
077c9d
--- a/nptl/Makefile
077c9d
+++ b/nptl/Makefile
077c9d
@@ -382,7 +382,8 @@ tests += tst-cancelx2 tst-cancelx3 tst-cancelx4 tst-cancelx5 \
077c9d
 	 tst-cleanupx0 tst-cleanupx1 tst-cleanupx2 tst-cleanupx3 tst-cleanupx4 \
077c9d
 	 tst-oncex3 tst-oncex4
077c9d
 ifeq ($(build-shared),yes)
077c9d
-tests += tst-atfork2 tst-tls4 tst-_res1 tst-fini1 tst-compat-forwarder
077c9d
+tests += tst-atfork2 tst-tls4 tst-_res1 tst-fini1 tst-compat-forwarder \
077c9d
+	 tst-audit-threads
077c9d
 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
077c9d
 tests-nolibpthread += tst-fini1
077c9d
 ifeq ($(have-z-execstack),yes)
077c9d
@@ -394,7 +395,8 @@ modules-names = tst-atfork2mod tst-tls3mod tst-tls4moda tst-tls4modb \
077c9d
 		tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
077c9d
 		tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
077c9d
 		tst-_res1mod1 tst-_res1mod2 tst-execstack-mod tst-fini1mod \
077c9d
-		tst-join7mod tst-compat-forwarder-mod
077c9d
+		tst-join7mod tst-compat-forwarder-mod tst-audit-threads-mod1 \
077c9d
+		tst-audit-threads-mod2
077c9d
 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
077c9d
 		   tst-cleanup4aux.o tst-cleanupx4aux.o
077c9d
 test-extras += tst-cleanup4aux tst-cleanupx4aux
077c9d
@@ -712,6 +714,14 @@ $(objpfx)tst-compat-forwarder: $(objpfx)tst-compat-forwarder-mod.so
077c9d
 
077c9d
 tst-mutex10-ENV = GLIBC_TUNABLES=glibc.elision.enable=1
077c9d
 
077c9d
+# Protect against a build using -Wl,-z,now.
077c9d
+LDFLAGS-tst-audit-threads-mod1.so = -Wl,-z,lazy
077c9d
+LDFLAGS-tst-audit-threads-mod2.so = -Wl,-z,lazy
077c9d
+LDFLAGS-tst-audit-threads = -Wl,-z,lazy
077c9d
+$(objpfx)tst-audit-threads: $(objpfx)tst-audit-threads-mod2.so
077c9d
+$(objpfx)tst-audit-threads.out: $(objpfx)tst-audit-threads-mod1.so
077c9d
+tst-audit-threads-ENV = LD_AUDIT=$(objpfx)tst-audit-threads-mod1.so
077c9d
+
077c9d
 # The tests here better do not run in parallel
077c9d
 ifneq ($(filter %tests,$(MAKECMDGOALS)),)
077c9d
 .NOTPARALLEL:
077c9d
diff --git a/nptl/tst-audit-threads-mod1.c b/nptl/tst-audit-threads-mod1.c
077c9d
new file mode 100644
077c9d
index 0000000000..615d5ee512
077c9d
--- /dev/null
077c9d
+++ b/nptl/tst-audit-threads-mod1.c
077c9d
@@ -0,0 +1,74 @@
077c9d
+/* Dummy audit library for test-audit-threads.
077c9d
+
077c9d
+   Copyright (C) 2018 Free Software Foundation, Inc.
077c9d
+   This file is part of the GNU C Library.
077c9d
+
077c9d
+   The GNU C Library is free software; you can redistribute it and/or
077c9d
+   modify it under the terms of the GNU Lesser General Public
077c9d
+   License as published by the Free Software Foundation; either
077c9d
+   version 2.1 of the License, or (at your option) any later version.
077c9d
+
077c9d
+   The GNU C Library is distributed in the hope that it will be useful,
077c9d
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
077c9d
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
077c9d
+   Lesser General Public License for more details.
077c9d
+
077c9d
+   You should have received a copy of the GNU Lesser General Public
077c9d
+   License along with the GNU C Library; if not, see
077c9d
+   <http://www.gnu.org/licenses/>.  */
077c9d
+
077c9d
+#include <elf.h>
077c9d
+#include <link.h>
077c9d
+#include <stdio.h>
077c9d
+#include <assert.h>
077c9d
+#include <string.h>
077c9d
+
077c9d
+/* We must use a dummy LD_AUDIT module to force the dynamic loader to
077c9d
+   *not* update the real PLT, and instead use a cached value for the
077c9d
+   lazy resolution result.  It is the update of that cached value that
077c9d
+   we are testing for correctness by doing this.  */
077c9d
+
077c9d
+/* Library to be audited.  */
077c9d
+#define LIB "tst-audit-threads-mod2.so"
077c9d
+/* CALLNUM is the number of retNum functions.  */
077c9d
+#define CALLNUM 7999
077c9d
+
077c9d
+#define CONCATX(a, b) __CONCAT (a, b)
077c9d
+
077c9d
+static int previous = 0;
077c9d
+
077c9d
+unsigned int
077c9d
+la_version (unsigned int ver)
077c9d
+{
077c9d
+  return 1;
077c9d
+}
077c9d
+
077c9d
+unsigned int
077c9d
+la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
077c9d
+{
077c9d
+  return LA_FLG_BINDTO | LA_FLG_BINDFROM;
077c9d
+}
077c9d
+
077c9d
+uintptr_t
077c9d
+CONCATX(la_symbind, __ELF_NATIVE_CLASS) (ElfW(Sym) *sym,
077c9d
+					unsigned int ndx,
077c9d
+					uintptr_t *refcook,
077c9d
+					uintptr_t *defcook,
077c9d
+					unsigned int *flags,
077c9d
+					const char *symname)
077c9d
+{
077c9d
+  const char * retnum = "retNum";
077c9d
+  char * num = strstr (symname, retnum);
077c9d
+  int n;
077c9d
+  /* Validate if the symbols are getting called in the correct order.
077c9d
+     This code is here to verify binutils does not optimize out the PLT
077c9d
+     entries that require the symbol binding.  */
077c9d
+  if (num != NULL)
077c9d
+    {
077c9d
+      n = atoi (num);
077c9d
+      assert (n >= previous);
077c9d
+      assert (n <= CALLNUM);
077c9d
+      previous = n;
077c9d
+    }
077c9d
+  return sym->st_value;
077c9d
+}
077c9d
diff --git a/nptl/tst-audit-threads-mod2.c b/nptl/tst-audit-threads-mod2.c
077c9d
new file mode 100644
077c9d
index 0000000000..f9817dd3dc
077c9d
--- /dev/null
077c9d
+++ b/nptl/tst-audit-threads-mod2.c
077c9d
@@ -0,0 +1,22 @@
077c9d
+/* Shared object with a huge number of functions for test-audit-threads.
077c9d
+
077c9d
+   Copyright (C) 2018 Free Software Foundation, Inc.
077c9d
+   This file is part of the GNU C Library.
077c9d
+
077c9d
+   The GNU C Library is free software; you can redistribute it and/or
077c9d
+   modify it under the terms of the GNU Lesser General Public
077c9d
+   License as published by the Free Software Foundation; either
077c9d
+   version 2.1 of the License, or (at your option) any later version.
077c9d
+
077c9d
+   The GNU C Library is distributed in the hope that it will be useful,
077c9d
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
077c9d
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
077c9d
+   Lesser General Public License for more details.
077c9d
+
077c9d
+   You should have received a copy of the GNU Lesser General Public
077c9d
+   License along with the GNU C Library; if not, see
077c9d
+   <http://www.gnu.org/licenses/>.  */
077c9d
+
077c9d
+/* Define all the retNumN functions in a library.  */
077c9d
+#define definenum
077c9d
+#include "tst-audit-threads.h"
077c9d
diff --git a/nptl/tst-audit-threads.c b/nptl/tst-audit-threads.c
077c9d
new file mode 100644
077c9d
index 0000000000..e4bf433bd8
077c9d
--- /dev/null
077c9d
+++ b/nptl/tst-audit-threads.c
077c9d
@@ -0,0 +1,97 @@
077c9d
+/* Test multi-threading using LD_AUDIT.
077c9d
+
077c9d
+   Copyright (C) 2018 Free Software Foundation, Inc.
077c9d
+   This file is part of the GNU C Library.
077c9d
+
077c9d
+   The GNU C Library is free software; you can redistribute it and/or
077c9d
+   modify it under the terms of the GNU Lesser General Public
077c9d
+   License as published by the Free Software Foundation; either
077c9d
+   version 2.1 of the License, or (at your option) any later version.
077c9d
+
077c9d
+   The GNU C Library is distributed in the hope that it will be useful,
077c9d
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
077c9d
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
077c9d
+   Lesser General Public License for more details.
077c9d
+
077c9d
+   You should have received a copy of the GNU Lesser General Public
077c9d
+   License along with the GNU C Library; if not, see
077c9d
+   <http://www.gnu.org/licenses/>.  */
077c9d
+
077c9d
+/* This test uses a dummy LD_AUDIT library (test-audit-threads-mod1) and a
077c9d
+   library with a huge number of functions in order to validate lazy symbol
077c9d
+   binding with an audit library.  We use one thread per CPU to test that
077c9d
+   concurrent lazy resolution does not have any defects which would cause
077c9d
+   the process to fail.  We use an LD_AUDIT library to force the testing of
077c9d
+   the relocation resolution caching code in the dynamic loader i.e.
077c9d
+   _dl_runtime_profile and _dl_profile_fixup.  */
077c9d
+
077c9d
+#include <support/xthread.h>
077c9d
+#include <strings.h>
077c9d
+#include <stdlib.h>
077c9d
+#include <sys/sysinfo.h>
077c9d
+
077c9d
+static int do_test (void);
077c9d
+
077c9d
+/* This test usually takes less than 3s to run.  However, there are cases that
077c9d
+   take up to 30s.  */
077c9d
+#define TIMEOUT 60
077c9d
+#define TEST_FUNCTION do_test ()
077c9d
+#include "../test-skeleton.c"
077c9d
+
077c9d
+/* Declare the functions we are going to call.  */
077c9d
+#define externnum
077c9d
+#include "tst-audit-threads.h"
077c9d
+#undef externnum
077c9d
+
077c9d
+int num_threads;
077c9d
+pthread_barrier_t barrier;
077c9d
+
077c9d
+void
077c9d
+sync_all (int num)
077c9d
+{
077c9d
+  pthread_barrier_wait (&barrier);
077c9d
+}
077c9d
+
077c9d
+void
077c9d
+call_all_ret_nums (void)
077c9d
+{
077c9d
+  /* Call each function one at a time from all threads.  */
077c9d
+#define callnum
077c9d
+#include "tst-audit-threads.h"
077c9d
+#undef callnum
077c9d
+}
077c9d
+
077c9d
+void *
077c9d
+thread_main (void *unused)
077c9d
+{
077c9d
+  call_all_ret_nums ();
077c9d
+  return NULL;
077c9d
+}
077c9d
+
077c9d
+#define STR2(X) #X
077c9d
+#define STR(X) STR2(X)
077c9d
+
077c9d
+static int
077c9d
+do_test (void)
077c9d
+{
077c9d
+  int i;
077c9d
+  pthread_t *threads;
077c9d
+
077c9d
+  num_threads = get_nprocs ();
077c9d
+  if (num_threads <= 1)
077c9d
+    num_threads = 2;
077c9d
+
077c9d
+  /* Used to synchronize all the threads after calling each retNumN.  */
077c9d
+  xpthread_barrier_init (&barrier, NULL, num_threads);
077c9d
+
077c9d
+  threads = (pthread_t *) xcalloc (num_threads, sizeof(pthread_t));
077c9d
+  for (i = 0; i < num_threads; i++)
077c9d
+    threads[i] = xpthread_create(NULL, thread_main, NULL);
077c9d
+
077c9d
+  for (i = 0; i < num_threads; i++)
077c9d
+    xpthread_join(threads[i]);
077c9d
+
077c9d
+  free (threads);
077c9d
+
077c9d
+  return 0;
077c9d
+}
077c9d
diff --git a/nptl/tst-audit-threads.h b/nptl/tst-audit-threads.h
077c9d
new file mode 100644
077c9d
index 0000000000..1c9ecc08df
077c9d
--- /dev/null
077c9d
+++ b/nptl/tst-audit-threads.h
077c9d
@@ -0,0 +1,92 @@
077c9d
+/* Helper header for test-audit-threads.
077c9d
+
077c9d
+   Copyright (C) 2018 Free Software Foundation, Inc.
077c9d
+   This file is part of the GNU C Library.
077c9d
+
077c9d
+   The GNU C Library is free software; you can redistribute it and/or
077c9d
+   modify it under the terms of the GNU Lesser General Public
077c9d
+   License as published by the Free Software Foundation; either
077c9d
+   version 2.1 of the License, or (at your option) any later version.
077c9d
+
077c9d
+   The GNU C Library is distributed in the hope that it will be useful,
077c9d
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
077c9d
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
077c9d
+   Lesser General Public License for more details.
077c9d
+
077c9d
+   You should have received a copy of the GNU Lesser General Public
077c9d
+   License along with the GNU C Library; if not, see
077c9d
+   <http://www.gnu.org/licenses/>.  */
077c9d
+
077c9d
+/* We use this helper to create a large number of functions, all of
077c9d
+   which will be resolved lazily and thus have their PLT updated.
077c9d
+   This is done to provide enough functions that we can statistically
077c9d
+   observe a thread vs. PLT resolution failure if one exists.  */
077c9d
+
077c9d
+#define CONCAT(a, b) a ## b
077c9d
+#define NUM(x, y) CONCAT (x, y)
077c9d
+
077c9d
+#define FUNC10(x)	\
077c9d
+  FUNC (NUM (x, 0));	\
077c9d
+  FUNC (NUM (x, 1));	\
077c9d
+  FUNC (NUM (x, 2));	\
077c9d
+  FUNC (NUM (x, 3));	\
077c9d
+  FUNC (NUM (x, 4));	\
077c9d
+  FUNC (NUM (x, 5));	\
077c9d
+  FUNC (NUM (x, 6));	\
077c9d
+  FUNC (NUM (x, 7));	\
077c9d
+  FUNC (NUM (x, 8));	\
077c9d
+  FUNC (NUM (x, 9))
077c9d
+
077c9d
+#define FUNC100(x)	\
077c9d
+  FUNC10 (NUM (x, 0));	\
077c9d
+  FUNC10 (NUM (x, 1));	\
077c9d
+  FUNC10 (NUM (x, 2));	\
077c9d
+  FUNC10 (NUM (x, 3));	\
077c9d
+  FUNC10 (NUM (x, 4));	\
077c9d
+  FUNC10 (NUM (x, 5));	\
077c9d
+  FUNC10 (NUM (x, 6));	\
077c9d
+  FUNC10 (NUM (x, 7));	\
077c9d
+  FUNC10 (NUM (x, 8));	\
077c9d
+  FUNC10 (NUM (x, 9))
077c9d
+
077c9d
+#define FUNC1000(x)		\
077c9d
+  FUNC100 (NUM (x, 0));		\
077c9d
+  FUNC100 (NUM (x, 1));		\
077c9d
+  FUNC100 (NUM (x, 2));		\
077c9d
+  FUNC100 (NUM (x, 3));		\
077c9d
+  FUNC100 (NUM (x, 4));		\
077c9d
+  FUNC100 (NUM (x, 5));		\
077c9d
+  FUNC100 (NUM (x, 6));		\
077c9d
+  FUNC100 (NUM (x, 7));		\
077c9d
+  FUNC100 (NUM (x, 8));		\
077c9d
+  FUNC100 (NUM (x, 9))
077c9d
+
077c9d
+#define FUNC7000()	\
077c9d
+  FUNC1000 (1);		\
077c9d
+  FUNC1000 (2);		\
077c9d
+  FUNC1000 (3);		\
077c9d
+  FUNC1000 (4);		\
077c9d
+  FUNC1000 (5);		\
077c9d
+  FUNC1000 (6);		\
077c9d
+  FUNC1000 (7);
077c9d
+
077c9d
+#ifdef FUNC
077c9d
+# undef FUNC
077c9d
+#endif
077c9d
+
077c9d
+#ifdef externnum
077c9d
+# define FUNC(x) extern int CONCAT (retNum, x) (void)
077c9d
+#endif
077c9d
+
077c9d
+#ifdef definenum
077c9d
+# define FUNC(x) int CONCAT (retNum, x) (void) { return x; }
077c9d
+#endif
077c9d
+
077c9d
+#ifdef callnum
077c9d
+# define FUNC(x) CONCAT (retNum, x) (); sync_all (x)
077c9d
+#endif
077c9d
+
077c9d
+/* A value of 7000 functions is chosen as an arbitrarily large
077c9d
+   number of functions that will allow us enough attempts to
077c9d
+   verify lazy resolution operation.  */
077c9d
+FUNC7000 ();