diff options
| author | 2015-04-07 16:09:30 -0700 | |
|---|---|---|
| committer | 2015-04-07 16:43:08 -0700 | |
| commit | 3c54b0023fca579aae006dfa607fb14de5846c42 (patch) | |
| tree | 7b996231875fdfd54855a9aa86fe2494cdee1ec5 /compiler | |
| parent | 425ee0e1103b52bb72132df64f503725d1a15300 (diff) | |
ART: Fix 64-bit ELF file support
The API wasn't cross-compile-safe, 32-bit patchoat would fail for
negative delta applied to a 64-bit ELF file.
Add 64-bit ELF file output to the compilers, behind a flag, currently
off by default (preserving current behavior).
Bug: 20095017
Change-Id: I2cde7b4c7cc83413c76692d7b745868d644a604c
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/compiler.h | 3 | ||||
| -rw-r--r-- | compiler/dex/quick/quick_compiler.cc | 9 | ||||
| -rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 9 |
3 files changed, 17 insertions, 4 deletions
diff --git a/compiler/compiler.h b/compiler/compiler.h index 6ec39f9605..a04641e3fa 100644 --- a/compiler/compiler.h +++ b/compiler/compiler.h @@ -107,6 +107,9 @@ class Compiler { return driver_; } + // Whether to produce 64-bit ELF files for 64-bit targets. Leave this off for now. + static constexpr bool kProduce64BitELFFiles = false; + private: CompilerDriver* const driver_; const uint64_t maximum_compilation_time_before_warning_; diff --git a/compiler/dex/quick/quick_compiler.cc b/compiler/dex/quick/quick_compiler.cc index 8baafc7fd2..01652d6560 100644 --- a/compiler/dex/quick/quick_compiler.cc +++ b/compiler/dex/quick/quick_compiler.cc @@ -798,8 +798,13 @@ bool QuickCompiler::WriteElf(art::File* file, const std::vector<const art::DexFile*>& dex_files, const std::string& android_root, bool is_host) const { - return art::ElfWriterQuick32::Create(file, oat_writer, dex_files, android_root, is_host, - *GetCompilerDriver()); + if (kProduce64BitELFFiles && Is64BitInstructionSet(GetCompilerDriver()->GetInstructionSet())) { + return art::ElfWriterQuick64::Create(file, oat_writer, dex_files, android_root, is_host, + *GetCompilerDriver()); + } else { + return art::ElfWriterQuick32::Create(file, oat_writer, dex_files, android_root, is_host, + *GetCompilerDriver()); + } } Mir2Lir* QuickCompiler::GetCodeGenerator(CompilationUnit* cu, void* compilation_unit) const { diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index e474c49121..e67bebd5d8 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -201,8 +201,13 @@ class OptimizingCompiler FINAL : public Compiler { const std::vector<const art::DexFile*>& dex_files, const std::string& android_root, bool is_host) const OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return art::ElfWriterQuick32::Create(file, oat_writer, dex_files, android_root, is_host, - *GetCompilerDriver()); + if (kProduce64BitELFFiles && Is64BitInstructionSet(GetCompilerDriver()->GetInstructionSet())) { + return art::ElfWriterQuick64::Create(file, oat_writer, dex_files, android_root, is_host, + *GetCompilerDriver()); + } else { + return art::ElfWriterQuick32::Create(file, oat_writer, dex_files, android_root, is_host, + *GetCompilerDriver()); + } } void InitCompilationUnit(CompilationUnit& cu) const OVERRIDE; |