* 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
This commit is contained in:
David Meyer
2012-03-01 01:36:50 +00:00
parent 741981adf3
commit 5c2b4ea73c
16 changed files with 654 additions and 4 deletions

View File

@ -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