linker: add test for zero shdr offset

Bug: http://b/30795430
Change-Id: I03853257c4b632ad9daaf1e90f9620678397cff0
Test: bionic-unit-tests --gtest_filter=dlfcn.dlopen_invalid*
This commit is contained in:
Dimitry Ivanov 2016-08-15 13:40:53 -07:00
parent 228e747b6c
commit 4623044517
6 changed files with 11 additions and 0 deletions

View File

@ -35,6 +35,9 @@ include $(LOCAL_PATH)/Android.build.prebuilt.mk
bionic_tests_module := libtest_invalid-empty_shdr_table.so
include $(LOCAL_PATH)/Android.build.prebuilt.mk
bionic_tests_module := libtest_invalid-zero_shdr_table_offset.so
include $(LOCAL_PATH)/Android.build.prebuilt.mk
ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
build_host := true
else

View File

@ -1194,4 +1194,12 @@ TEST(dlfcn, dlopen_invalid_empty_shdr_table) {
ASSERT_STREQ(expected_dlerror.c_str(), dlerror());
}
TEST(dlfcn, dlopen_invalid_zero_shdr_table_offset) {
std::string libpath = std::string(getenv("ANDROID_DATA")) + PREBUILT_ELF_PATH + "/libtest_invalid-zero_shdr_table_offset.so";
void* handle = dlopen(libpath.c_str(), RTLD_NOW);
ASSERT_TRUE(handle == nullptr);
std::string expected_dlerror = std::string("dlopen failed: \"") + libpath + "\" has invalid shdr offset/size: 0/";
ASSERT_SUBSTR(expected_dlerror.c_str(), dlerror());
}
#endif