blob: 811beb44d2cfc7e10cee3ac8f86c326c6343ce17 [file] [log] [blame]
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -07001/*
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 Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_COMPILER_ELF_WRITER_QUICK_H_
18#define ART_COMPILER_ELF_WRITER_QUICK_H_
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070019
Brian Carlstromb12f3472014-06-11 14:54:46 -070020#include "elf_utils.h"
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070021#include "elf_writer.h"
David Srbecky2f6cdb02015-04-11 00:17:53 +010022#include "oat_writer.h"
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070023
24namespace art {
25
Nicolas Geoffrayf9b87b12014-09-02 08:12:09 +000026template <typename Elf_Word, typename Elf_Sword, typename Elf_Addr,
27 typename Elf_Dyn, typename Elf_Sym, typename Elf_Ehdr,
28 typename Elf_Phdr, typename Elf_Shdr>
Ian Rogers3d504072014-03-01 09:16:49 -080029class ElfWriterQuick FINAL : public ElfWriter {
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070030 public:
31 // Write an ELF file. Returns true on success, false on failure.
32 static bool Create(File* file,
Ian Rogers3d504072014-03-01 09:16:49 -080033 OatWriter* oat_writer,
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070034 const std::vector<const DexFile*>& dex_files,
35 const std::string& android_root,
36 bool is_host,
37 const CompilerDriver& driver)
38 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
39
David Srbecky2f6cdb02015-04-11 00:17:53 +010040 static void EncodeOatPatches(const OatWriter::PatchLocationsMap& sections,
41 std::vector<uint8_t>* buffer);
42
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070043 protected:
Ian Rogers3d504072014-03-01 09:16:49 -080044 bool Write(OatWriter* oat_writer,
45 const std::vector<const DexFile*>& dex_files,
46 const std::string& android_root,
47 bool is_host)
48 OVERRIDE
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070049 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
50
51 private:
Ian Rogers3d504072014-03-01 09:16:49 -080052 ElfWriterQuick(const CompilerDriver& driver, File* elf_file)
53 : ElfWriter(driver, elf_file) {}
54 ~ElfWriterQuick() {}
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070055
56 DISALLOW_IMPLICIT_CONSTRUCTORS(ElfWriterQuick);
57};
58
Nicolas Geoffrayf9b87b12014-09-02 08:12:09 +000059// Explicitly instantiated in elf_writer_quick.cc
60typedef ElfWriterQuick<Elf32_Word, Elf32_Sword, Elf32_Addr, Elf32_Dyn,
61 Elf32_Sym, Elf32_Ehdr, Elf32_Phdr, Elf32_Shdr> ElfWriterQuick32;
62typedef ElfWriterQuick<Elf64_Word, Elf64_Sword, Elf64_Addr, Elf64_Dyn,
63 Elf64_Sym, Elf64_Ehdr, Elf64_Phdr, Elf64_Shdr> ElfWriterQuick64;
64
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070065} // namespace art
66
Brian Carlstromfc0e3212013-07-17 14:40:12 -070067#endif // ART_COMPILER_ELF_WRITER_QUICK_H_