Link vdso before linking the main executable

Also set linked flag after it is linked and
call constructors. Set RTLD_NODELETE flag to
prevent accidental unloads.

Test: bionic-unit-tests --gtest_filter=dl*:Dl*
Test: bionic-unit-tests-glibc --gtest_filter=dl*
Change-Id: Ib2178849b918cbefd6f8fcfe6d1f78889fe0bf76
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index 1e2b6c9..66ea0f9 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -245,6 +245,12 @@
   dlclose(handle);
 }
 
+TEST(dlfcn, dlopen_vdso) {
+  void* handle = dlopen("linux-vdso.so.1", RTLD_NOW);
+  ASSERT_TRUE(handle != nullptr) << dlerror();
+  dlclose(handle);
+}
+
 // mips doesn't support ifuncs
 #if !defined(__mips__)
 TEST(dlfcn, ifunc_variable) {