loader: set PT_INTERP to itself
Some versions of kernel set AT_BASE to 0
if dynamic loader does not have PT_INTERP
set.
Bug: http://b/30739481
Test: run /system/bin/linker64 and /system/bin/linker
Change-Id: I1b67777166fe917d3ee1a97277045ca6f5db0084
diff --git a/tests/dl_test.cpp b/tests/dl_test.cpp
index 74c7b51..ee9b2e1 100644
--- a/tests/dl_test.cpp
+++ b/tests/dl_test.cpp
@@ -24,6 +24,8 @@
#include <string>
+#include "utils.h"
+
extern "C" int main_global_default_serial() {
return 3370318;
}
@@ -69,4 +71,19 @@
ASSERT_EQ(3370318, lib_global_protected_get_serial());
}
+TEST(dl, exec_linker) {
+#if defined(__BIONIC__)
+#if defined(__LP64__)
+ static constexpr const char* kPathToLinker = "/system/bin/linker64";
+#else
+ static constexpr const char* kPathToLinker = "/system/bin/linker";
+#endif
+ ExecTestHelper eth;
+ std::string expected_output = std::string("This is ") + kPathToLinker +
+ ", the helper program for dynamic executables.\n";
+ eth.SetArgs( { kPathToLinker, nullptr });
+ eth.Run([&]() { execve(kPathToLinker, eth.GetArgs(), eth.GetEnv()); }, 0, expected_output.c_str());
+#endif
+}
+
// TODO: Add tests for LD_PRELOADs