Revert "Write shared data section for oatdump export dex"
This reverts commit fdca4cb565c25a4a05078b2afc3f7abb374309e3.
Reason for revert: CHECK failure in device testing (bad checksum).
Change-Id: I43bd3ada4853022728d217ff8b79c32026fc4974
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index b483e5f..b342abe 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -300,13 +300,11 @@
$(HOST_CORE_IMAGE_DEFAULT_64) \
$(HOST_CORE_IMAGE_DEFAULT_32) \
oatdumpd-host \
- oatdumpds-host \
- dexdump2-host
+ oatdumpds-host
ART_GTEST_oatdump_test_TARGET_DEPS := \
$(TARGET_CORE_IMAGE_DEFAULT_64) \
$(TARGET_CORE_IMAGE_DEFAULT_32) \
- oatdumpd-target \
- dexdump2-target
+ oatdumpd-target
ART_GTEST_oatdump_image_test_HOST_DEPS := $(ART_GTEST_oatdump_test_HOST_DEPS)
ART_GTEST_oatdump_image_test_TARGET_DEPS := $(ART_GTEST_oatdump_test_TARGET_DEPS)
ART_GTEST_oatdump_app_test_HOST_DEPS := $(ART_GTEST_oatdump_test_HOST_DEPS) \
diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc
index 3bff123..433ed9a 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -1180,17 +1180,6 @@
}
}
- // Update header for shared section.
- uint32_t shared_section_offset = 0u;
- uint32_t shared_section_size = 0u;
- if (dex_file->IsCompactDexFile()) {
- CompactDexFile::Header* const header =
- reinterpret_cast<CompactDexFile::Header*>(const_cast<uint8_t*>(dex_file->Begin()));
- shared_section_offset = header->data_off_;
- shared_section_size = header->data_size_;
- // The shared section will be serialized right after the dex file.
- header->data_off_ = header->file_size_;
- }
// Verify output directory exists
if (!OS::DirectoryExists(options_.export_dex_location_)) {
// TODO: Extend OS::DirectoryExists if symlink support is required
@@ -1237,22 +1226,16 @@
return false;
}
- bool success = file->WriteFully(dex_file->Begin(), fsize);
+ bool success = false;
+ success = file->WriteFully(dex_file->Begin(), fsize);
+ // }
+
if (!success) {
os << "Failed to write dex file";
file->Erase();
return false;
}
- if (shared_section_size != 0) {
- success = file->WriteFully(dex_file->Begin() + shared_section_offset, shared_section_size);
- if (!success) {
- os << "Failed to write shared data section";
- file->Erase();
- return false;
- }
- }
-
if (file->FlushCloseOrErase() != 0) {
os << "Flush and close failed";
return false;
diff --git a/oatdump/oatdump_test.cc b/oatdump/oatdump_test.cc
index 18cb2fd..0034469 100644
--- a/oatdump/oatdump_test.cc
+++ b/oatdump/oatdump_test.cc
@@ -75,11 +75,6 @@
std::string error_msg;
ASSERT_TRUE(Exec(kDynamic, kModeOat, {"--export-dex-to=" + tmp_dir_}, kListOnly, &error_msg))
<< error_msg;
- const std::string dex_location = tmp_dir_+ "/core-oj-hostdex.jar_export.dex";
- const std::string dexdump2 = GetExecutableFilePath("dexdump2",
- /*is_debug*/false,
- /*is_static*/false);
- ASSERT_TRUE(ForkAndExecAndWait({dexdump2, "-d", dex_location}, &error_msg)) << error_msg;
}
TEST_F(OatDumpTest, TestExportDexStatic) {
TEST_DISABLED_FOR_NON_STATIC_HOST_BUILDS();
diff --git a/oatdump/oatdump_test.h b/oatdump/oatdump_test.h
index b85730d..fac0bb2 100644
--- a/oatdump/oatdump_test.h
+++ b/oatdump/oatdump_test.h
@@ -70,24 +70,20 @@
kStatic, // oatdump(d)s, dex2oat(d)s
};
- // Returns path to the oatdump/dex2oat/dexdump binary.
- std::string GetExecutableFilePath(const char* name, bool is_debug, bool is_static) {
+ // Returns path to the oatdump/dex2oat binary.
+ std::string GetExecutableFilePath(Flavor flavor, const char* name) {
std::string root = GetTestAndroidRoot();
root += "/bin/";
root += name;
- if (is_debug) {
+ if (kIsDebugBuild) {
root += "d";
}
- if (is_static) {
+ if (flavor == kStatic) {
root += "s";
}
return root;
}
- std::string GetExecutableFilePath(Flavor flavor, const char* name) {
- return GetExecutableFilePath(name, kIsDebugBuild, flavor == kStatic);
- }
-
enum Mode {
kModeOat,
kModeOatWithBootImage,
@@ -131,7 +127,17 @@
};
exec_argv.insert(exec_argv.end(), args.begin(), args.end());
- return ForkAndExecAndWait(exec_argv, error_msg);
+ pid_t pid;
+ int pipe_fd;
+ bool result = ForkAndExec(exec_argv, &pid, &pipe_fd, error_msg);
+ if (result) {
+ close(pipe_fd);
+ int status = 0;
+ if (waitpid(pid, &status, 0) != -1) {
+ result = (status == 0);
+ }
+ }
+ return result;
}
// Run the test with custom arguments.
@@ -294,21 +300,6 @@
}
}
- bool ForkAndExecAndWait(const std::vector<std::string>& exec_argv,
- /*out*/ std::string* error_msg) {
- pid_t pid;
- int pipe_fd;
- bool result = ForkAndExec(exec_argv, &pid, &pipe_fd, error_msg);
- if (result) {
- close(pipe_fd);
- int status = 0;
- if (waitpid(pid, &status, 0) != -1) {
- result = (status == 0);
- }
- }
- return result;
- }
-
std::string tmp_dir_;
private: