linux: update test expectations

Android 9+ sets the executable's dynamic array
address in the link map.

Improve tests to verify that the dynamic array
address in the link map matches the address in the
executable.

Bug: chromium:1050178
Change-Id: I4c938f804092c8f35578389a7e7d7267144ad80c
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1967972
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
This commit is contained in:
Joshua Peraza 2020-06-01 14:55:26 -07:00 committed by Commit Bot
parent 4b5a5bac26
commit 686852d9d8

View File

@ -74,6 +74,13 @@ void TestAgainstTarget(PtraceConnection* connection) {
LinuxVMAddress debug_address; LinuxVMAddress debug_address;
ASSERT_TRUE(exe_reader.GetDebugAddress(&debug_address)); ASSERT_TRUE(exe_reader.GetDebugAddress(&debug_address));
VMAddress exe_dynamic_address = 0;
if (exe_reader.GetDynamicArrayAddress(&exe_dynamic_address)) {
CheckedLinuxAddressRange exe_range(
connection->Is64Bit(), exe_reader.Address(), exe_reader.Size());
EXPECT_TRUE(exe_range.ContainsValue(exe_dynamic_address));
}
// start the actual tests // start the actual tests
DebugRendezvous debug; DebugRendezvous debug;
ASSERT_TRUE(debug.Initialize(range, debug_address)); ASSERT_TRUE(debug.Initialize(range, debug_address));
@ -85,8 +92,13 @@ void TestAgainstTarget(PtraceConnection* connection) {
EXPECT_NE(debug.Executable()->name.find("crashpad_snapshot_test"), EXPECT_NE(debug.Executable()->name.find("crashpad_snapshot_test"),
std::string::npos); std::string::npos);
// Android's loader never sets the dynamic array for the executable. // Android's loader doesn't set the dynamic array for the executable in the
EXPECT_EQ(debug.Executable()->dynamic_array, 0u); // link map until Android 9.0 (API 28).
if (android_runtime_api >= 28) {
EXPECT_EQ(debug.Executable()->dynamic_array, exe_dynamic_address);
} else {
EXPECT_EQ(debug.Executable()->dynamic_array, 0u);
}
#else #else
// glibc's loader implements most of the tested features that Android's was // glibc's loader implements most of the tested features that Android's was
// missing but has since gained. // missing but has since gained.
@ -94,9 +106,7 @@ void TestAgainstTarget(PtraceConnection* connection) {
// glibc's loader does not set the name for the executable. // glibc's loader does not set the name for the executable.
EXPECT_TRUE(debug.Executable()->name.empty()); EXPECT_TRUE(debug.Executable()->name.empty());
CheckedLinuxAddressRange exe_range( EXPECT_EQ(debug.Executable()->dynamic_array, exe_dynamic_address);
connection->Is64Bit(), exe_reader.Address(), exe_reader.Size());
EXPECT_TRUE(exe_range.ContainsValue(debug.Executable()->dynamic_array));
#endif // OS_ANDROID #endif // OS_ANDROID
// Android's loader doesn't set the load bias until Android 4.3 (API 18). // Android's loader doesn't set the load bias until Android 4.3 (API 18).