blob: 2b9ef9da715e077a6adbe2db85bbc132c2963710 [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
2 * Copyright (C) 2011 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 */
Brian Carlstrome24fa612011-09-29 00:53:55 -070016
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_OAT_FILE_H_
18#define ART_RUNTIME_OAT_FILE_H_
Brian Carlstrome24fa612011-09-29 00:53:55 -070019
Vladimir Marko3f5838d2014-08-07 18:07:18 +010020#include <list>
Brian Carlstrom700c8d32012-11-05 10:42:02 -080021#include <string>
Brian Carlstrome24fa612011-09-29 00:53:55 -070022#include <vector>
23
Vladimir Marko3f5838d2014-08-07 18:07:18 +010024#include "base/mutex.h"
Vladimir Marko539690a2014-06-05 18:36:42 +010025#include "base/stringpiece.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080026#include "dex_file.h"
27#include "invoke_type.h"
28#include "mem_map.h"
Mingyao Yang98d1cc82014-05-15 17:02:16 -070029#include "mirror/class.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080030#include "oat.h"
Brian Carlstrom700c8d32012-11-05 10:42:02 -080031#include "os.h"
Brian Carlstrome24fa612011-09-29 00:53:55 -070032
33namespace art {
34
Brian Carlstromba150c32013-08-27 17:31:03 -070035class BitVector;
Brian Carlstrom700c8d32012-11-05 10:42:02 -080036class ElfFile;
37class MemMap;
38class OatMethodOffsets;
Ian Rogers33e95662013-05-20 20:29:14 -070039class OatHeader;
Richard Uhler07b3c232015-03-31 15:57:54 -070040class OatDexFile;
Brian Carlstrom700c8d32012-11-05 10:42:02 -080041
Richard Uhler07b3c232015-03-31 15:57:54 -070042class OatFile FINAL {
Brian Carlstrome24fa612011-09-29 00:53:55 -070043 public:
Richard Uhler07b3c232015-03-31 15:57:54 -070044 typedef art::OatDexFile OatDexFile;
45
Alex Light84d76052014-08-22 17:49:35 -070046 // Opens an oat file contained within the given elf file. This is always opened as
47 // non-executable at the moment.
48 static OatFile* OpenWithElfFile(ElfFile* elf_file, const std::string& location,
Richard Uhlere5fed032015-03-18 08:21:11 -070049 const char* abs_dex_location,
Alex Light84d76052014-08-22 17:49:35 -070050 std::string* error_msg);
Brian Carlstrome24fa612011-09-29 00:53:55 -070051 // Open an oat file. Returns NULL on failure. Requested base can
52 // optionally be used to request where the file should be loaded.
Richard Uhlere5fed032015-03-18 08:21:11 -070053 // See the ResolveRelativeEncodedDexLocation for a description of how the
54 // abs_dex_location argument is used.
Brian Carlstrome24fa612011-09-29 00:53:55 -070055 static OatFile* Open(const std::string& filename,
Brian Carlstroma004aa92012-02-08 18:05:09 -080056 const std::string& location,
Ian Rogers13735952014-10-08 12:43:28 -070057 uint8_t* requested_base,
Igor Murashkin46774762014-10-22 11:37:02 -070058 uint8_t* oat_file_begin,
Ian Rogers8d31bbd2013-10-13 10:44:14 -070059 bool executable,
Richard Uhlere5fed032015-03-18 08:21:11 -070060 const char* abs_dex_location,
Ian Rogers8d31bbd2013-10-13 10:44:14 -070061 std::string* error_msg);
Brian Carlstrome24fa612011-09-29 00:53:55 -070062
Brian Carlstrom700c8d32012-11-05 10:42:02 -080063 // Open an oat file from an already opened File.
Brian Carlstrom265091e2013-01-30 14:08:26 -080064 // Does not use dlopen underneath so cannot be used for runtime use
65 // where relocations may be required. Currently used from
66 // ImageWriter which wants to open a writable version from an existing
67 // file descriptor for patching.
Richard Uhlere5fed032015-03-18 08:21:11 -070068 static OatFile* OpenWritable(File* file, const std::string& location,
69 const char* abs_dex_location,
70 std::string* error_msg);
Alex Lighta59dd802014-07-02 16:28:08 -070071 // Opens an oat file from an already opened File. Maps it PROT_READ, MAP_PRIVATE.
Richard Uhlere5fed032015-03-18 08:21:11 -070072 static OatFile* OpenReadable(File* file, const std::string& location,
73 const char* abs_dex_location,
74 std::string* error_msg);
Brian Carlstrom700c8d32012-11-05 10:42:02 -080075
Brian Carlstrome24fa612011-09-29 00:53:55 -070076 ~OatFile();
77
Alex Light9dcc4572014-08-14 14:16:26 -070078 bool IsExecutable() const {
79 return is_executable_;
80 }
81
Andreas Gampe7ba64962014-10-23 11:37:40 -070082 bool IsPic() const;
83
Alex Light53cb16b2014-06-12 11:26:29 -070084 ElfFile* GetElfFile() const {
85 CHECK_NE(reinterpret_cast<uintptr_t>(elf_file_.get()), reinterpret_cast<uintptr_t>(nullptr))
86 << "Cannot get an elf file from " << GetLocation();
87 return elf_file_.get();
88 }
89
Brian Carlstrome24fa612011-09-29 00:53:55 -070090 const std::string& GetLocation() const {
91 return location_;
92 }
93
94 const OatHeader& GetOatHeader() const;
95
Richard Uhler07b3c232015-03-31 15:57:54 -070096 class OatMethod FINAL {
Brian Carlstrom3320cf42011-10-04 14:58:28 -070097 public:
Ian Rogersb0fa5dc2014-04-28 16:47:08 -070098 void LinkMethod(mirror::ArtMethod* method) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Brian Carlstromae826982011-11-09 01:33:42 -080099
100 uint32_t GetCodeOffset() const {
101 return code_offset_;
102 }
Brian Carlstromae826982011-11-09 01:33:42 -0800103
Ian Rogersef7d42f2014-01-06 12:55:46 -0800104 const void* GetQuickCode() const {
Elliott Hughes956af0f2014-12-11 14:34:28 -0800105 return GetOatPointer<const void*>(code_offset_);
Ian Rogersef7d42f2014-01-06 12:55:46 -0800106 }
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700107
108 // Returns size of quick code.
Ian Rogersef7d42f2014-01-06 12:55:46 -0800109 uint32_t GetQuickCodeSize() const;
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700110 uint32_t GetQuickCodeSizeOffset() const;
111
112 // Returns OatQuickMethodHeader for debugging. Most callers should
113 // use more specific methods such as GetQuickCodeSize.
114 const OatQuickMethodHeader* GetOatQuickMethodHeader() const;
115 uint32_t GetOatQuickMethodHeaderOffset() const;
Logan Chien0c717dd2012-03-28 18:31:07 +0800116
Vladimir Marko7624d252014-05-02 14:40:15 +0100117 size_t GetFrameSizeInBytes() const;
118 uint32_t GetCoreSpillMask() const;
119 uint32_t GetFpSpillMask() const;
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700120
Vladimir Marko8a630572014-04-09 18:45:35 +0100121 const uint8_t* GetMappingTable() const;
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700122 uint32_t GetMappingTableOffset() const;
123 uint32_t GetMappingTableOffsetOffset() const;
124
Vladimir Marko8a630572014-04-09 18:45:35 +0100125 const uint8_t* GetVmapTable() const;
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700126 uint32_t GetVmapTableOffset() const;
127 uint32_t GetVmapTableOffsetOffset() const;
Vladimir Marko8a630572014-04-09 18:45:35 +0100128
Mathieu Chartier957ca1c2014-11-21 16:51:29 -0800129 const uint8_t* GetGcMap() const;
130 uint32_t GetGcMapOffset() const;
131 uint32_t GetGcMapOffsetOffset() const;
132
Brian Carlstromae826982011-11-09 01:33:42 -0800133 // Create an OatMethod with offsets relative to the given base address
Mathieu Chartier957ca1c2014-11-21 16:51:29 -0800134 OatMethod(const uint8_t* base, const uint32_t code_offset)
135 : begin_(base), code_offset_(code_offset) {
Ian Rogers97b52f82014-08-14 11:34:07 -0700136 }
137 ~OatMethod() {}
Brian Carlstrom3320cf42011-10-04 14:58:28 -0700138
Ian Rogers97b52f82014-08-14 11:34:07 -0700139 // A representation of an invalid OatMethod, used when an OatMethod or OatClass can't be found.
140 // See ClassLinker::FindOatMethodFor.
141 static const OatMethod Invalid() {
Mathieu Chartier957ca1c2014-11-21 16:51:29 -0800142 return OatMethod(nullptr, -1);
Ian Rogers97b52f82014-08-14 11:34:07 -0700143 }
Nicolas Geoffray4fcdc942014-07-22 10:48:00 +0100144
Brian Carlstromae826982011-11-09 01:33:42 -0800145 private:
146 template<class T>
147 T GetOatPointer(uint32_t offset) const {
148 if (offset == 0) {
149 return NULL;
150 }
Ian Rogers30fab402012-01-23 15:43:46 -0800151 return reinterpret_cast<T>(begin_ + offset);
Brian Carlstromae826982011-11-09 01:33:42 -0800152 }
153
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800154 const uint8_t* begin_;
155 uint32_t code_offset_;
Brian Carlstromae826982011-11-09 01:33:42 -0800156
157 friend class OatClass;
Brian Carlstrom3320cf42011-10-04 14:58:28 -0700158 };
159
Richard Uhler07b3c232015-03-31 15:57:54 -0700160 class OatClass FINAL {
Brian Carlstrome24fa612011-09-29 00:53:55 -0700161 public:
Brian Carlstromba150c32013-08-27 17:31:03 -0700162 mirror::Class::Status GetStatus() const {
163 return status_;
164 }
165
166 OatClassType GetType() const {
167 return type_;
168 }
Brian Carlstrom0755ec52012-01-11 15:19:46 -0800169
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700170 // Get the OatMethod entry based on its index into the class
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700171 // defintion. Direct methods come first, followed by virtual
172 // methods. Note that runtime created methods such as miranda
Brian Carlstrome24fa612011-09-29 00:53:55 -0700173 // methods are not included.
Brian Carlstromaded5f72011-10-07 17:15:04 -0700174 const OatMethod GetOatMethod(uint32_t method_index) const;
Brian Carlstrome24fa612011-09-29 00:53:55 -0700175
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700176 // Return a pointer to the OatMethodOffsets for the requested
177 // method_index, or nullptr if none is present. Note that most
178 // callers should use GetOatMethod.
179 const OatMethodOffsets* GetOatMethodOffsets(uint32_t method_index) const;
180
181 // Return the offset from the start of the OatFile to the
182 // OatMethodOffsets for the requested method_index, or 0 if none
183 // is present. Note that most callers should use GetOatMethod.
184 uint32_t GetOatMethodOffsetsOffset(uint32_t method_index) const;
185
Ian Rogers97b52f82014-08-14 11:34:07 -0700186 // A representation of an invalid OatClass, used when an OatClass can't be found.
187 // See ClassLinker::FindOatClass.
188 static OatClass Invalid() {
189 return OatClass(nullptr, mirror::Class::kStatusError, kOatClassNoneCompiled, 0, nullptr,
190 nullptr);
191 }
Nicolas Geoffray4fcdc942014-07-22 10:48:00 +0100192
Brian Carlstrome24fa612011-09-29 00:53:55 -0700193 private:
Brian Carlstrom0755ec52012-01-11 15:19:46 -0800194 OatClass(const OatFile* oat_file,
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800195 mirror::Class::Status status,
Brian Carlstromba150c32013-08-27 17:31:03 -0700196 OatClassType type,
197 uint32_t bitmap_size,
198 const uint32_t* bitmap_pointer,
Brian Carlstrom0755ec52012-01-11 15:19:46 -0800199 const OatMethodOffsets* methods_pointer);
Brian Carlstrom3320cf42011-10-04 14:58:28 -0700200
Ian Rogers97b52f82014-08-14 11:34:07 -0700201 const OatFile* const oat_file_;
Brian Carlstromba150c32013-08-27 17:31:03 -0700202
Ian Rogers97b52f82014-08-14 11:34:07 -0700203 const mirror::Class::Status status_;
Brian Carlstromba150c32013-08-27 17:31:03 -0700204
Ian Rogers97b52f82014-08-14 11:34:07 -0700205 const OatClassType type_;
Brian Carlstromba150c32013-08-27 17:31:03 -0700206
Ian Rogers97b52f82014-08-14 11:34:07 -0700207 const uint32_t* const bitmap_;
Brian Carlstromba150c32013-08-27 17:31:03 -0700208
Ian Rogers97b52f82014-08-14 11:34:07 -0700209 const OatMethodOffsets* const methods_pointer_;
Brian Carlstrome24fa612011-09-29 00:53:55 -0700210
Richard Uhler07b3c232015-03-31 15:57:54 -0700211 friend class art::OatDexFile;
Brian Carlstrome24fa612011-09-29 00:53:55 -0700212 };
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700213 const OatDexFile* GetOatDexFile(const char* dex_location,
Brian Carlstrom756ee4e2013-10-03 15:46:12 -0700214 const uint32_t* const dex_location_checksum,
Vladimir Marko3f5838d2014-08-07 18:07:18 +0100215 bool exception_if_not_found = true) const
216 LOCKS_EXCLUDED(secondary_lookup_lock_);
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700217
Vladimir Markoaa4497d2014-09-05 14:01:17 +0100218 const std::vector<const OatDexFile*>& GetOatDexFiles() const {
219 return oat_dex_files_storage_;
220 }
Brian Carlstrome24fa612011-09-29 00:53:55 -0700221
Ian Rogers30fab402012-01-23 15:43:46 -0800222 size_t Size() const {
223 return End() - Begin();
Brian Carlstrome24fa612011-09-29 00:53:55 -0700224 }
225
Vladimir Marko5c42c292015-02-25 12:02:49 +0000226 size_t BssSize() const {
227 return BssEnd() - BssBegin();
228 }
229
Ian Rogers13735952014-10-08 12:43:28 -0700230 const uint8_t* Begin() const;
231 const uint8_t* End() const;
Alex Light53cb16b2014-06-12 11:26:29 -0700232
Vladimir Marko5c42c292015-02-25 12:02:49 +0000233 const uint8_t* BssBegin() const;
234 const uint8_t* BssEnd() const;
235
Richard Uhlere5fed032015-03-18 08:21:11 -0700236 // Returns the absolute dex location for the encoded relative dex location.
237 //
238 // If not nullptr, abs_dex_location is used to resolve the absolute dex
239 // location of relative dex locations encoded in the oat file.
240 // For example, given absolute location "/data/app/foo/base.apk", encoded
241 // dex locations "base.apk", "base.apk:classes2.dex", etc. would be resolved
242 // to "/data/app/foo/base.apk", "/data/app/foo/base.apk:classes2.dex", etc.
243 // Relative encoded dex locations that don't match the given abs_dex_location
244 // are left unchanged.
245 static std::string ResolveRelativeEncodedDexLocation(
246 const char* abs_dex_location, const std::string& rel_dex_location);
247
Brian Carlstrome24fa612011-09-29 00:53:55 -0700248 private:
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800249 static void CheckLocation(const std::string& location);
250
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800251 static OatFile* OpenElfFile(File* file,
252 const std::string& location,
Ian Rogers13735952014-10-08 12:43:28 -0700253 uint8_t* requested_base,
Igor Murashkin46774762014-10-22 11:37:02 -0700254 uint8_t* oat_file_begin, // Override base if not null
Brian Carlstromf1d34552013-07-12 20:22:23 -0700255 bool writable,
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700256 bool executable,
Richard Uhlere5fed032015-03-18 08:21:11 -0700257 const char* abs_dex_location,
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700258 std::string* error_msg);
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800259
Alex Light9dcc4572014-08-14 14:16:26 -0700260 explicit OatFile(const std::string& filename, bool executable);
Igor Murashkin46774762014-10-22 11:37:02 -0700261 bool ElfFileOpen(File* file, uint8_t* requested_base,
262 uint8_t* oat_file_begin, // Override where the file is loaded to if not null
263 bool writable, bool executable,
Richard Uhlere5fed032015-03-18 08:21:11 -0700264 const char* abs_dex_location,
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700265 std::string* error_msg);
Richard Uhlere5fed032015-03-18 08:21:11 -0700266
267 bool Setup(const char* abs_dex_location, std::string* error_msg);
Brian Carlstrome24fa612011-09-29 00:53:55 -0700268
Brian Carlstrome24fa612011-09-29 00:53:55 -0700269 // The oat file name.
270 //
271 // The image will embed this to link its associated oat file.
272 const std::string location_;
273
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800274 // Pointer to OatHeader.
Ian Rogers13735952014-10-08 12:43:28 -0700275 const uint8_t* begin_;
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800276
277 // Pointer to end of oat region for bounds checking.
Ian Rogers13735952014-10-08 12:43:28 -0700278 const uint8_t* end_;
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800279
Vladimir Marko5c42c292015-02-25 12:02:49 +0000280 // Pointer to the .bss section, if present, otherwise nullptr.
281 const uint8_t* bss_begin_;
282
283 // Pointer to the end of the .bss section, if present, otherwise nullptr.
284 const uint8_t* bss_end_;
285
Alex Light9dcc4572014-08-14 14:16:26 -0700286 // Was this oat_file loaded executable?
287 const bool is_executable_;
288
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800289 // Backing memory map for oat file during when opened by ElfWriter during initial compilation.
Ian Rogers700a4022014-05-19 16:49:03 -0700290 std::unique_ptr<MemMap> mem_map_;
Brian Carlstrome24fa612011-09-29 00:53:55 -0700291
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800292 // Backing memory map for oat file during cross compilation.
Ian Rogers700a4022014-05-19 16:49:03 -0700293 std::unique_ptr<ElfFile> elf_file_;
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800294
295 // dlopen handle during runtime.
296 void* dlopen_handle_;
297
Vladimir Markoaa4497d2014-09-05 14:01:17 +0100298 // Owning storage for the OatDexFile objects.
299 std::vector<const OatDexFile*> oat_dex_files_storage_;
300
Vladimir Marko3f5838d2014-08-07 18:07:18 +0100301 // NOTE: We use a StringPiece as the key type to avoid a memory allocation on every
302 // lookup with a const char* key. The StringPiece doesn't own its backing storage,
303 // therefore we're using the OatDexFile::dex_file_location_ as the backing storage
304 // for keys in oat_dex_files_ and the string_cache_ entries for the backing storage
305 // of keys in secondary_oat_dex_files_ and oat_dex_files_by_canonical_location_.
Mathieu Chartierbad02672014-08-25 13:08:22 -0700306 typedef AllocationTrackingSafeMap<StringPiece, const OatDexFile*, kAllocatorTagOatFile> Table;
Vladimir Marko3f5838d2014-08-07 18:07:18 +0100307
Vladimir Markoaa4497d2014-09-05 14:01:17 +0100308 // Map each location and canonical location (if different) retrieved from the
309 // oat file to its OatDexFile. This map doesn't change after it's constructed in Setup()
310 // and therefore doesn't need any locking and provides the cheapest dex file lookup
311 // for GetOatDexFile() for a very frequent use case. Never contains a nullptr value.
312 Table oat_dex_files_;
Vladimir Marko3f5838d2014-08-07 18:07:18 +0100313
314 // Lock guarding all members needed for secondary lookup in GetOatDexFile().
315 mutable Mutex secondary_lookup_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
316
317 // If the primary oat_dex_files_ lookup fails, use a secondary map. This map stores
318 // the results of all previous secondary lookups, whether successful (non-null) or
319 // failed (null). If it doesn't contain an entry we need to calculate the canonical
320 // location and use oat_dex_files_by_canonical_location_.
321 mutable Table secondary_oat_dex_files_ GUARDED_BY(secondary_lookup_lock_);
322
Vladimir Marko3f5838d2014-08-07 18:07:18 +0100323 // Cache of strings. Contains the backing storage for keys in the secondary_oat_dex_files_
324 // and the lazily initialized oat_dex_files_by_canonical_location_.
325 // NOTE: We're keeping references to contained strings in form of StringPiece and adding
326 // new strings to the end. The adding of a new element must not touch any previously stored
327 // elements. std::list<> and std::deque<> satisfy this requirement, std::vector<> doesn't.
328 mutable std::list<std::string> string_cache_ GUARDED_BY(secondary_lookup_lock_);
Brian Carlstrome24fa612011-09-29 00:53:55 -0700329
330 friend class OatClass;
Richard Uhler07b3c232015-03-31 15:57:54 -0700331 friend class art::OatDexFile;
Elliott Hughese3c845c2012-02-28 17:23:01 -0800332 friend class OatDumper; // For GetBase and GetLimit
Brian Carlstrome24fa612011-09-29 00:53:55 -0700333 DISALLOW_COPY_AND_ASSIGN(OatFile);
334};
335
Richard Uhler07b3c232015-03-31 15:57:54 -0700336// OatDexFile should be an inner class of OatFile. Unfortunately, C++ doesn't
337// support forward declarations of inner classes, and we want to
338// forward-declare OatDexFile so that we can store an opaque pointer to an
339// OatDexFile in DexFile.
340class OatDexFile FINAL {
341 public:
342 // Opens the DexFile referred to by this OatDexFile from within the containing OatFile.
343 std::unique_ptr<const DexFile> OpenDexFile(std::string* error_msg) const;
344
345 const OatFile* GetOatFile() const {
346 return oat_file_;
347 }
348
349 // Returns the size of the DexFile refered to by this OatDexFile.
350 size_t FileSize() const;
351
352 // Returns original path of DexFile that was the source of this OatDexFile.
353 const std::string& GetDexFileLocation() const {
354 return dex_file_location_;
355 }
356
357 // Returns the canonical location of DexFile that was the source of this OatDexFile.
358 const std::string& GetCanonicalDexFileLocation() const {
359 return canonical_dex_file_location_;
360 }
361
362 // Returns checksum of original DexFile that was the source of this OatDexFile;
363 uint32_t GetDexFileLocationChecksum() const {
364 return dex_file_location_checksum_;
365 }
366
367 // Returns the OatClass for the class specified by the given DexFile class_def_index.
368 OatFile::OatClass GetOatClass(uint16_t class_def_index) const;
369
370 // Returns the offset to the OatClass information. Most callers should use GetOatClass.
371 uint32_t GetOatClassOffset(uint16_t class_def_index) const;
372
373 ~OatDexFile();
374
375 private:
376 OatDexFile(const OatFile* oat_file,
377 const std::string& dex_file_location,
378 const std::string& canonical_dex_file_location,
379 uint32_t dex_file_checksum,
380 const uint8_t* dex_file_pointer,
381 const uint32_t* oat_class_offsets_pointer);
382
383 const OatFile* const oat_file_;
384 const std::string dex_file_location_;
385 const std::string canonical_dex_file_location_;
386 const uint32_t dex_file_location_checksum_;
387 const uint8_t* const dex_file_pointer_;
388 const uint32_t* const oat_class_offsets_pointer_;
389
390 friend class OatFile;
391 DISALLOW_COPY_AND_ASSIGN(OatDexFile);
392};
393
Brian Carlstrome24fa612011-09-29 00:53:55 -0700394} // namespace art
395
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700396#endif // ART_RUNTIME_OAT_FILE_H_