From 7d09a8cd114751f88bf0d03f0f2e8f87a4a5ed9a Mon Sep 17 00:00:00 2001 From: Dmitriy Ivanov Date: Tue, 23 Jun 2015 13:44:18 -0700 Subject: [PATCH] Work around compiler optimization This makes bionic-unit-test-glibc64 behave consistently when testing dlopen from a library with dt_runpath. Bug: http://b/21899363 Change-Id: I9d446eb6852876975874d6b7761f6f81cc4e9916 --- tests/libs/dlopen_b.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/libs/dlopen_b.cpp b/tests/libs/dlopen_b.cpp index 34f288122..5291d81fa 100644 --- a/tests/libs/dlopen_b.cpp +++ b/tests/libs/dlopen_b.cpp @@ -1,7 +1,15 @@ #include extern "C" void *dlopen_b() { + // TODO (dimitry): this is to work around http://b/20049306 + // remove once it is fixed + static int dummy = 0; + // This is not supposed to succeed. Even though this library has DT_RUNPATH // for libtest_dt_runpath_x.so, it is not taked into account for dlopen. void *handle = dlopen("libtest_dt_runpath_x.so", RTLD_NOW); - return handle; + if (handle != nullptr) { + dummy++; + return handle; + } + return nullptr; }