blob: 094467ab07ff9bd22d9badf89cd40a8f626b7f7d [file] [log] [blame]
Logan Chien0f0899a2012-03-23 10:48:18 +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
17#ifndef ART_SRC_ELF_IMAGE_H_
18#define ART_SRC_ELF_IMAGE_H_
19
20#include "globals.h"
Logan Chien08e1ba32012-05-08 15:08:51 +080021#include <string>
Logan Chien799ef4f2012-04-23 00:17:47 +080022#include <vector>
Logan Chien0f0899a2012-03-23 10:48:18 +080023
24namespace art {
25
26class ElfImage {
27 public:
Logan Chien799ef4f2012-04-23 00:17:47 +080028 explicit ElfImage(const std::vector<uint8_t>& v)
29 : begin_(&*v.begin()), size_(v.size()) {
Logan Chien0f0899a2012-03-23 10:48:18 +080030 }
31
Logan Chien08e1ba32012-05-08 15:08:51 +080032 explicit ElfImage(const std::string& s)
33 : begin_(reinterpret_cast<const uint8_t*>(s.data())), size_(s.size()) {
34 }
35
Logan Chien0f0899a2012-03-23 10:48:18 +080036 explicit ElfImage(const byte* begin, size_t size)
37 : begin_(begin), size_(size) {
38 }
39
TDYa1279d93ee62012-05-09 09:56:07 -070040 // TODO: Remove this after implement in-place linking.
41 ElfImage() : begin_(NULL), size_(0) {
42 }
43
Logan Chien0f0899a2012-03-23 10:48:18 +080044 const byte* begin() const {
45 return begin_;
46 }
47
48 const byte* end() const {
49 return (begin_ + size_);
50 }
51
52 size_t size() const {
53 return size_;
54 }
55
56 private:
57 const byte* begin_;
58 size_t size_;
59};
60
61} // namespace art
62
63#endif // ART_SRC_ELF_IMAGE_H_