Brian Carlstrom | 6a47b9d | 2013-05-17 10:58:25 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_COMPILER_ELF_WRITER_QUICK_H_ |
| 18 | #define ART_COMPILER_ELF_WRITER_QUICK_H_ |
Brian Carlstrom | 6a47b9d | 2013-05-17 10:58:25 -0700 | [diff] [blame] | 19 | |
Brian Carlstrom | b12f347 | 2014-06-11 14:54:46 -0700 | [diff] [blame] | 20 | #include "elf_utils.h" |
Brian Carlstrom | 6a47b9d | 2013-05-17 10:58:25 -0700 | [diff] [blame] | 21 | #include "elf_writer.h" |
David Srbecky | 2f6cdb0 | 2015-04-11 00:17:53 +0100 | [diff] [blame] | 22 | #include "oat_writer.h" |
Brian Carlstrom | 6a47b9d | 2013-05-17 10:58:25 -0700 | [diff] [blame] | 23 | |
| 24 | namespace art { |
| 25 | |
David Srbecky | 533c207 | 2015-04-22 12:20:22 +0100 | [diff] [blame] | 26 | template <typename ElfTypes> |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 27 | class ElfWriterQuick FINAL : public ElfWriter { |
Brian Carlstrom | 6a47b9d | 2013-05-17 10:58:25 -0700 | [diff] [blame] | 28 | public: |
| 29 | // Write an ELF file. Returns true on success, false on failure. |
| 30 | static bool Create(File* file, |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 31 | OatWriter* oat_writer, |
Brian Carlstrom | 6a47b9d | 2013-05-17 10:58:25 -0700 | [diff] [blame] | 32 | const std::vector<const DexFile*>& dex_files, |
| 33 | const std::string& android_root, |
| 34 | bool is_host, |
| 35 | const CompilerDriver& driver) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 36 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | 6a47b9d | 2013-05-17 10:58:25 -0700 | [diff] [blame] | 37 | |
David Srbecky | f898087 | 2015-05-22 17:04:47 +0100 | [diff] [blame] | 38 | static void EncodeOatPatches(const std::vector<uintptr_t>& locations, |
David Srbecky | 2f6cdb0 | 2015-04-11 00:17:53 +0100 | [diff] [blame] | 39 | std::vector<uint8_t>* buffer); |
| 40 | |
Brian Carlstrom | 6a47b9d | 2013-05-17 10:58:25 -0700 | [diff] [blame] | 41 | protected: |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 42 | bool Write(OatWriter* oat_writer, |
| 43 | const std::vector<const DexFile*>& dex_files, |
| 44 | const std::string& android_root, |
| 45 | bool is_host) |
| 46 | OVERRIDE |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 47 | SHARED_REQUIRES(Locks::mutator_lock_); |
Brian Carlstrom | 6a47b9d | 2013-05-17 10:58:25 -0700 | [diff] [blame] | 48 | |
| 49 | private: |
Ian Rogers | 3d50407 | 2014-03-01 09:16:49 -0800 | [diff] [blame] | 50 | ElfWriterQuick(const CompilerDriver& driver, File* elf_file) |
| 51 | : ElfWriter(driver, elf_file) {} |
| 52 | ~ElfWriterQuick() {} |
Brian Carlstrom | 6a47b9d | 2013-05-17 10:58:25 -0700 | [diff] [blame] | 53 | |
| 54 | DISALLOW_IMPLICIT_CONSTRUCTORS(ElfWriterQuick); |
| 55 | }; |
| 56 | |
Nicolas Geoffray | f9b87b1 | 2014-09-02 08:12:09 +0000 | [diff] [blame] | 57 | // Explicitly instantiated in elf_writer_quick.cc |
David Srbecky | 533c207 | 2015-04-22 12:20:22 +0100 | [diff] [blame] | 58 | typedef ElfWriterQuick<ElfTypes32> ElfWriterQuick32; |
| 59 | typedef ElfWriterQuick<ElfTypes64> ElfWriterQuick64; |
Nicolas Geoffray | f9b87b1 | 2014-09-02 08:12:09 +0000 | [diff] [blame] | 60 | |
Brian Carlstrom | 6a47b9d | 2013-05-17 10:58:25 -0700 | [diff] [blame] | 61 | } // namespace art |
| 62 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 63 | #endif // ART_COMPILER_ELF_WRITER_QUICK_H_ |