-int __vdso_clock_gettime(clockid_t, struct timespec *) __attribute__((weak));
-static int (*cgt)(clockid_t, struct timespec *) = __vdso_clock_gettime;
+#ifdef VDSO_CGT_SYM
+
+void *__vdsosym(const char *, const char *);
+
+static void *volatile vdso_func;
+
+static int cgt_init(clockid_t clk, struct timespec *ts)
+{
+ void *p = __vdsosym(VDSO_CGT_VER, VDSO_CGT_SYM);
+ int (*f)(clockid_t, struct timespec *) =
+ (int (*)(clockid_t, struct timespec *))p;
+ a_cas_p(&vdso_func, (void *)cgt_init, p);
+ return f ? f(clk, ts) : -ENOSYS;
+}
+
+static void *volatile vdso_func = (void *)cgt_init;
+
+#endif