linker: add test for empty shdr table
Bug: http://b/30795430
Change-Id: Id839c22f88276f31e0615bc2a67d75e27a9aa7c6
Test: run bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp
index c33bd3a..68827fa 100644
--- a/tests/dlfcn_test.cpp
+++ b/tests/dlfcn_test.cpp
@@ -1186,4 +1186,12 @@
ASSERT_STREQ(expected_dlerror.c_str(), dlerror());
}
+TEST(dlfcn, dlopen_invalid_empty_shdr_table) {
+ std::string libpath = std::string(getenv("ANDROID_DATA")) + PREBUILT_ELF_PATH + "/libtest_invalid-empty_shdr_table.so";
+ void* handle = dlopen(libpath.c_str(), RTLD_NOW);
+ ASSERT_TRUE(handle == nullptr);
+ std::string expected_dlerror = std::string("dlopen failed: \"") + libpath + "\" has no section headers";
+ ASSERT_STREQ(expected_dlerror.c_str(), dlerror());
+}
+
#endif