blob: d9e45a9c19295a9db8fc5690853eb03666daf8dd [file] [log] [blame]
Brian Carlstrom700c8d32012-11-05 10:42:02 -08001/*
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 Carlstrom6a47b9d2013-05-17 10:58:25 -070017#include "elf_fixup.h"
18#include "elf_stripper.h"
Brian Carlstrom700c8d32012-11-05 10:42:02 -080019#include "os.h"
20
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070021#if defined(ART_USE_PORTABLE_COMPILER)
22#include "elf_writer_mclinker.h"
23#else
24#include "elf_writer_quick.h"
25#endif
26
Ian Rogers1212a022013-03-04 10:48:41 -080027namespace art {
28class CompilerDriver;
Brian Carlstrom265091e2013-01-30 14:08:26 -080029class DexFile;
Ian Rogers1212a022013-03-04 10:48:41 -080030} // namespace art
31
32extern "C" bool WriteElf(art::CompilerDriver& driver,
Brian Carlstrom3f47c122013-03-07 00:02:40 -080033 const std::string& android_root,
Brian Carlstrom265091e2013-01-30 14:08:26 -080034 bool is_host,
35 const std::vector<const art::DexFile*>& dex_files,
Brian Carlstrom700c8d32012-11-05 10:42:02 -080036 std::vector<uint8_t>& oat_contents,
Brian Carlstrom265091e2013-01-30 14:08:26 -080037 art::File* file)
38 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070039#if defined(ART_USE_PORTABLE_COMPILER)
40 return art::ElfWriterMclinker::Create(file, oat_contents, dex_files, android_root, is_host, driver);
41#else
42 return art::ElfWriterQuick::Create(file, oat_contents, dex_files, android_root, is_host, driver);
43#endif
Brian Carlstrom700c8d32012-11-05 10:42:02 -080044}
45extern "C" bool FixupElf(art::File* file, uintptr_t oat_data_begin) {
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070046 return art::ElfFixup::Fixup(file, oat_data_begin);
Brian Carlstrom700c8d32012-11-05 10:42:02 -080047}
48extern "C" void GetOatElfInformation(art::File* file,
49 size_t& oat_loaded_size,
50 size_t& oat_data_offset) {
51 art::ElfWriter::GetOatElfInformation(file, oat_loaded_size, oat_data_offset);
52}
Brian Carlstrom265091e2013-01-30 14:08:26 -080053extern "C" bool StripElf(art::File* file) {
Brian Carlstrom6a47b9d2013-05-17 10:58:25 -070054 return art::ElfStripper::Strip(file);
Brian Carlstrom265091e2013-01-30 14:08:26 -080055}