aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Object/ObjectFile.h
diff options
context:
space:
mode:
authorDavid Meyer <pdox@google.com>2012-03-01 01:36:50 +0000
committerDavid Meyer <pdox@google.com>2012-03-01 01:36:50 +0000
commit5c2b4ea73c8f48bb5f96c86fe437385b8fb3dcda (patch)
treee62d2d345c810a0aaf0a561192a31079c5acb5b6 /include/llvm/Object/ObjectFile.h
parent741981adf3a2bc0c6652c9c4ec846250950f3e68 (diff)
[Object]
* Add begin_dynamic_table() / end_dynamic_table() private interface to ELFObjectFile. * Add begin_libraries_needed() / end_libraries_needed() interface to ObjectFile, for grabbing the list of needed libraries for a shared object or dynamic executable. * Implement this new interface completely for ELF, leave stubs for COFF and MachO. * Add 'llvm-readobj' tool for dumping ObjectFile information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151785 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Object/ObjectFile.h')
-rw-r--r--include/llvm/Object/ObjectFile.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/include/llvm/Object/ObjectFile.h b/include/llvm/Object/ObjectFile.h
index 56d8c249c7..dd47ceb747 100644
--- a/include/llvm/Object/ObjectFile.h
+++ b/include/llvm/Object/ObjectFile.h
@@ -228,6 +228,32 @@ public:
};
typedef content_iterator<SymbolRef> symbol_iterator;
+/// LibraryRef - This is a value type class that represents a single library in
+/// the list of libraries needed by a shared or dynamic object.
+class LibraryRef {
+ friend class SectionRef;
+ DataRefImpl LibraryPimpl;
+ const ObjectFile *OwningObject;
+
+public:
+ LibraryRef() : OwningObject(NULL) {
+ std::memset(&LibraryPimpl, 0, sizeof(LibraryPimpl));
+ }
+
+ LibraryRef(DataRefImpl LibraryP, const ObjectFile *Owner);
+
+ bool operator==(const LibraryRef &Other) const;
+ bool operator <(const LibraryRef &Other) const;
+
+ error_code getNext(LibraryRef &Result) const;
+
+ // Get the path to this library, as stored in the object file.
+ error_code getPath(StringRef &Result) const;
+
+ DataRefImpl getRawDataRefImpl() const;
+};
+typedef content_iterator<LibraryRef> library_iterator;
+
const uint64_t UnknownAddressOrSize = ~0ULL;
/// ObjectFile - This class is the base class for all object file types.
@@ -307,6 +333,11 @@ protected:
return object_error::success;
}
+ // Same for LibraryRef
+ friend class LibraryRef;
+ virtual error_code getLibraryNext(DataRefImpl Lib, LibraryRef &Res) const = 0;
+ virtual error_code getLibraryPath(DataRefImpl Lib, StringRef &Res) const = 0;
+
public:
virtual symbol_iterator begin_symbols() const = 0;
@@ -318,6 +349,9 @@ public:
virtual section_iterator begin_sections() const = 0;
virtual section_iterator end_sections() const = 0;
+ virtual library_iterator begin_libraries_needed() const = 0;
+ virtual library_iterator end_libraries_needed() const = 0;
+
/// @brief The number of bytes used to represent an address in this object
/// file format.
virtual uint8_t getBytesInAddress() const = 0;
@@ -509,6 +543,26 @@ inline error_code RelocationRef::getValueString(SmallVectorImpl<char> &Result)
inline error_code RelocationRef::getHidden(bool &Result) const {
return OwningObject->getRelocationHidden(RelocationPimpl, Result);
}
+// Inline function definitions.
+inline LibraryRef::LibraryRef(DataRefImpl LibraryP, const ObjectFile *Owner)
+ : LibraryPimpl(LibraryP)
+ , OwningObject(Owner) {}
+
+inline bool LibraryRef::operator==(const LibraryRef &Other) const {
+ return LibraryPimpl == Other.LibraryPimpl;
+}
+
+inline bool LibraryRef::operator <(const LibraryRef &Other) const {
+ return LibraryPimpl < Other.LibraryPimpl;
+}
+
+inline error_code LibraryRef::getNext(LibraryRef &Result) const {
+ return OwningObject->getLibraryNext(LibraryPimpl, Result);
+}
+
+inline error_code LibraryRef::getPath(StringRef &Result) const {
+ return OwningObject->getLibraryPath(LibraryPimpl, Result);
+}
} // end namespace object
} // end namespace llvm