blob: 83781abeff5efc7f5665ed4aa851242a08c2024a [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
David Srbecky533c2072015-04-22 12:20:22 +010026template <typename ElfTypes>
Ian Rogers3d504072014-03-01 09:16:49 -080027class ElfWriterQuick FINAL : public ElfWriter {
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070028 public:
29 // Write an ELF file. Returns true on success, false on failure.
30 static bool Create(File* file,
Ian Rogers3d504072014-03-01 09:16:49 -080031 OatWriter* oat_writer,
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070032 const std::vector<const DexFile*>& dex_files,
33 const std::string& android_root,
34 bool is_host,
35 const CompilerDriver& driver)
Mathieu Chartier90443472015-07-16 20:32:27 -070036 SHARED_REQUIRES(Locks::mutator_lock_);
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070037
David Srbeckyf8980872015-05-22 17:04:47 +010038 static void EncodeOatPatches(const std::vector<uintptr_t>& locations,
David Srbecky2f6cdb02015-04-11 00:17:53 +010039 std::vector<uint8_t>* buffer);
40
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070041 protected:
Ian Rogers3d504072014-03-01 09:16:49 -080042 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 Chartier90443472015-07-16 20:32:27 -070047 SHARED_REQUIRES(Locks::mutator_lock_);
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070048
49 private:
Ian Rogers3d504072014-03-01 09:16:49 -080050 ElfWriterQuick(const CompilerDriver& driver, File* elf_file)
51 : ElfWriter(driver, elf_file) {}
52 ~ElfWriterQuick() {}
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070053
54 DISALLOW_IMPLICIT_CONSTRUCTORS(ElfWriterQuick);
55};
56
Nicolas Geoffrayf9b87b12014-09-02 08:12:09 +000057// Explicitly instantiated in elf_writer_quick.cc
David Srbecky533c2072015-04-22 12:20:22 +010058typedef ElfWriterQuick<ElfTypes32> ElfWriterQuick32;
59typedef ElfWriterQuick<ElfTypes64> ElfWriterQuick64;
Nicolas Geoffrayf9b87b12014-09-02 08:12:09 +000060
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070061} // namespace art
62
Brian Carlstromfc0e3212013-07-17 14:40:12 -070063#endif // ART_COMPILER_ELF_WRITER_QUICK_H_