linker: add test for zeroed out shdr_table_
Bug: http://b/30795430
Change-Id: I86b658d01b64670d3e702ddb1d3f9db4f75d784f
Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index 0fa32b3..f474ed9 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -1202,4 +1202,12 @@
ASSERT_SUBSTR(expected_dlerror.c_str(), dlerror());
}
+TEST(dlfcn, dlopen_invalid_zero_shdr_table_content) {
+ std::string libpath = std::string(getenv("ANDROID_DATA")) + PREBUILT_ELF_PATH + "/libtest_invalid-zero_shdr_table_content.so";
+ void* handle = dlopen(libpath.c_str(), RTLD_NOW);
+ ASSERT_TRUE(handle == nullptr);
+ std::string expected_dlerror = std::string("dlopen failed: \"") + libpath + "\" .dynamic section header was not found";
+ ASSERT_SUBSTR(expected_dlerror.c_str(), dlerror());
+}
+
#endif