1c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===- ObjectFile.h - File format independent object file -------*- C++ -*-===//
2c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
3c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//                     The LLVM Compiler Infrastructure
4c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
5c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// This file is distributed under the University of Illinois Open Source
6c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// License. See LICENSE.TXT for details.
7c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
8c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===//
9c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
10c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// This file declares a file format independent ObjectFile class.
11c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
12c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===//
13c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
14c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#ifndef LLVM_OBJECT_OBJECTFILE_H
15c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#define LLVM_OBJECT_OBJECTFILE_H
16c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
17c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/StringRef.h"
18c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/iterator_range.h"
19c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/BinaryFormat/Magic.h"
20c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/MC/SubtargetFeature.h"
21c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Object/Binary.h"
22c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Object/Error.h"
23c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Object/SymbolicFile.h"
24c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/Casting.h"
25c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/Error.h"
26c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/FileSystem.h"
27c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/MemoryBuffer.h"
28c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <cassert>
29c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <cstdint>
30c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <memory>
31c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <system_error>
32c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
33c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace llvm {
34c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
35c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass ARMAttributeParser;
36c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
37c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace object {
38c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
39c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass COFFObjectFile;
40c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MachOObjectFile;
41c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass ObjectFile;
42c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass SectionRef;
43c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass SymbolRef;
44c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass symbol_iterator;
45c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass WasmObjectFile;
46c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
47c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotusing section_iterator = content_iterator<SectionRef>;
48c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
49c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// This is a value type class that represents a single relocation in the list
50c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// of relocations in the object file.
51c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass RelocationRef {
52c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  DataRefImpl RelocationPimpl;
53c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const ObjectFile *OwningObject = nullptr;
54c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
55c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
56c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  RelocationRef() = default;
57c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  RelocationRef(DataRefImpl RelocationP, const ObjectFile *Owner);
58c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
59c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool operator==(const RelocationRef &Other) const;
60c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
61c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void moveNext();
62c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
63c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint64_t getOffset() const;
64c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  symbol_iterator getSymbol() const;
65c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint64_t getType() const;
66c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
67c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @brief Get a string that represents the type of this relocation.
68c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
69c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This is for display purposes only.
70c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void getTypeName(SmallVectorImpl<char> &Result) const;
71c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
72c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  DataRefImpl getRawDataRefImpl() const;
73c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const ObjectFile *getObject() const;
74c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
75c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
76c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotusing relocation_iterator = content_iterator<RelocationRef>;
77c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
78c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// This is a value type class that represents a single section in the list of
79c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// sections in the object file.
80c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass SectionRef {
81c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  friend class SymbolRef;
82c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
83c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  DataRefImpl SectionPimpl;
84c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const ObjectFile *OwningObject = nullptr;
85c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
86c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
87c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SectionRef() = default;
88c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SectionRef(DataRefImpl SectionP, const ObjectFile *Owner);
89c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
90c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool operator==(const SectionRef &Other) const;
91c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool operator!=(const SectionRef &Other) const;
92c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool operator<(const SectionRef &Other) const;
93c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
94c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void moveNext();
95c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
96c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  std::error_code getName(StringRef &Result) const;
97c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint64_t getAddress() const;
98c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint64_t getIndex() const;
99c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint64_t getSize() const;
100c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  std::error_code getContents(StringRef &Result) const;
101c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
102c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @brief Get the alignment of this section as the actual value (not log 2).
103c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint64_t getAlignment() const;
104c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
105c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isCompressed() const;
106c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isText() const;
107c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isData() const;
108c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isBSS() const;
109c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isVirtual() const;
110c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isBitcode() const;
111c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isStripped() const;
112c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
113c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool containsSymbol(SymbolRef S) const;
114c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
115c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  relocation_iterator relocation_begin() const;
116c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  relocation_iterator relocation_end() const;
117c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  iterator_range<relocation_iterator> relocations() const {
118c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return make_range(relocation_begin(), relocation_end());
119c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
120c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  section_iterator getRelocatedSection() const;
121c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
122c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  DataRefImpl getRawDataRefImpl() const;
123c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const ObjectFile *getObject() const;
124c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
125c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
126c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// This is a value type class that represents a single symbol in the list of
127c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// symbols in the object file.
128c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass SymbolRef : public BasicSymbolRef {
129c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  friend class SectionRef;
130c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
131c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
132c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  enum Type {
133c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ST_Unknown, // Type not specified
134c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ST_Data,
135c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ST_Debug,
136c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ST_File,
137c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ST_Function,
138c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ST_Other
139c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
140c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
141c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SymbolRef() = default;
142c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner);
143c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SymbolRef(const BasicSymbolRef &B) : BasicSymbolRef(B) {
144c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(isa<ObjectFile>(BasicSymbolRef::getObject()));
145c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
146c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
147c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  Expected<StringRef> getName() const;
148c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns the symbol virtual address (i.e. address at which it will be
149c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// mapped).
150c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  Expected<uint64_t> getAddress() const;
151c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
152c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the value of the symbol depending on the object this can be an
153c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// offset or a virtual address.
154c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint64_t getValue() const;
155c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
156c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @brief Get the alignment of this symbol as the actual value (not log 2).
157c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint32_t getAlignment() const;
158c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint64_t getCommonSize() const;
159c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  Expected<SymbolRef::Type> getType() const;
160c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
161c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @brief Get section this symbol is defined in reference to. Result is
162c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// end_sections() if it is undefined or is an absolute symbol.
163c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  Expected<section_iterator> getSection() const;
164c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
165c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const ObjectFile *getObject() const;
166c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
167c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
168c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass symbol_iterator : public basic_symbol_iterator {
169c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
170c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  symbol_iterator(SymbolRef Sym) : basic_symbol_iterator(Sym) {}
171c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  symbol_iterator(const basic_symbol_iterator &B)
172c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : basic_symbol_iterator(SymbolRef(B->getRawDataRefImpl(),
173c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                        cast<ObjectFile>(B->getObject()))) {}
174c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
175c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const SymbolRef *operator->() const {
176c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const BasicSymbolRef &P = basic_symbol_iterator::operator *();
177c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return static_cast<const SymbolRef*>(&P);
178c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
179c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
180c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const SymbolRef &operator*() const {
181c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const BasicSymbolRef &P = basic_symbol_iterator::operator *();
182c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return static_cast<const SymbolRef&>(P);
183c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
184c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
185c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
186c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// This class is the base class for all object file types. Concrete instances
187c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// of this object are created by createObjectFile, which figures out which type
188c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// to create.
189c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass ObjectFile : public SymbolicFile {
190c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void anchor();
191c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
192c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprotected:
193c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ObjectFile(unsigned int Type, MemoryBufferRef Source);
194c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
195c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const uint8_t *base() const {
196c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return reinterpret_cast<const uint8_t *>(Data.getBufferStart());
197c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
198c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
199c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // These functions are for SymbolRef to call internally. The main goal of
200c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // this is to allow SymbolRef::SymbolPimpl to point directly to the symbol
201c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // entry in the memory mapped object file. SymbolPimpl cannot contain any
202c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // virtual functions because then it could not point into the memory mapped
203c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // file.
204c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //
205c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Implementations assume that the DataRefImpl is valid and has not been
206c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // modified externally. It's UB otherwise.
207c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  friend class SymbolRef;
208c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
209c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual Expected<StringRef> getSymbolName(DataRefImpl Symb) const = 0;
210c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  std::error_code printSymbolName(raw_ostream &OS,
211c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  DataRefImpl Symb) const override;
212c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const = 0;
213c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const = 0;
214c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const;
215c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const = 0;
216c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const = 0;
217c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual Expected<section_iterator>
218c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  getSymbolSection(DataRefImpl Symb) const = 0;
219c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
220c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Same as above for SectionRef.
221c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  friend class SectionRef;
222c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
223c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void moveSectionNext(DataRefImpl &Sec) const = 0;
224c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual std::error_code getSectionName(DataRefImpl Sec,
225c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                         StringRef &Res) const = 0;
226c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual uint64_t getSectionAddress(DataRefImpl Sec) const = 0;
227c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual uint64_t getSectionIndex(DataRefImpl Sec) const = 0;
228c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual uint64_t getSectionSize(DataRefImpl Sec) const = 0;
229c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual std::error_code getSectionContents(DataRefImpl Sec,
230c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                             StringRef &Res) const = 0;
231c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual uint64_t getSectionAlignment(DataRefImpl Sec) const = 0;
232c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isSectionCompressed(DataRefImpl Sec) const = 0;
233c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isSectionText(DataRefImpl Sec) const = 0;
234c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isSectionData(DataRefImpl Sec) const = 0;
235c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isSectionBSS(DataRefImpl Sec) const = 0;
236c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // A section is 'virtual' if its contents aren't present in the object image.
237c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isSectionVirtual(DataRefImpl Sec) const = 0;
238c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isSectionBitcode(DataRefImpl Sec) const;
239c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isSectionStripped(DataRefImpl Sec) const;
240c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const = 0;
241c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual relocation_iterator section_rel_end(DataRefImpl Sec) const = 0;
242c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual section_iterator getRelocatedSection(DataRefImpl Sec) const;
243c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
244c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Same as above for RelocationRef.
245c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  friend class RelocationRef;
246c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void moveRelocationNext(DataRefImpl &Rel) const = 0;
247c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual uint64_t getRelocationOffset(DataRefImpl Rel) const = 0;
248c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const = 0;
249c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual uint64_t getRelocationType(DataRefImpl Rel) const = 0;
250c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void getRelocationTypeName(DataRefImpl Rel,
251c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                     SmallVectorImpl<char> &Result) const = 0;
252c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
253c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint64_t getSymbolValue(DataRefImpl Symb) const;
254c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
255c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
256c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ObjectFile() = delete;
257c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ObjectFile(const ObjectFile &other) = delete;
258c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
259c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint64_t getCommonSymbolSize(DataRefImpl Symb) const {
260c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(getSymbolFlags(Symb) & SymbolRef::SF_Common);
261c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return getCommonSymbolSizeImpl(Symb);
262c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
263c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
264c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  using symbol_iterator_range = iterator_range<symbol_iterator>;
265c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  symbol_iterator_range symbols() const {
266c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return symbol_iterator_range(symbol_begin(), symbol_end());
267c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
268c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
269c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual section_iterator section_begin() const = 0;
270c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual section_iterator section_end() const = 0;
271c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
272c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  using section_iterator_range = iterator_range<section_iterator>;
273c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  section_iterator_range sections() const {
274c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return section_iterator_range(section_begin(), section_end());
275c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
276c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
277c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @brief The number of bytes used to represent an address in this object
278c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///        file format.
279c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual uint8_t getBytesInAddress() const = 0;
280c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
281c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual StringRef getFileFormatName() const = 0;
282c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual /* Triple::ArchType */ unsigned getArch() const = 0;
283c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual SubtargetFeatures getFeatures() const = 0;
284c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void setARMSubArch(Triple &TheTriple) const { }
285c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
286c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @brief Create a triple from the data in this object file.
287c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  Triple makeTriple() const;
288c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
289c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns platform-specific object flags, if any.
290c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual std::error_code getPlatformFlags(unsigned &Result) const {
291c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Result = 0;
292c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return object_error::invalid_file_type;
293c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
294c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
295c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual std::error_code
296c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    getBuildAttributes(ARMAttributeParser &Attributes) const {
297c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return std::error_code();
298c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
299c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
300c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Maps a debug section name to a standard DWARF section name.
301c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual StringRef mapDebugSectionName(StringRef Name) const { return Name; }
302c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
303c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// True if this is a relocatable object (.o/.obj).
304c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isRelocatableObject() const = 0;
305c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
306c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @returns Pointer to ObjectFile subclass to handle this type of object.
307c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @param ObjectPath The path to the object file. ObjectPath.isObject must
308c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///        return true.
309c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @brief Create ObjectFile from path.
310c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static Expected<OwningBinary<ObjectFile>>
311c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  createObjectFile(StringRef ObjectPath);
312c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
313c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static Expected<std::unique_ptr<ObjectFile>>
314c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  createObjectFile(MemoryBufferRef Object, llvm::file_magic Type);
315c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static Expected<std::unique_ptr<ObjectFile>>
316c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  createObjectFile(MemoryBufferRef Object) {
317c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return createObjectFile(Object, llvm::file_magic::unknown);
318c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
319c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
320c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const Binary *v) {
321c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return v->isObject();
322c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
323c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
324c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static Expected<std::unique_ptr<COFFObjectFile>>
325c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  createCOFFObjectFile(MemoryBufferRef Object);
326c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
327c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static Expected<std::unique_ptr<ObjectFile>>
328c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  createELFObjectFile(MemoryBufferRef Object);
329c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
330c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static Expected<std::unique_ptr<MachOObjectFile>>
331c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  createMachOObjectFile(MemoryBufferRef Object,
332c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                        uint32_t UniversalCputype = 0,
333c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                        uint32_t UniversalIndex = 0);
334c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
335c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static Expected<std::unique_ptr<WasmObjectFile>>
336c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  createWasmObjectFile(MemoryBufferRef Object);
337c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
338c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
339c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// Inline function definitions.
340c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline SymbolRef::SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner)
341c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    : BasicSymbolRef(SymbolP, Owner) {}
342c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
343c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline Expected<StringRef> SymbolRef::getName() const {
344c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return getObject()->getSymbolName(getRawDataRefImpl());
345c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
346c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
347c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline Expected<uint64_t> SymbolRef::getAddress() const {
348c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return getObject()->getSymbolAddress(getRawDataRefImpl());
349c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
350c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
351c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline uint64_t SymbolRef::getValue() const {
352c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return getObject()->getSymbolValue(getRawDataRefImpl());
353c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
354c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
355c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline uint32_t SymbolRef::getAlignment() const {
356c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return getObject()->getSymbolAlignment(getRawDataRefImpl());
357c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
358c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
359c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline uint64_t SymbolRef::getCommonSize() const {
360c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return getObject()->getCommonSymbolSize(getRawDataRefImpl());
361c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
362c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
363c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline Expected<section_iterator> SymbolRef::getSection() const {
364c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return getObject()->getSymbolSection(getRawDataRefImpl());
365c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
366c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
367c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline Expected<SymbolRef::Type> SymbolRef::getType() const {
368c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return getObject()->getSymbolType(getRawDataRefImpl());
369c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
370c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
371c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline const ObjectFile *SymbolRef::getObject() const {
372c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const SymbolicFile *O = BasicSymbolRef::getObject();
373c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return cast<ObjectFile>(O);
374c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
375c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
376c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// SectionRef
377c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline SectionRef::SectionRef(DataRefImpl SectionP,
378c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              const ObjectFile *Owner)
379c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  : SectionPimpl(SectionP)
380c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  , OwningObject(Owner) {}
381c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
382c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline bool SectionRef::operator==(const SectionRef &Other) const {
383c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return SectionPimpl == Other.SectionPimpl;
384c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
385c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
386c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline bool SectionRef::operator!=(const SectionRef &Other) const {
387c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return SectionPimpl != Other.SectionPimpl;
388c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
389c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
390c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline bool SectionRef::operator<(const SectionRef &Other) const {
391c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return SectionPimpl < Other.SectionPimpl;
392c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
393c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
394c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline void SectionRef::moveNext() {
395c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->moveSectionNext(SectionPimpl);
396c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
397c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
398c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline std::error_code SectionRef::getName(StringRef &Result) const {
399c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->getSectionName(SectionPimpl, Result);
400c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
401c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
402c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline uint64_t SectionRef::getAddress() const {
403c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->getSectionAddress(SectionPimpl);
404c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
405c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
406c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline uint64_t SectionRef::getIndex() const {
407c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->getSectionIndex(SectionPimpl);
408c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
409c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
410c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline uint64_t SectionRef::getSize() const {
411c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->getSectionSize(SectionPimpl);
412c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
413c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
414c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline std::error_code SectionRef::getContents(StringRef &Result) const {
415c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->getSectionContents(SectionPimpl, Result);
416c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
417c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
418c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline uint64_t SectionRef::getAlignment() const {
419c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->getSectionAlignment(SectionPimpl);
420c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
421c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
422c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline bool SectionRef::isCompressed() const {
423c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->isSectionCompressed(SectionPimpl);
424c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
425c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
426c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline bool SectionRef::isText() const {
427c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->isSectionText(SectionPimpl);
428c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
429c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
430c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline bool SectionRef::isData() const {
431c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->isSectionData(SectionPimpl);
432c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
433c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
434c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline bool SectionRef::isBSS() const {
435c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->isSectionBSS(SectionPimpl);
436c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
437c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
438c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline bool SectionRef::isVirtual() const {
439c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->isSectionVirtual(SectionPimpl);
440c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
441c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
442c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline bool SectionRef::isBitcode() const {
443c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->isSectionBitcode(SectionPimpl);
444c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
445c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
446c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline bool SectionRef::isStripped() const {
447c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->isSectionStripped(SectionPimpl);
448c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
449c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
450c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline relocation_iterator SectionRef::relocation_begin() const {
451c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->section_rel_begin(SectionPimpl);
452c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
453c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
454c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline relocation_iterator SectionRef::relocation_end() const {
455c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->section_rel_end(SectionPimpl);
456c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
457c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
458c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline section_iterator SectionRef::getRelocatedSection() const {
459c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->getRelocatedSection(SectionPimpl);
460c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
461c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
462c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline DataRefImpl SectionRef::getRawDataRefImpl() const {
463c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return SectionPimpl;
464c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
465c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
466c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline const ObjectFile *SectionRef::getObject() const {
467c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject;
468c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
469c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
470c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// RelocationRef
471c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline RelocationRef::RelocationRef(DataRefImpl RelocationP,
472c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              const ObjectFile *Owner)
473c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  : RelocationPimpl(RelocationP)
474c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  , OwningObject(Owner) {}
475c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
476c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline bool RelocationRef::operator==(const RelocationRef &Other) const {
477c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return RelocationPimpl == Other.RelocationPimpl;
478c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
479c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
480c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline void RelocationRef::moveNext() {
481c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->moveRelocationNext(RelocationPimpl);
482c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
483c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
484c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline uint64_t RelocationRef::getOffset() const {
485c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->getRelocationOffset(RelocationPimpl);
486c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
487c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
488c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline symbol_iterator RelocationRef::getSymbol() const {
489c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->getRelocationSymbol(RelocationPimpl);
490c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
491c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
492c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline uint64_t RelocationRef::getType() const {
493c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->getRelocationType(RelocationPimpl);
494c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
495c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
496c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline void RelocationRef::getTypeName(SmallVectorImpl<char> &Result) const {
497c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject->getRelocationTypeName(RelocationPimpl, Result);
498c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
499c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
500c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline DataRefImpl RelocationRef::getRawDataRefImpl() const {
501c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return RelocationPimpl;
502c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
503c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
504c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotinline const ObjectFile *RelocationRef::getObject() const {
505c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  return OwningObject;
506c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}
507c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
508c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} // end namespace object
509c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
510c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} // end namespace llvm
511c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
512c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#endif // LLVM_OBJECT_OBJECTFILE_H
513