linker: add test for zero shstrndx

Bug: http://b/30166532
Bug: http://b/30795430
Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
Change-Id: I4cec73635cf403df9dd60b9a294d2298bb0abe3d
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index 6e78082..c33bd3a 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -1178,4 +1178,12 @@
   ASSERT_SUBSTR(expected_dlerror.c_str(), dlerror());
 }
 
+TEST(dlfcn, dlopen_invalid_zero_shstrndx) {
+  std::string libpath = std::string(getenv("ANDROID_DATA")) + PREBUILT_ELF_PATH + "/libtest_invalid-zero_shstrndx.so";
+  void* handle = dlopen(libpath.c_str(), RTLD_NOW);
+  ASSERT_TRUE(handle == nullptr);
+  std::string expected_dlerror = std::string("dlopen failed: \"") + libpath + "\" has invalid e_shstrndx";
+  ASSERT_STREQ(expected_dlerror.c_str(), dlerror());
+}
+
 #endif