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 
17 #ifndef ART_COMPILER_ELF_WRITER_QUICK_H_
18 #define ART_COMPILER_ELF_WRITER_QUICK_H_
19 
20 #include "elf_utils.h"
21 #include "elf_writer.h"
22 #include "oat_writer.h"
23 
24 namespace art {
25 
26 template <typename ElfTypes>
27 class ElfWriterQuick FINAL : public ElfWriter {
28  public:
29   // Write an ELF file. Returns true on success, false on failure.
30   static bool Create(File* file,
31                      OatWriter* oat_writer,
32                      const std::vector<const DexFile*>& dex_files,
33                      const std::string& android_root,
34                      bool is_host,
35                      const CompilerDriver& driver)
36       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
37 
38   static void EncodeOatPatches(const std::vector<uintptr_t>& locations,
39                                std::vector<uint8_t>* buffer);
40 
41  protected:
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
47       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
48 
49  private:
ElfWriterQuick(const CompilerDriver & driver,File * elf_file)50   ElfWriterQuick(const CompilerDriver& driver, File* elf_file)
51     : ElfWriter(driver, elf_file) {}
~ElfWriterQuick()52   ~ElfWriterQuick() {}
53 
54   DISALLOW_IMPLICIT_CONSTRUCTORS(ElfWriterQuick);
55 };
56 
57 // Explicitly instantiated in elf_writer_quick.cc
58 typedef ElfWriterQuick<ElfTypes32> ElfWriterQuick32;
59 typedef ElfWriterQuick<ElfTypes64> ElfWriterQuick64;
60 
61 }  // namespace art
62 
63 #endif  // ART_COMPILER_ELF_WRITER_QUICK_H_
64