blob: dbd75415a400f97646dbb543e2da6818b716bb25 [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"
Nicolas Geoffray6bc43742015-10-12 18:11:10 +010032#include "utils.h"
Brian Carlstrome24fa612011-09-29 00:53:55 -070033
34namespace art {
35
Brian Carlstromba150c32013-08-27 17:31:03 -070036class BitVector;
Brian Carlstrom700c8d32012-11-05 10:42:02 -080037class ElfFile;
38class MemMap;
39class OatMethodOffsets;
Ian Rogers33e95662013-05-20 20:29:14 -070040class OatHeader;
Richard Uhler07b3c232015-03-31 15:57:54 -070041class OatDexFile;
Brian Carlstrom700c8d32012-11-05 10:42:02 -080042
Andreas Gampe049cff02015-12-01 23:27:12 -080043class OatFile {
Brian Carlstrome24fa612011-09-29 00:53:55 -070044 public:
Richard Uhler07b3c232015-03-31 15:57:54 -070045 typedef art::OatDexFile OatDexFile;
46
Alex Light84d76052014-08-22 17:49:35 -070047 // Opens an oat file contained within the given elf file. This is always opened as
48 // non-executable at the moment.
Igor Murashkinb1d8c312015-08-04 11:18:43 -070049 static OatFile* OpenWithElfFile(ElfFile* elf_file, const std::string& location,
Richard Uhlere5fed032015-03-18 08:21:11 -070050 const char* abs_dex_location,
Igor Murashkinb1d8c312015-08-04 11:18:43 -070051 std::string* error_msg);
Mathieu Chartier2cebb242015-04-21 16:50:40 -070052 // Open an oat file. Returns null on failure. Requested base can
Brian Carlstrome24fa612011-09-29 00:53:55 -070053 // optionally be used to request where the file should be loaded.
Richard Uhlere5fed032015-03-18 08:21:11 -070054 // See the ResolveRelativeEncodedDexLocation for a description of how the
55 // abs_dex_location argument is used.
Brian Carlstrome24fa612011-09-29 00:53:55 -070056 static OatFile* Open(const std::string& filename,
Brian Carlstroma004aa92012-02-08 18:05:09 -080057 const std::string& location,
Ian Rogers13735952014-10-08 12:43:28 -070058 uint8_t* requested_base,
Igor Murashkin46774762014-10-22 11:37:02 -070059 uint8_t* oat_file_begin,
Ian Rogers8d31bbd2013-10-13 10:44:14 -070060 bool executable,
Richard Uhlere5fed032015-03-18 08:21:11 -070061 const char* abs_dex_location,
Igor Murashkinb1d8c312015-08-04 11:18:43 -070062 std::string* error_msg);
Brian Carlstrome24fa612011-09-29 00:53:55 -070063
Brian Carlstrom700c8d32012-11-05 10:42:02 -080064 // Open an oat file from an already opened File.
Brian Carlstrom265091e2013-01-30 14:08:26 -080065 // Does not use dlopen underneath so cannot be used for runtime use
66 // where relocations may be required. Currently used from
67 // ImageWriter which wants to open a writable version from an existing
68 // file descriptor for patching.
Igor Murashkinb1d8c312015-08-04 11:18:43 -070069 static OatFile* OpenWritable(File* file, const std::string& location,
Richard Uhlere5fed032015-03-18 08:21:11 -070070 const char* abs_dex_location,
Igor Murashkinb1d8c312015-08-04 11:18:43 -070071 std::string* error_msg);
Alex Lighta59dd802014-07-02 16:28:08 -070072 // Opens an oat file from an already opened File. Maps it PROT_READ, MAP_PRIVATE.
Igor Murashkinb1d8c312015-08-04 11:18:43 -070073 static OatFile* OpenReadable(File* file, const std::string& location,
Richard Uhlere5fed032015-03-18 08:21:11 -070074 const char* abs_dex_location,
Igor Murashkinb1d8c312015-08-04 11:18:43 -070075 std::string* error_msg);
Brian Carlstrom700c8d32012-11-05 10:42:02 -080076
Andreas Gampe049cff02015-12-01 23:27:12 -080077 virtual ~OatFile();
Brian Carlstrome24fa612011-09-29 00:53:55 -070078
Alex Light9dcc4572014-08-14 14:16:26 -070079 bool IsExecutable() const {
80 return is_executable_;
81 }
82
Andreas Gampe7ba64962014-10-23 11:37:40 -070083 bool IsPic() const;
84
Sebastien Hertz0de11332015-05-13 12:14:05 +020085 // Indicates whether the oat file was compiled with full debugging capability.
86 bool IsDebuggable() const;
87
Brian Carlstrome24fa612011-09-29 00:53:55 -070088 const std::string& GetLocation() const {
89 return location_;
90 }
91
92 const OatHeader& GetOatHeader() const;
93
Richard Uhler07b3c232015-03-31 15:57:54 -070094 class OatMethod FINAL {
Brian Carlstrom3320cf42011-10-04 14:58:28 -070095 public:
Mathieu Chartiere401d142015-04-22 13:56:20 -070096 void LinkMethod(ArtMethod* method) const;
Brian Carlstromae826982011-11-09 01:33:42 -080097
Nicolas Geoffrayc04c8002015-07-14 11:37:54 +010098 uint32_t GetCodeOffset() const;
Brian Carlstromae826982011-11-09 01:33:42 -080099
Nicolas Geoffrayc04c8002015-07-14 11:37:54 +0100100 const void* GetQuickCode() const;
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700101
102 // Returns size of quick code.
Ian Rogersef7d42f2014-01-06 12:55:46 -0800103 uint32_t GetQuickCodeSize() const;
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700104 uint32_t GetQuickCodeSizeOffset() const;
105
106 // Returns OatQuickMethodHeader for debugging. Most callers should
107 // use more specific methods such as GetQuickCodeSize.
108 const OatQuickMethodHeader* GetOatQuickMethodHeader() const;
109 uint32_t GetOatQuickMethodHeaderOffset() const;
Logan Chien0c717dd2012-03-28 18:31:07 +0800110
Vladimir Marko7624d252014-05-02 14:40:15 +0100111 size_t GetFrameSizeInBytes() const;
112 uint32_t GetCoreSpillMask() const;
113 uint32_t GetFpSpillMask() const;
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700114
Vladimir Marko8a630572014-04-09 18:45:35 +0100115 const uint8_t* GetMappingTable() const;
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700116 uint32_t GetMappingTableOffset() const;
117 uint32_t GetMappingTableOffsetOffset() const;
118
Vladimir Marko8a630572014-04-09 18:45:35 +0100119 const uint8_t* GetVmapTable() const;
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700120 uint32_t GetVmapTableOffset() const;
121 uint32_t GetVmapTableOffsetOffset() const;
Vladimir Marko8a630572014-04-09 18:45:35 +0100122
Mathieu Chartier957ca1c2014-11-21 16:51:29 -0800123 const uint8_t* GetGcMap() const;
124 uint32_t GetGcMapOffset() const;
125 uint32_t GetGcMapOffsetOffset() const;
126
Brian Carlstromae826982011-11-09 01:33:42 -0800127 // Create an OatMethod with offsets relative to the given base address
Mathieu Chartier957ca1c2014-11-21 16:51:29 -0800128 OatMethod(const uint8_t* base, const uint32_t code_offset)
129 : begin_(base), code_offset_(code_offset) {
Ian Rogers97b52f82014-08-14 11:34:07 -0700130 }
Andreas Gampe758a8012015-04-03 21:28:42 -0700131 OatMethod(const OatMethod&) = default;
Ian Rogers97b52f82014-08-14 11:34:07 -0700132 ~OatMethod() {}
Brian Carlstrom3320cf42011-10-04 14:58:28 -0700133
Andreas Gampe758a8012015-04-03 21:28:42 -0700134 OatMethod& operator=(const OatMethod&) = default;
135
Ian Rogers97b52f82014-08-14 11:34:07 -0700136 // A representation of an invalid OatMethod, used when an OatMethod or OatClass can't be found.
137 // See ClassLinker::FindOatMethodFor.
138 static const OatMethod Invalid() {
Mathieu Chartier957ca1c2014-11-21 16:51:29 -0800139 return OatMethod(nullptr, -1);
Ian Rogers97b52f82014-08-14 11:34:07 -0700140 }
Nicolas Geoffray4fcdc942014-07-22 10:48:00 +0100141
Brian Carlstromae826982011-11-09 01:33:42 -0800142 private:
143 template<class T>
144 T GetOatPointer(uint32_t offset) const {
145 if (offset == 0) {
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700146 return nullptr;
Brian Carlstromae826982011-11-09 01:33:42 -0800147 }
Ian Rogers30fab402012-01-23 15:43:46 -0800148 return reinterpret_cast<T>(begin_ + offset);
Brian Carlstromae826982011-11-09 01:33:42 -0800149 }
150
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800151 const uint8_t* begin_;
152 uint32_t code_offset_;
Brian Carlstromae826982011-11-09 01:33:42 -0800153
154 friend class OatClass;
Brian Carlstrom3320cf42011-10-04 14:58:28 -0700155 };
156
Richard Uhler07b3c232015-03-31 15:57:54 -0700157 class OatClass FINAL {
Brian Carlstrome24fa612011-09-29 00:53:55 -0700158 public:
Brian Carlstromba150c32013-08-27 17:31:03 -0700159 mirror::Class::Status GetStatus() const {
160 return status_;
161 }
162
163 OatClassType GetType() const {
164 return type_;
165 }
Brian Carlstrom0755ec52012-01-11 15:19:46 -0800166
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700167 // Get the OatMethod entry based on its index into the class
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700168 // defintion. Direct methods come first, followed by virtual
169 // methods. Note that runtime created methods such as miranda
Brian Carlstrome24fa612011-09-29 00:53:55 -0700170 // methods are not included.
Brian Carlstromaded5f72011-10-07 17:15:04 -0700171 const OatMethod GetOatMethod(uint32_t method_index) const;
Brian Carlstrome24fa612011-09-29 00:53:55 -0700172
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700173 // Return a pointer to the OatMethodOffsets for the requested
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700174 // method_index, or null if none is present. Note that most
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700175 // callers should use GetOatMethod.
176 const OatMethodOffsets* GetOatMethodOffsets(uint32_t method_index) const;
177
178 // Return the offset from the start of the OatFile to the
179 // OatMethodOffsets for the requested method_index, or 0 if none
180 // is present. Note that most callers should use GetOatMethod.
181 uint32_t GetOatMethodOffsetsOffset(uint32_t method_index) const;
182
Ian Rogers97b52f82014-08-14 11:34:07 -0700183 // A representation of an invalid OatClass, used when an OatClass can't be found.
184 // See ClassLinker::FindOatClass.
185 static OatClass Invalid() {
186 return OatClass(nullptr, mirror::Class::kStatusError, kOatClassNoneCompiled, 0, nullptr,
187 nullptr);
188 }
Nicolas Geoffray4fcdc942014-07-22 10:48:00 +0100189
Brian Carlstrome24fa612011-09-29 00:53:55 -0700190 private:
Brian Carlstrom0755ec52012-01-11 15:19:46 -0800191 OatClass(const OatFile* oat_file,
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800192 mirror::Class::Status status,
Brian Carlstromba150c32013-08-27 17:31:03 -0700193 OatClassType type,
194 uint32_t bitmap_size,
195 const uint32_t* bitmap_pointer,
Brian Carlstrom0755ec52012-01-11 15:19:46 -0800196 const OatMethodOffsets* methods_pointer);
Brian Carlstrom3320cf42011-10-04 14:58:28 -0700197
Ian Rogers97b52f82014-08-14 11:34:07 -0700198 const OatFile* const oat_file_;
Brian Carlstromba150c32013-08-27 17:31:03 -0700199
Ian Rogers97b52f82014-08-14 11:34:07 -0700200 const mirror::Class::Status status_;
Brian Carlstromba150c32013-08-27 17:31:03 -0700201
Ian Rogers97b52f82014-08-14 11:34:07 -0700202 const OatClassType type_;
Brian Carlstromba150c32013-08-27 17:31:03 -0700203
Ian Rogers97b52f82014-08-14 11:34:07 -0700204 const uint32_t* const bitmap_;
Brian Carlstromba150c32013-08-27 17:31:03 -0700205
Ian Rogers97b52f82014-08-14 11:34:07 -0700206 const OatMethodOffsets* const methods_pointer_;
Brian Carlstrome24fa612011-09-29 00:53:55 -0700207
Richard Uhler07b3c232015-03-31 15:57:54 -0700208 friend class art::OatDexFile;
Brian Carlstrome24fa612011-09-29 00:53:55 -0700209 };
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700210 const OatDexFile* GetOatDexFile(const char* dex_location,
Brian Carlstrom756ee4e2013-10-03 15:46:12 -0700211 const uint32_t* const dex_location_checksum,
Vladimir Marko3f5838d2014-08-07 18:07:18 +0100212 bool exception_if_not_found = true) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700213 REQUIRES(!secondary_lookup_lock_);
Ian Rogers8d31bbd2013-10-13 10:44:14 -0700214
Vladimir Markoaa4497d2014-09-05 14:01:17 +0100215 const std::vector<const OatDexFile*>& GetOatDexFiles() const {
216 return oat_dex_files_storage_;
217 }
Brian Carlstrome24fa612011-09-29 00:53:55 -0700218
Ian Rogers30fab402012-01-23 15:43:46 -0800219 size_t Size() const {
220 return End() - Begin();
Brian Carlstrome24fa612011-09-29 00:53:55 -0700221 }
222
Vladimir Marko5c42c292015-02-25 12:02:49 +0000223 size_t BssSize() const {
224 return BssEnd() - BssBegin();
225 }
226
Ian Rogers13735952014-10-08 12:43:28 -0700227 const uint8_t* Begin() const;
228 const uint8_t* End() const;
Alex Light53cb16b2014-06-12 11:26:29 -0700229
Vladimir Marko5c42c292015-02-25 12:02:49 +0000230 const uint8_t* BssBegin() const;
231 const uint8_t* BssEnd() const;
232
Richard Uhlere5fed032015-03-18 08:21:11 -0700233 // Returns the absolute dex location for the encoded relative dex location.
234 //
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700235 // If not null, abs_dex_location is used to resolve the absolute dex
Richard Uhlere5fed032015-03-18 08:21:11 -0700236 // location of relative dex locations encoded in the oat file.
237 // For example, given absolute location "/data/app/foo/base.apk", encoded
238 // dex locations "base.apk", "base.apk:classes2.dex", etc. would be resolved
239 // to "/data/app/foo/base.apk", "/data/app/foo/base.apk:classes2.dex", etc.
240 // Relative encoded dex locations that don't match the given abs_dex_location
241 // are left unchanged.
242 static std::string ResolveRelativeEncodedDexLocation(
243 const char* abs_dex_location, const std::string& rel_dex_location);
244
Andreas Gampe7848da42015-04-09 11:15:04 -0700245 // Create a dependency list (dex locations and checksums) for the given dex files.
246 static std::string EncodeDexFileDependencies(const std::vector<const DexFile*>& dex_files);
247
248 // Check the given dependency list against their dex files - thus the name "Static," this does
249 // not check the class-loader environment, only whether there have been file updates.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700250 static bool CheckStaticDexFileDependencies(const char* dex_dependencies, std::string* msg);
Andreas Gampe7848da42015-04-09 11:15:04 -0700251
252 // Get the dex locations of a dependency list. Note: this is *not* cleaned for synthetic
253 // locations of multidex files.
254 static bool GetDexLocationsFromDependencies(const char* dex_dependencies,
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700255 std::vector<std::string>* locations);
Andreas Gampe7848da42015-04-09 11:15:04 -0700256
Andreas Gampe049cff02015-12-01 23:27:12 -0800257 protected:
258 OatFile(const std::string& filename, bool executable);
259
Brian Carlstrome24fa612011-09-29 00:53:55 -0700260 private:
Brian Carlstrome24fa612011-09-29 00:53:55 -0700261 // The oat file name.
262 //
263 // The image will embed this to link its associated oat file.
264 const std::string location_;
265
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800266 // Pointer to OatHeader.
Ian Rogers13735952014-10-08 12:43:28 -0700267 const uint8_t* begin_;
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800268
269 // Pointer to end of oat region for bounds checking.
Ian Rogers13735952014-10-08 12:43:28 -0700270 const uint8_t* end_;
Brian Carlstrom700c8d32012-11-05 10:42:02 -0800271
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700272 // Pointer to the .bss section, if present, otherwise null.
Vladimir Marko06d7aaa2015-10-16 11:23:41 +0100273 uint8_t* bss_begin_;
Vladimir Marko5c42c292015-02-25 12:02:49 +0000274
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700275 // Pointer to the end of the .bss section, if present, otherwise null.
Vladimir Marko06d7aaa2015-10-16 11:23:41 +0100276 uint8_t* bss_end_;
Vladimir Marko5c42c292015-02-25 12:02:49 +0000277
Alex Light9dcc4572014-08-14 14:16:26 -0700278 // Was this oat_file loaded executable?
279 const bool is_executable_;
280
Vladimir Markoaa4497d2014-09-05 14:01:17 +0100281 // Owning storage for the OatDexFile objects.
282 std::vector<const OatDexFile*> oat_dex_files_storage_;
283
Vladimir Marko3f5838d2014-08-07 18:07:18 +0100284 // NOTE: We use a StringPiece as the key type to avoid a memory allocation on every
285 // lookup with a const char* key. The StringPiece doesn't own its backing storage,
286 // therefore we're using the OatDexFile::dex_file_location_ as the backing storage
287 // for keys in oat_dex_files_ and the string_cache_ entries for the backing storage
288 // of keys in secondary_oat_dex_files_ and oat_dex_files_by_canonical_location_.
Mathieu Chartierbad02672014-08-25 13:08:22 -0700289 typedef AllocationTrackingSafeMap<StringPiece, const OatDexFile*, kAllocatorTagOatFile> Table;
Vladimir Marko3f5838d2014-08-07 18:07:18 +0100290
Vladimir Markoaa4497d2014-09-05 14:01:17 +0100291 // Map each location and canonical location (if different) retrieved from the
292 // oat file to its OatDexFile. This map doesn't change after it's constructed in Setup()
293 // and therefore doesn't need any locking and provides the cheapest dex file lookup
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700294 // for GetOatDexFile() for a very frequent use case. Never contains a null value.
Vladimir Markoaa4497d2014-09-05 14:01:17 +0100295 Table oat_dex_files_;
Vladimir Marko3f5838d2014-08-07 18:07:18 +0100296
297 // Lock guarding all members needed for secondary lookup in GetOatDexFile().
298 mutable Mutex secondary_lookup_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
299
300 // If the primary oat_dex_files_ lookup fails, use a secondary map. This map stores
301 // the results of all previous secondary lookups, whether successful (non-null) or
302 // failed (null). If it doesn't contain an entry we need to calculate the canonical
303 // location and use oat_dex_files_by_canonical_location_.
304 mutable Table secondary_oat_dex_files_ GUARDED_BY(secondary_lookup_lock_);
305
Vladimir Marko3f5838d2014-08-07 18:07:18 +0100306 // Cache of strings. Contains the backing storage for keys in the secondary_oat_dex_files_
307 // and the lazily initialized oat_dex_files_by_canonical_location_.
308 // NOTE: We're keeping references to contained strings in form of StringPiece and adding
309 // new strings to the end. The adding of a new element must not touch any previously stored
310 // elements. std::list<> and std::deque<> satisfy this requirement, std::vector<> doesn't.
311 mutable std::list<std::string> string_cache_ GUARDED_BY(secondary_lookup_lock_);
Brian Carlstrome24fa612011-09-29 00:53:55 -0700312
313 friend class OatClass;
Richard Uhler07b3c232015-03-31 15:57:54 -0700314 friend class art::OatDexFile;
Elliott Hughese3c845c2012-02-28 17:23:01 -0800315 friend class OatDumper; // For GetBase and GetLimit
Andreas Gampe049cff02015-12-01 23:27:12 -0800316 friend class OatFileBase;
Brian Carlstrome24fa612011-09-29 00:53:55 -0700317 DISALLOW_COPY_AND_ASSIGN(OatFile);
318};
319
Richard Uhler07b3c232015-03-31 15:57:54 -0700320// OatDexFile should be an inner class of OatFile. Unfortunately, C++ doesn't
321// support forward declarations of inner classes, and we want to
322// forward-declare OatDexFile so that we can store an opaque pointer to an
323// OatDexFile in DexFile.
324class OatDexFile FINAL {
325 public:
326 // Opens the DexFile referred to by this OatDexFile from within the containing OatFile.
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700327 std::unique_ptr<const DexFile> OpenDexFile(std::string* error_msg) const;
Richard Uhler07b3c232015-03-31 15:57:54 -0700328
329 const OatFile* GetOatFile() const {
330 return oat_file_;
331 }
332
333 // Returns the size of the DexFile refered to by this OatDexFile.
334 size_t FileSize() const;
335
336 // Returns original path of DexFile that was the source of this OatDexFile.
337 const std::string& GetDexFileLocation() const {
338 return dex_file_location_;
339 }
340
341 // Returns the canonical location of DexFile that was the source of this OatDexFile.
342 const std::string& GetCanonicalDexFileLocation() const {
343 return canonical_dex_file_location_;
344 }
345
346 // Returns checksum of original DexFile that was the source of this OatDexFile;
347 uint32_t GetDexFileLocationChecksum() const {
348 return dex_file_location_checksum_;
349 }
350
351 // Returns the OatClass for the class specified by the given DexFile class_def_index.
352 OatFile::OatClass GetOatClass(uint16_t class_def_index) const;
353
354 // Returns the offset to the OatClass information. Most callers should use GetOatClass.
355 uint32_t GetOatClassOffset(uint16_t class_def_index) const;
356
Vladimir Marko06d7aaa2015-10-16 11:23:41 +0100357 uint8_t* GetDexCacheArrays() const {
Vladimir Marko09d09432015-09-08 13:47:48 +0100358 return dex_cache_arrays_;
359 }
360
Artem Udovichenkod9786b02015-10-14 16:36:55 +0300361 const uint8_t* GetLookupTableData() const {
362 return lookup_table_data_;
363 }
364
Richard Uhler07b3c232015-03-31 15:57:54 -0700365 ~OatDexFile();
366
367 private:
368 OatDexFile(const OatFile* oat_file,
369 const std::string& dex_file_location,
370 const std::string& canonical_dex_file_location,
371 uint32_t dex_file_checksum,
372 const uint8_t* dex_file_pointer,
Artem Udovichenkod9786b02015-10-14 16:36:55 +0300373 const uint8_t* lookup_table_data,
Vladimir Marko09d09432015-09-08 13:47:48 +0100374 const uint32_t* oat_class_offsets_pointer,
Vladimir Marko06d7aaa2015-10-16 11:23:41 +0100375 uint8_t* dex_cache_arrays);
Richard Uhler07b3c232015-03-31 15:57:54 -0700376
377 const OatFile* const oat_file_;
378 const std::string dex_file_location_;
379 const std::string canonical_dex_file_location_;
380 const uint32_t dex_file_location_checksum_;
381 const uint8_t* const dex_file_pointer_;
Artem Udovichenkod9786b02015-10-14 16:36:55 +0300382 const uint8_t* lookup_table_data_;
Richard Uhler07b3c232015-03-31 15:57:54 -0700383 const uint32_t* const oat_class_offsets_pointer_;
Vladimir Marko06d7aaa2015-10-16 11:23:41 +0100384 uint8_t* const dex_cache_arrays_;
Richard Uhler07b3c232015-03-31 15:57:54 -0700385
386 friend class OatFile;
Andreas Gampe049cff02015-12-01 23:27:12 -0800387 friend class OatFileBase;
Richard Uhler07b3c232015-03-31 15:57:54 -0700388 DISALLOW_COPY_AND_ASSIGN(OatDexFile);
389};
390
Brian Carlstrome24fa612011-09-29 00:53:55 -0700391} // namespace art
392
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700393#endif // ART_RUNTIME_OAT_FILE_H_