2010-11-15 03:21:41 +00:00
|
|
|
//===- ObjectFile.h - File format independent object file -------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares a file format independent ObjectFile class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-01-10 00:45:19 +00:00
|
|
|
#ifndef LLVM_OBJECT_OBJECTFILE_H
|
|
|
|
#define LLVM_OBJECT_OBJECTFILE_H
|
2010-11-15 03:21:41 +00:00
|
|
|
|
2010-11-16 01:06:51 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2014-02-21 20:10:59 +00:00
|
|
|
#include "llvm/Object/SymbolicFile.h"
|
2010-11-29 18:16:10 +00:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
2011-06-25 17:55:23 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2014-01-22 16:04:52 +00:00
|
|
|
#include "llvm/Support/FileSystem.h"
|
2011-06-25 17:54:50 +00:00
|
|
|
#include "llvm/Support/MemoryBuffer.h"
|
2011-01-21 02:27:02 +00:00
|
|
|
#include <cstring>
|
2012-01-22 09:01:03 +00:00
|
|
|
#include <vector>
|
2010-11-15 03:21:41 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace object {
|
|
|
|
|
|
|
|
class ObjectFile;
|
2014-07-31 03:12:45 +00:00
|
|
|
class COFFObjectFile;
|
|
|
|
class MachOObjectFile;
|
2011-01-21 02:27:02 +00:00
|
|
|
|
2011-10-17 23:54:46 +00:00
|
|
|
class SymbolRef;
|
2014-02-21 20:10:59 +00:00
|
|
|
class symbol_iterator;
|
2015-05-21 21:24:32 +00:00
|
|
|
class SectionRef;
|
|
|
|
typedef content_iterator<SectionRef> section_iterator;
|
2010-11-15 03:21:41 +00:00
|
|
|
|
2011-09-08 20:52:17 +00:00
|
|
|
/// RelocationRef - This is a value type class that represents a single
|
|
|
|
/// relocation in the list of relocations in the object file.
|
|
|
|
class RelocationRef {
|
|
|
|
DataRefImpl RelocationPimpl;
|
|
|
|
const ObjectFile *OwningObject;
|
|
|
|
|
|
|
|
public:
|
2014-04-13 04:57:38 +00:00
|
|
|
RelocationRef() : OwningObject(nullptr) { }
|
2011-09-08 20:52:17 +00:00
|
|
|
|
|
|
|
RelocationRef(DataRefImpl RelocationP, const ObjectFile *Owner);
|
|
|
|
|
|
|
|
bool operator==(const RelocationRef &Other) const;
|
|
|
|
|
2014-01-30 02:49:50 +00:00
|
|
|
void moveNext();
|
2011-09-08 20:52:17 +00:00
|
|
|
|
2014-06-12 21:46:39 +00:00
|
|
|
std::error_code getAddress(uint64_t &Result) const;
|
|
|
|
std::error_code getOffset(uint64_t &Result) const;
|
2013-06-05 01:33:53 +00:00
|
|
|
symbol_iterator getSymbol() const;
|
2015-05-21 21:24:32 +00:00
|
|
|
section_iterator getSection() const;
|
2014-06-12 21:46:39 +00:00
|
|
|
std::error_code getType(uint64_t &Result) const;
|
2011-10-07 19:25:32 +00:00
|
|
|
|
2011-10-25 20:35:53 +00:00
|
|
|
/// @brief Indicates whether this relocation should hidden when listing
|
|
|
|
/// relocations, usually because it is the trailing part of a multipart
|
|
|
|
/// relocation that will be printed as part of the leading relocation.
|
2014-06-12 21:46:39 +00:00
|
|
|
std::error_code getHidden(bool &Result) const;
|
2011-10-25 20:35:53 +00:00
|
|
|
|
2011-10-07 19:25:32 +00:00
|
|
|
/// @brief Get a string that represents the type of this relocation.
|
|
|
|
///
|
|
|
|
/// This is for display purposes only.
|
2014-06-12 21:46:39 +00:00
|
|
|
std::error_code getTypeName(SmallVectorImpl<char> &Result) const;
|
2011-10-07 19:25:32 +00:00
|
|
|
|
|
|
|
/// @brief Get a string that represents the calculation of the value of this
|
|
|
|
/// relocation.
|
|
|
|
///
|
|
|
|
/// This is for display purposes only.
|
2014-06-12 21:46:39 +00:00
|
|
|
std::error_code getValueString(SmallVectorImpl<char> &Result) const;
|
2012-06-18 19:47:16 +00:00
|
|
|
|
|
|
|
DataRefImpl getRawDataRefImpl() const;
|
2013-05-09 03:39:05 +00:00
|
|
|
const ObjectFile *getObjectFile() const;
|
2011-09-08 20:52:17 +00:00
|
|
|
};
|
2011-10-07 19:25:32 +00:00
|
|
|
typedef content_iterator<RelocationRef> relocation_iterator;
|
2011-09-08 20:52:17 +00:00
|
|
|
|
2010-11-15 03:21:41 +00:00
|
|
|
/// SectionRef - This is a value type class that represents a single section in
|
|
|
|
/// the list of sections in the object file.
|
|
|
|
class SectionRef {
|
2011-07-15 18:39:21 +00:00
|
|
|
friend class SymbolRef;
|
2010-11-15 03:21:41 +00:00
|
|
|
DataRefImpl SectionPimpl;
|
|
|
|
const ObjectFile *OwningObject;
|
|
|
|
|
|
|
|
public:
|
2014-04-13 04:57:38 +00:00
|
|
|
SectionRef() : OwningObject(nullptr) { }
|
2011-07-05 14:49:08 +00:00
|
|
|
|
2010-11-15 03:21:41 +00:00
|
|
|
SectionRef(DataRefImpl SectionP, const ObjectFile *Owner);
|
|
|
|
|
|
|
|
bool operator==(const SectionRef &Other) const;
|
2014-03-21 07:26:41 +00:00
|
|
|
bool operator!=(const SectionRef &Other) const;
|
2012-10-10 22:37:01 +00:00
|
|
|
bool operator<(const SectionRef &Other) const;
|
2010-11-15 03:21:41 +00:00
|
|
|
|
2014-01-30 02:49:50 +00:00
|
|
|
void moveNext();
|
2010-11-15 03:21:41 +00:00
|
|
|
|
2014-06-12 21:46:39 +00:00
|
|
|
std::error_code getName(StringRef &Result) const;
|
2014-10-08 15:28:58 +00:00
|
|
|
uint64_t getAddress() const;
|
|
|
|
uint64_t getSize() const;
|
2014-06-12 21:46:39 +00:00
|
|
|
std::error_code getContents(StringRef &Result) const;
|
2010-11-15 03:21:41 +00:00
|
|
|
|
2011-10-10 21:55:43 +00:00
|
|
|
/// @brief Get the alignment of this section as the actual value (not log 2).
|
2014-10-08 15:28:58 +00:00
|
|
|
uint64_t getAlignment() const;
|
2011-10-10 21:55:43 +00:00
|
|
|
|
2014-10-08 15:28:58 +00:00
|
|
|
bool isText() const;
|
|
|
|
bool isData() const;
|
|
|
|
bool isBSS() const;
|
|
|
|
bool isVirtual() const;
|
2011-07-15 18:39:21 +00:00
|
|
|
|
2014-10-08 15:28:58 +00:00
|
|
|
bool containsSymbol(SymbolRef S) const;
|
2011-10-07 19:25:32 +00:00
|
|
|
|
2014-02-10 20:24:04 +00:00
|
|
|
relocation_iterator relocation_begin() const;
|
|
|
|
relocation_iterator relocation_end() const;
|
2014-04-21 18:10:29 +00:00
|
|
|
iterator_range<relocation_iterator> relocations() const {
|
|
|
|
return iterator_range<relocation_iterator>(relocation_begin(),
|
|
|
|
relocation_end());
|
2014-03-14 14:22:49 +00:00
|
|
|
}
|
2013-05-30 03:05:14 +00:00
|
|
|
section_iterator getRelocatedSection() const;
|
2012-04-12 20:13:57 +00:00
|
|
|
|
|
|
|
DataRefImpl getRawDataRefImpl() const;
|
2014-12-10 20:46:55 +00:00
|
|
|
const ObjectFile *getObject() const;
|
2010-11-15 03:21:41 +00:00
|
|
|
};
|
|
|
|
|
2011-10-17 23:54:46 +00:00
|
|
|
/// SymbolRef - This is a value type class that represents a single symbol in
|
|
|
|
/// the list of symbols in the object file.
|
2014-02-21 20:10:59 +00:00
|
|
|
class SymbolRef : public BasicSymbolRef {
|
2011-10-17 23:54:46 +00:00
|
|
|
friend class SectionRef;
|
|
|
|
|
|
|
|
public:
|
2014-02-21 20:10:59 +00:00
|
|
|
SymbolRef() : BasicSymbolRef() {}
|
2011-10-17 23:54:46 +00:00
|
|
|
|
|
|
|
enum Type {
|
2012-02-29 02:11:55 +00:00
|
|
|
ST_Unknown, // Type not specified
|
2011-10-17 23:54:46 +00:00
|
|
|
ST_Data,
|
2011-10-17 23:55:06 +00:00
|
|
|
ST_Debug,
|
|
|
|
ST_File,
|
|
|
|
ST_Function,
|
2011-10-17 23:54:46 +00:00
|
|
|
ST_Other
|
|
|
|
};
|
|
|
|
|
|
|
|
SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner);
|
|
|
|
|
2014-06-12 21:46:39 +00:00
|
|
|
std::error_code getName(StringRef &Result) const;
|
2012-09-21 07:08:08 +00:00
|
|
|
/// Returns the symbol virtual address (i.e. address at which it will be
|
|
|
|
/// mapped).
|
2014-06-12 21:46:39 +00:00
|
|
|
std::error_code getAddress(uint64_t &Result) const;
|
2013-04-29 22:24:22 +00:00
|
|
|
/// @brief Get the alignment of this symbol as the actual value (not log 2).
|
2015-05-31 23:52:50 +00:00
|
|
|
uint32_t getAlignment() const;
|
2015-06-01 00:27:26 +00:00
|
|
|
uint64_t getSize() const;
|
2014-06-12 21:46:39 +00:00
|
|
|
std::error_code getType(SymbolRef::Type &Result) const;
|
2014-07-20 23:53:14 +00:00
|
|
|
std::error_code getOther(uint8_t &Result) const;
|
2011-10-17 23:54:46 +00:00
|
|
|
|
|
|
|
/// @brief Get section this symbol is defined in reference to. Result is
|
|
|
|
/// end_sections() if it is undefined or is an absolute symbol.
|
2014-06-12 21:46:39 +00:00
|
|
|
std::error_code getSection(section_iterator &Result) const;
|
2011-10-17 23:54:46 +00:00
|
|
|
|
2014-02-21 20:10:59 +00:00
|
|
|
const ObjectFile *getObject() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
class symbol_iterator : public basic_symbol_iterator {
|
|
|
|
public:
|
|
|
|
symbol_iterator(SymbolRef Sym) : basic_symbol_iterator(Sym) {}
|
|
|
|
symbol_iterator(const basic_symbol_iterator &B)
|
|
|
|
: basic_symbol_iterator(SymbolRef(B->getRawDataRefImpl(),
|
|
|
|
cast<ObjectFile>(B->getObject()))) {}
|
|
|
|
|
|
|
|
const SymbolRef *operator->() const {
|
|
|
|
const BasicSymbolRef &P = basic_symbol_iterator::operator *();
|
|
|
|
return static_cast<const SymbolRef*>(&P);
|
|
|
|
}
|
|
|
|
|
|
|
|
const SymbolRef &operator*() const {
|
|
|
|
const BasicSymbolRef &P = basic_symbol_iterator::operator *();
|
|
|
|
return static_cast<const SymbolRef&>(P);
|
|
|
|
}
|
2011-10-17 23:54:46 +00:00
|
|
|
};
|
|
|
|
|
2010-11-15 03:21:41 +00:00
|
|
|
/// ObjectFile - This class is the base class for all object file types.
|
|
|
|
/// Concrete instances of this object are created by createObjectFile, which
|
2012-10-19 22:10:54 +00:00
|
|
|
/// figures out which type to create.
|
2014-02-21 20:10:59 +00:00
|
|
|
class ObjectFile : public SymbolicFile {
|
2011-12-20 02:50:00 +00:00
|
|
|
virtual void anchor();
|
2015-02-15 22:54:22 +00:00
|
|
|
ObjectFile() = delete;
|
|
|
|
ObjectFile(const ObjectFile &other) = delete;
|
2010-11-15 03:21:41 +00:00
|
|
|
|
|
|
|
protected:
|
2014-08-19 18:44:46 +00:00
|
|
|
ObjectFile(unsigned int Type, MemoryBufferRef Source);
|
2010-11-15 03:21:41 +00:00
|
|
|
|
2011-06-25 17:54:50 +00:00
|
|
|
const uint8_t *base() const {
|
2014-08-19 18:44:46 +00:00
|
|
|
return reinterpret_cast<const uint8_t *>(Data.getBufferStart());
|
2011-06-25 17:54:50 +00:00
|
|
|
}
|
2010-11-15 03:21:41 +00:00
|
|
|
|
|
|
|
// These functions are for SymbolRef to call internally. The main goal of
|
|
|
|
// this is to allow SymbolRef::SymbolPimpl to point directly to the symbol
|
|
|
|
// entry in the memory mapped object file. SymbolPimpl cannot contain any
|
|
|
|
// virtual functions because then it could not point into the memory mapped
|
|
|
|
// file.
|
2011-06-25 17:55:23 +00:00
|
|
|
//
|
|
|
|
// Implementations assume that the DataRefImpl is valid and has not been
|
|
|
|
// modified externally. It's UB otherwise.
|
2010-11-15 03:21:41 +00:00
|
|
|
friend class SymbolRef;
|
2014-06-12 21:46:39 +00:00
|
|
|
virtual std::error_code getSymbolName(DataRefImpl Symb,
|
|
|
|
StringRef &Res) const = 0;
|
|
|
|
std::error_code printSymbolName(raw_ostream &OS,
|
|
|
|
DataRefImpl Symb) const override;
|
|
|
|
virtual std::error_code getSymbolAddress(DataRefImpl Symb,
|
|
|
|
uint64_t &Res) const = 0;
|
2015-05-31 23:52:50 +00:00
|
|
|
virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const;
|
2015-06-01 00:27:26 +00:00
|
|
|
virtual uint64_t getSymbolSize(DataRefImpl Symb) const = 0;
|
2014-06-12 21:46:39 +00:00
|
|
|
virtual std::error_code getSymbolType(DataRefImpl Symb,
|
|
|
|
SymbolRef::Type &Res) const = 0;
|
|
|
|
virtual std::error_code getSymbolSection(DataRefImpl Symb,
|
|
|
|
section_iterator &Res) const = 0;
|
2014-07-20 23:53:14 +00:00
|
|
|
virtual std::error_code getSymbolOther(DataRefImpl Symb,
|
|
|
|
uint8_t &Res) const {
|
|
|
|
return object_error::invalid_file_type;
|
|
|
|
}
|
2010-11-15 03:21:41 +00:00
|
|
|
|
|
|
|
// Same as above for SectionRef.
|
|
|
|
friend class SectionRef;
|
2014-01-30 02:49:50 +00:00
|
|
|
virtual void moveSectionNext(DataRefImpl &Sec) const = 0;
|
2014-06-12 21:46:39 +00:00
|
|
|
virtual std::error_code getSectionName(DataRefImpl Sec,
|
|
|
|
StringRef &Res) const = 0;
|
2014-10-08 15:28:58 +00:00
|
|
|
virtual uint64_t getSectionAddress(DataRefImpl Sec) const = 0;
|
|
|
|
virtual uint64_t getSectionSize(DataRefImpl Sec) const = 0;
|
2014-06-12 21:46:39 +00:00
|
|
|
virtual std::error_code getSectionContents(DataRefImpl Sec,
|
|
|
|
StringRef &Res) const = 0;
|
2014-10-08 15:28:58 +00:00
|
|
|
virtual uint64_t getSectionAlignment(DataRefImpl Sec) const = 0;
|
|
|
|
virtual bool isSectionText(DataRefImpl Sec) const = 0;
|
|
|
|
virtual bool isSectionData(DataRefImpl Sec) const = 0;
|
|
|
|
virtual bool isSectionBSS(DataRefImpl Sec) const = 0;
|
2012-04-12 20:13:57 +00:00
|
|
|
// A section is 'virtual' if its contents aren't present in the object image.
|
2014-10-08 15:28:58 +00:00
|
|
|
virtual bool isSectionVirtual(DataRefImpl Sec) const = 0;
|
|
|
|
virtual bool sectionContainsSymbol(DataRefImpl Sec,
|
|
|
|
DataRefImpl Symb) const = 0;
|
2013-09-27 21:47:05 +00:00
|
|
|
virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const = 0;
|
|
|
|
virtual relocation_iterator section_rel_end(DataRefImpl Sec) const = 0;
|
2013-05-30 03:05:14 +00:00
|
|
|
virtual section_iterator getRelocatedSection(DataRefImpl Sec) const;
|
2010-11-15 03:21:41 +00:00
|
|
|
|
2011-09-08 20:52:17 +00:00
|
|
|
// Same as above for RelocationRef.
|
|
|
|
friend class RelocationRef;
|
2014-01-30 02:49:50 +00:00
|
|
|
virtual void moveRelocationNext(DataRefImpl &Rel) const = 0;
|
2014-06-12 21:46:39 +00:00
|
|
|
virtual std::error_code getRelocationAddress(DataRefImpl Rel,
|
|
|
|
uint64_t &Res) const = 0;
|
|
|
|
virtual std::error_code getRelocationOffset(DataRefImpl Rel,
|
|
|
|
uint64_t &Res) const = 0;
|
2013-06-05 01:33:53 +00:00
|
|
|
virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const = 0;
|
2015-05-21 21:24:32 +00:00
|
|
|
virtual section_iterator getRelocationSection(DataRefImpl Rel) const = 0;
|
2014-06-12 21:46:39 +00:00
|
|
|
virtual std::error_code getRelocationType(DataRefImpl Rel,
|
|
|
|
uint64_t &Res) const = 0;
|
|
|
|
virtual std::error_code
|
|
|
|
getRelocationTypeName(DataRefImpl Rel,
|
|
|
|
SmallVectorImpl<char> &Result) const = 0;
|
|
|
|
virtual std::error_code
|
|
|
|
getRelocationValueString(DataRefImpl Rel,
|
|
|
|
SmallVectorImpl<char> &Result) const = 0;
|
|
|
|
virtual std::error_code getRelocationHidden(DataRefImpl Rel,
|
|
|
|
bool &Result) const {
|
2011-10-25 20:35:53 +00:00
|
|
|
Result = false;
|
|
|
|
return object_error::success;
|
|
|
|
}
|
2011-09-08 20:52:17 +00:00
|
|
|
|
2010-11-15 03:21:41 +00:00
|
|
|
public:
|
2014-03-17 07:28:19 +00:00
|
|
|
typedef iterator_range<symbol_iterator> symbol_iterator_range;
|
|
|
|
symbol_iterator_range symbols() const {
|
|
|
|
return symbol_iterator_range(symbol_begin(), symbol_end());
|
|
|
|
}
|
2010-11-15 03:21:41 +00:00
|
|
|
|
2014-02-10 20:24:04 +00:00
|
|
|
virtual section_iterator section_begin() const = 0;
|
|
|
|
virtual section_iterator section_end() const = 0;
|
2010-11-15 03:21:41 +00:00
|
|
|
|
2014-03-13 13:52:54 +00:00
|
|
|
typedef iterator_range<section_iterator> section_iterator_range;
|
|
|
|
section_iterator_range sections() const {
|
|
|
|
return section_iterator_range(section_begin(), section_end());
|
|
|
|
}
|
|
|
|
|
2010-11-15 03:21:41 +00:00
|
|
|
/// @brief The number of bytes used to represent an address in this object
|
|
|
|
/// file format.
|
|
|
|
virtual uint8_t getBytesInAddress() const = 0;
|
|
|
|
|
|
|
|
virtual StringRef getFileFormatName() const = 0;
|
2010-11-16 01:06:51 +00:00
|
|
|
virtual /* Triple::ArchType */ unsigned getArch() const = 0;
|
2010-11-15 03:21:41 +00:00
|
|
|
|
2014-07-20 23:53:14 +00:00
|
|
|
/// Returns platform-specific object flags, if any.
|
|
|
|
virtual std::error_code getPlatformFlags(unsigned &Result) const {
|
|
|
|
Result = 0;
|
|
|
|
return object_error::invalid_file_type;
|
|
|
|
}
|
|
|
|
|
2014-08-17 19:09:37 +00:00
|
|
|
/// True if this is a relocatable object (.o/.obj).
|
|
|
|
virtual bool isRelocatableObject() const = 0;
|
|
|
|
|
2010-11-15 03:21:41 +00:00
|
|
|
/// @returns Pointer to ObjectFile subclass to handle this type of object.
|
|
|
|
/// @param ObjectPath The path to the object file. ObjectPath.isObject must
|
|
|
|
/// return true.
|
|
|
|
/// @brief Create ObjectFile from path.
|
2014-08-19 18:44:46 +00:00
|
|
|
static ErrorOr<OwningBinary<ObjectFile>>
|
2014-07-31 03:12:45 +00:00
|
|
|
createObjectFile(StringRef ObjectPath);
|
|
|
|
|
|
|
|
static ErrorOr<std::unique_ptr<ObjectFile>>
|
2014-08-19 18:44:46 +00:00
|
|
|
createObjectFile(MemoryBufferRef Object, sys::fs::file_magic Type);
|
2014-07-31 03:12:45 +00:00
|
|
|
static ErrorOr<std::unique_ptr<ObjectFile>>
|
2014-08-19 18:44:46 +00:00
|
|
|
createObjectFile(MemoryBufferRef Object) {
|
2014-06-23 21:53:12 +00:00
|
|
|
return createObjectFile(Object, sys::fs::file_magic::unknown);
|
2014-01-29 00:02:26 +00:00
|
|
|
}
|
|
|
|
|
2010-11-15 03:21:41 +00:00
|
|
|
|
2011-06-25 17:54:50 +00:00
|
|
|
static inline bool classof(const Binary *v) {
|
2012-03-09 20:41:57 +00:00
|
|
|
return v->isObject();
|
2011-06-25 17:54:50 +00:00
|
|
|
}
|
|
|
|
|
2014-07-31 03:12:45 +00:00
|
|
|
static ErrorOr<std::unique_ptr<COFFObjectFile>>
|
2014-08-19 18:44:46 +00:00
|
|
|
createCOFFObjectFile(MemoryBufferRef Object);
|
2014-07-31 03:12:45 +00:00
|
|
|
|
|
|
|
static ErrorOr<std::unique_ptr<ObjectFile>>
|
2014-08-19 18:44:46 +00:00
|
|
|
createELFObjectFile(MemoryBufferRef Object);
|
2014-07-31 03:12:45 +00:00
|
|
|
|
|
|
|
static ErrorOr<std::unique_ptr<MachOObjectFile>>
|
2014-08-19 18:44:46 +00:00
|
|
|
createMachOObjectFile(MemoryBufferRef Object);
|
2010-11-15 03:21:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Inline function definitions.
|
|
|
|
inline SymbolRef::SymbolRef(DataRefImpl SymbolP, const ObjectFile *Owner)
|
2014-02-21 20:10:59 +00:00
|
|
|
: BasicSymbolRef(SymbolP, Owner) {}
|
2010-11-15 03:21:41 +00:00
|
|
|
|
2014-06-12 21:46:39 +00:00
|
|
|
inline std::error_code SymbolRef::getName(StringRef &Result) const {
|
2014-02-21 20:10:59 +00:00
|
|
|
return getObject()->getSymbolName(getRawDataRefImpl(), Result);
|
2010-11-15 03:21:41 +00:00
|
|
|
}
|
|
|
|
|
2014-06-12 21:46:39 +00:00
|
|
|
inline std::error_code SymbolRef::getAddress(uint64_t &Result) const {
|
2014-02-21 20:10:59 +00:00
|
|
|
return getObject()->getSymbolAddress(getRawDataRefImpl(), Result);
|
2010-11-15 03:21:41 +00:00
|
|
|
}
|
|
|
|
|
2015-05-31 23:52:50 +00:00
|
|
|
inline uint32_t SymbolRef::getAlignment() const {
|
|
|
|
return getObject()->getSymbolAlignment(getRawDataRefImpl());
|
2013-04-29 22:24:22 +00:00
|
|
|
}
|
|
|
|
|
2015-06-01 00:27:26 +00:00
|
|
|
inline uint64_t SymbolRef::getSize() const {
|
|
|
|
return getObject()->getSymbolSize(getRawDataRefImpl());
|
2011-10-17 23:54:46 +00:00
|
|
|
}
|
|
|
|
|
2014-06-12 21:46:39 +00:00
|
|
|
inline std::error_code SymbolRef::getSection(section_iterator &Result) const {
|
2014-02-21 20:10:59 +00:00
|
|
|
return getObject()->getSymbolSection(getRawDataRefImpl(), Result);
|
2011-10-17 23:54:46 +00:00
|
|
|
}
|
|
|
|
|
2014-06-12 21:46:39 +00:00
|
|
|
inline std::error_code SymbolRef::getType(SymbolRef::Type &Result) const {
|
2014-02-21 20:10:59 +00:00
|
|
|
return getObject()->getSymbolType(getRawDataRefImpl(), Result);
|
2011-09-14 01:22:52 +00:00
|
|
|
}
|
|
|
|
|
2014-07-20 23:53:14 +00:00
|
|
|
inline std::error_code SymbolRef::getOther(uint8_t &Result) const {
|
|
|
|
return getObject()->getSymbolOther(getRawDataRefImpl(), Result);
|
|
|
|
}
|
|
|
|
|
2014-02-21 20:10:59 +00:00
|
|
|
inline const ObjectFile *SymbolRef::getObject() const {
|
|
|
|
const SymbolicFile *O = BasicSymbolRef::getObject();
|
|
|
|
return cast<ObjectFile>(O);
|
2011-10-11 02:57:48 +00:00
|
|
|
}
|
|
|
|
|
2010-11-15 03:21:41 +00:00
|
|
|
|
|
|
|
/// SectionRef
|
|
|
|
inline SectionRef::SectionRef(DataRefImpl SectionP,
|
|
|
|
const ObjectFile *Owner)
|
|
|
|
: SectionPimpl(SectionP)
|
|
|
|
, OwningObject(Owner) {}
|
|
|
|
|
|
|
|
inline bool SectionRef::operator==(const SectionRef &Other) const {
|
|
|
|
return SectionPimpl == Other.SectionPimpl;
|
|
|
|
}
|
|
|
|
|
2014-03-21 07:26:41 +00:00
|
|
|
inline bool SectionRef::operator!=(const SectionRef &Other) const {
|
|
|
|
return SectionPimpl != Other.SectionPimpl;
|
|
|
|
}
|
|
|
|
|
2012-10-10 22:37:01 +00:00
|
|
|
inline bool SectionRef::operator<(const SectionRef &Other) const {
|
2011-11-02 19:33:41 +00:00
|
|
|
return SectionPimpl < Other.SectionPimpl;
|
|
|
|
}
|
|
|
|
|
2014-01-30 02:49:50 +00:00
|
|
|
inline void SectionRef::moveNext() {
|
|
|
|
return OwningObject->moveSectionNext(SectionPimpl);
|
2010-11-15 03:21:41 +00:00
|
|
|
}
|
|
|
|
|
2014-06-12 21:46:39 +00:00
|
|
|
inline std::error_code SectionRef::getName(StringRef &Result) const {
|
2011-06-25 17:55:23 +00:00
|
|
|
return OwningObject->getSectionName(SectionPimpl, Result);
|
2010-11-15 03:21:41 +00:00
|
|
|
}
|
|
|
|
|
2014-10-08 15:28:58 +00:00
|
|
|
inline uint64_t SectionRef::getAddress() const {
|
|
|
|
return OwningObject->getSectionAddress(SectionPimpl);
|
2010-11-15 03:21:41 +00:00
|
|
|
}
|
|
|
|
|
2014-10-08 15:28:58 +00:00
|
|
|
inline uint64_t SectionRef::getSize() const {
|
|
|
|
return OwningObject->getSectionSize(SectionPimpl);
|
2010-11-15 03:21:41 +00:00
|
|
|
}
|
|
|
|
|
2014-06-12 21:46:39 +00:00
|
|
|
inline std::error_code SectionRef::getContents(StringRef &Result) const {
|
2011-06-25 17:55:23 +00:00
|
|
|
return OwningObject->getSectionContents(SectionPimpl, Result);
|
2010-11-15 03:21:41 +00:00
|
|
|
}
|
|
|
|
|
2014-10-08 15:28:58 +00:00
|
|
|
inline uint64_t SectionRef::getAlignment() const {
|
|
|
|
return OwningObject->getSectionAlignment(SectionPimpl);
|
2011-10-10 21:55:43 +00:00
|
|
|
}
|
|
|
|
|
2014-10-08 15:28:58 +00:00
|
|
|
inline bool SectionRef::isText() const {
|
|
|
|
return OwningObject->isSectionText(SectionPimpl);
|
2010-11-15 03:21:41 +00:00
|
|
|
}
|
|
|
|
|
2014-10-08 15:28:58 +00:00
|
|
|
inline bool SectionRef::isData() const {
|
|
|
|
return OwningObject->isSectionData(SectionPimpl);
|
2011-09-28 20:57:30 +00:00
|
|
|
}
|
|
|
|
|
2014-10-08 15:28:58 +00:00
|
|
|
inline bool SectionRef::isBSS() const {
|
|
|
|
return OwningObject->isSectionBSS(SectionPimpl);
|
2011-09-28 20:57:30 +00:00
|
|
|
}
|
|
|
|
|
2014-10-08 15:28:58 +00:00
|
|
|
inline bool SectionRef::isVirtual() const {
|
|
|
|
return OwningObject->isSectionVirtual(SectionPimpl);
|
2012-04-12 20:13:57 +00:00
|
|
|
}
|
|
|
|
|
2014-10-08 15:28:58 +00:00
|
|
|
inline bool SectionRef::containsSymbol(SymbolRef S) const {
|
2014-02-21 20:10:59 +00:00
|
|
|
return OwningObject->sectionContainsSymbol(SectionPimpl,
|
2014-10-08 15:28:58 +00:00
|
|
|
S.getRawDataRefImpl());
|
2011-07-15 18:39:21 +00:00
|
|
|
}
|
|
|
|
|
2014-02-10 20:24:04 +00:00
|
|
|
inline relocation_iterator SectionRef::relocation_begin() const {
|
2013-09-27 21:47:05 +00:00
|
|
|
return OwningObject->section_rel_begin(SectionPimpl);
|
2011-10-07 19:25:32 +00:00
|
|
|
}
|
|
|
|
|
2014-02-10 20:24:04 +00:00
|
|
|
inline relocation_iterator SectionRef::relocation_end() const {
|
2013-09-27 21:47:05 +00:00
|
|
|
return OwningObject->section_rel_end(SectionPimpl);
|
2011-10-07 19:25:32 +00:00
|
|
|
}
|
|
|
|
|
2013-05-30 03:05:14 +00:00
|
|
|
inline section_iterator SectionRef::getRelocatedSection() const {
|
|
|
|
return OwningObject->getRelocatedSection(SectionPimpl);
|
|
|
|
}
|
|
|
|
|
2012-04-12 20:13:57 +00:00
|
|
|
inline DataRefImpl SectionRef::getRawDataRefImpl() const {
|
|
|
|
return SectionPimpl;
|
|
|
|
}
|
2011-09-08 20:52:17 +00:00
|
|
|
|
2014-12-10 20:46:55 +00:00
|
|
|
inline const ObjectFile *SectionRef::getObject() const {
|
|
|
|
return OwningObject;
|
|
|
|
}
|
|
|
|
|
2011-09-08 20:52:17 +00:00
|
|
|
/// RelocationRef
|
|
|
|
inline RelocationRef::RelocationRef(DataRefImpl RelocationP,
|
|
|
|
const ObjectFile *Owner)
|
|
|
|
: RelocationPimpl(RelocationP)
|
|
|
|
, OwningObject(Owner) {}
|
|
|
|
|
|
|
|
inline bool RelocationRef::operator==(const RelocationRef &Other) const {
|
|
|
|
return RelocationPimpl == Other.RelocationPimpl;
|
|
|
|
}
|
|
|
|
|
2014-01-30 02:49:50 +00:00
|
|
|
inline void RelocationRef::moveNext() {
|
|
|
|
return OwningObject->moveRelocationNext(RelocationPimpl);
|
2011-09-08 20:52:17 +00:00
|
|
|
}
|
|
|
|
|
2014-06-12 21:46:39 +00:00
|
|
|
inline std::error_code RelocationRef::getAddress(uint64_t &Result) const {
|
2011-09-08 20:52:17 +00:00
|
|
|
return OwningObject->getRelocationAddress(RelocationPimpl, Result);
|
|
|
|
}
|
|
|
|
|
2014-06-12 21:46:39 +00:00
|
|
|
inline std::error_code RelocationRef::getOffset(uint64_t &Result) const {
|
2011-11-29 17:40:10 +00:00
|
|
|
return OwningObject->getRelocationOffset(RelocationPimpl, Result);
|
|
|
|
}
|
|
|
|
|
2013-06-05 01:33:53 +00:00
|
|
|
inline symbol_iterator RelocationRef::getSymbol() const {
|
|
|
|
return OwningObject->getRelocationSymbol(RelocationPimpl);
|
2011-09-08 20:52:17 +00:00
|
|
|
}
|
|
|
|
|
2015-05-21 21:24:32 +00:00
|
|
|
inline section_iterator RelocationRef::getSection() const {
|
|
|
|
return OwningObject->getRelocationSection(RelocationPimpl);
|
|
|
|
}
|
|
|
|
|
2014-06-12 21:46:39 +00:00
|
|
|
inline std::error_code RelocationRef::getType(uint64_t &Result) const {
|
2011-09-08 20:52:17 +00:00
|
|
|
return OwningObject->getRelocationType(RelocationPimpl, Result);
|
|
|
|
}
|
|
|
|
|
2014-06-12 21:46:39 +00:00
|
|
|
inline std::error_code
|
|
|
|
RelocationRef::getTypeName(SmallVectorImpl<char> &Result) const {
|
2011-10-07 19:25:32 +00:00
|
|
|
return OwningObject->getRelocationTypeName(RelocationPimpl, Result);
|
|
|
|
}
|
|
|
|
|
2014-06-12 21:46:39 +00:00
|
|
|
inline std::error_code
|
|
|
|
RelocationRef::getValueString(SmallVectorImpl<char> &Result) const {
|
2011-10-07 19:25:32 +00:00
|
|
|
return OwningObject->getRelocationValueString(RelocationPimpl, Result);
|
|
|
|
}
|
|
|
|
|
2014-06-12 21:46:39 +00:00
|
|
|
inline std::error_code RelocationRef::getHidden(bool &Result) const {
|
2011-10-25 20:35:53 +00:00
|
|
|
return OwningObject->getRelocationHidden(RelocationPimpl, Result);
|
|
|
|
}
|
2012-06-18 19:47:16 +00:00
|
|
|
|
|
|
|
inline DataRefImpl RelocationRef::getRawDataRefImpl() const {
|
|
|
|
return RelocationPimpl;
|
|
|
|
}
|
|
|
|
|
2013-05-09 03:39:05 +00:00
|
|
|
inline const ObjectFile *RelocationRef::getObjectFile() const {
|
|
|
|
return OwningObject;
|
|
|
|
}
|
|
|
|
|
2011-10-25 20:35:53 +00:00
|
|
|
|
2010-11-15 03:21:41 +00:00
|
|
|
} // end namespace object
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|