Add patchoat check that input oat file has patch section.
Do this check before opening the output file in case this could be
causing the file to become truncated.
Bug: 27723864
(cherry-picked from commit 99503b9805def2ed7d4fe4bf285c6fdd8ddce6ed)
Change-Id: I2134ec65fb6d9582f4eb4c2619a5ffb7b987eaa6
diff --git a/runtime/elf_file.cc b/runtime/elf_file.cc
index 3b4b88d..096f003 100644
--- a/runtime/elf_file.cc
+++ b/runtime/elf_file.cc
@@ -1830,6 +1830,14 @@
}
}
+bool ElfFile::HasSection(const std::string& name) const {
+ if (elf64_.get() != nullptr) {
+ return elf64_->FindSectionByName(name) != nullptr;
+ } else {
+ return elf32_->FindSectionByName(name) != nullptr;
+ }
+}
+
uint64_t ElfFile::FindSymbolAddress(unsigned section_type,
const std::string& symbol_name,
bool build_map) {