summaryrefslogtreecommitdiff
path: root/patchoat/patchoat.cc
diff options
context:
space:
mode:
Diffstat (limited to 'patchoat/patchoat.cc')
-rw-r--r--patchoat/patchoat.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc
index 2d165b05da..8e5af53e66 100644
--- a/patchoat/patchoat.cc
+++ b/patchoat/patchoat.cc
@@ -24,9 +24,11 @@
#include <string>
#include <vector>
+#include "base/dumpable.h"
#include "base/scoped_flock.h"
#include "base/stringpiece.h"
#include "base/stringprintf.h"
+#include "base/unix_file/fd_file.h"
#include "elf_utils.h"
#include "elf_file.h"
#include "elf_file_impl.h"
@@ -513,7 +515,7 @@ bool PatchOat::PatchOatHeader(ElfFileImpl* oat_file) {
}
bool PatchOat::PatchElf() {
- if (oat_file_->is_elf64_)
+ if (oat_file_->Is64Bit())
return PatchElf<ElfFileImpl64>(oat_file_->GetImpl64());
else
return PatchElf<ElfFileImpl32>(oat_file_->GetImpl32());
@@ -531,13 +533,12 @@ bool PatchOat::PatchElf(ElfFileImpl* oat_file) {
}
bool need_fixup = false;
- for (unsigned int i = 0; i < oat_file->GetProgramHeaderNum(); i++) {
+ for (unsigned int i = 0; i < oat_file->GetProgramHeaderNum(); ++i) {
auto hdr = oat_file->GetProgramHeader(i);
- if (hdr->p_vaddr != 0 && hdr->p_vaddr != hdr->p_offset) {
- need_fixup = true;
- }
- if (hdr->p_paddr != 0 && hdr->p_paddr != hdr->p_offset) {
+ if ((hdr->p_vaddr != 0 && hdr->p_vaddr != hdr->p_offset) ||
+ (hdr->p_paddr != 0 && hdr->p_paddr != hdr->p_offset)) {
need_fixup = true;
+ break;
}
}
if (!need_fixup) {
@@ -644,8 +645,7 @@ static void UsageError(const char* fmt, ...) {
va_end(ap);
}
-static void Usage(const char *fmt, ...) NO_RETURN;
-static void Usage(const char *fmt, ...) {
+[[noreturn]] static void Usage(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
UsageErrorV(fmt, ap);
@@ -759,6 +759,7 @@ static File* CreateOrOpen(const char* name, bool* created) {
static int patchoat(int argc, char **argv) {
InitLogging(argv);
+ MemMap::Init();
const bool debug = kIsDebugBuild;
orig_argc = argc;
orig_argv = argv;
@@ -801,7 +802,7 @@ static int patchoat(int argc, char **argv) {
bool dump_timings = kIsDebugBuild;
bool lock_output = true;
- for (int i = 0; i < argc; i++) {
+ for (int i = 0; i < argc; ++i) {
const StringPiece option(argv[i]);
const bool log_options = false;
if (log_options) {