LLVM API Documentation
#include <Archive.h>
Collaboration diagram for llvm::Archive:
Constructors | |
~Archive () | |
Destruct in-memory archive. | |
static Archive * | CreateEmpty (const sys::Path &Filename) |
Create an empty Archive. | |
static Archive * | OpenAndLoad (const sys::Path &filePath) |
Open and load an archive file. | |
static Archive * | OpenAndLoadSymbols (const sys::Path &Filename) |
Open an existing archive and load its symbols. | |
Implementation | |
typedef std::map< unsigned, std::pair< ModuleProvider *, ArchiveMember * > > | ModuleMap |
Module mapping type. | |
Archive (const sys::Path &filename, bool map=false) | |
Construct an Archive for filename and optionally map it into memory. | |
void | parseSymbolTable (const void *data, unsigned len) |
Parse the symbol table at data . | |
ArchiveMember * | parseMemberHeader (const char *&At, const char *End) |
Parse the header of a member starting at At . | |
void | checkSignature () |
Check that the archive signature is correct. | |
void | loadArchive () |
Load the entire archive. | |
void | loadSymbolTable () |
Load just the symbol table. | |
void | writeSymbolTable (std::ofstream &ARFile) |
Write the symbol table to an ofstream. | |
void | writeMember (const ArchiveMember &member, std::ofstream &ARFile, bool CreateSymbolTable, bool TruncateNames, bool ShouldCompress) |
Write one ArchiveMember to an ofstream. | |
bool | fillHeader (const ArchiveMember &mbr, ArchiveMemberHeader &hdr, int sz, bool TruncateNames) const |
Fill in an ArchiveMemberHeader from ArchiveMember. | |
Public Types | |
Types | |
typedef iplist< ArchiveMember > | MembersList |
The ilist type of ArchiveMembers that Archive contains. | |
typedef MembersList::iterator | iterator |
Forward mutable iterator over ArchiveMember. | |
typedef MembersList::const_iterator | const_iterator |
Forward immutable iterator over ArchiveMember. | |
typedef std::reverse_iterator< iterator > | reverse_iterator |
Reverse mutable iterator over ArchiveMember. | |
typedef std::reverse_iterator< const_iterator > | const_reverse_iterator |
Reverse immutable iterator over ArchiveMember. | |
typedef std::map< std::string, unsigned > | SymTabType |
The in-memory version of the symbol table. | |
Public Member Functions | |
ilist accessor methods | |
iterator | begin () |
const_iterator | begin () const |
iterator | end () |
const_iterator | end () const |
reverse_iterator | rbegin () |
const_reverse_iterator | rbegin () const |
reverse_iterator | rend () |
const_reverse_iterator | rend () const |
unsigned | size () const |
bool | empty () const |
const ArchiveMember & | front () const |
ArchiveMember & | front () |
const ArchiveMember & | back () const |
ArchiveMember & | back () |
ilist mutator methods | |
void | splice (iterator dest, Archive &arch, iterator src) |
Move a member to a new location. | |
iterator | erase (iterator target) |
Erase a member. | |
Accessors | |
const sys::Path & | getPath () |
Get the archive path. | |
MembersList & | getMembers () |
Get the iplist of the members. | |
const SymTabType & | getSymbolTable () |
Get the archive's symbol table. | |
unsigned | getFirstFileOffset () |
Get the offset to the first "real" file member in the archive. | |
bool | getAllModules (std::vector< Module * > &Modules, std::string *ErrMessage) |
Instantiate all the bytecode modules located in the archive. | |
ModuleProvider * | findModuleDefiningSymbol (const std::string &symbol) |
Look up a module by symbol name. | |
void | findModulesDefiningSymbols (std::set< std::string > &symbols, std::set< ModuleProvider * > &modules) |
Look up multiple symbols in the archive. | |
Mutators | |
void | writeToDisk (bool CreateSymbolTable=false, bool TruncateNames=false, bool Compress=false) |
Write (possibly modified) archive contents to disk. | |
void | addFileBefore (const sys::Path &filename, iterator where) |
Add a file to the archive. | |
Protected Attributes | |
Data | |
sys::Path | archPath |
Path to the archive file we read/write. | |
MembersList | members |
The ilist of ArchiveMember. | |
sys::MappedFile * | mapfile |
Raw Archive contents mapped into memory. | |
const char * | base |
Base of the memory mapped file data. | |
SymTabType | symTab |
The symbol table. | |
std::string | strtab |
The string table for long file names. | |
unsigned | symTabSize |
Size in bytes of symbol table. | |
unsigned | firstFileOffset |
Offset to first normal file. | |
ModuleMap | modules |
The modules loaded via symbol lookup. | |
ArchiveMember * | foreignST |
This holds the foreign symbol table. |
Definition at line 225 of file Archive.h.
|
Forward immutable iterator over ArchiveMember.
|
|
Reverse immutable iterator over ArchiveMember.
|
|
Forward mutable iterator over ArchiveMember.
|
|
The ilist type of ArchiveMembers that Archive contains. This is the ilist type over which users may iterate to examine the contents of the archive |
|
Module mapping type. This type is used to keep track of bytecode modules loaded from the symbol table. It maps the file offset to a pair that consists of the associated ArchiveMember and the ModuleProvider. |
|
Reverse mutable iterator over ArchiveMember.
|
|
The in-memory version of the symbol table.
|
|
Destruct in-memory archive. This destructor cleans up the Archive object, releases all memory, and closes files. It does nothing with the archive file on disk. If you haven't used the writeToDisk method by the time the destructor is called, all changes to the archive will be lost.
Definition at line 143 of file Archive.cpp. References E, I, mapfile, modules, and llvm::sys::MappedFile::unmap(). |
|
Construct an Archive for
Definition at line 132 of file Archive.cpp. References base, llvm::sys::MappedFile::map(), and mapfile. |
|
Add a file to the archive.
This method adds a new file to the archive. The
Definition at line 155 of file ArchiveWriter.cpp. References llvm::sys::BytecodeFileType, llvm::ArchiveMember::BytecodeFlag, llvm::sys::CompressedBytecodeFileType, llvm::ArchiveMember::CompressedBytecodeFlag, llvm::ArchiveMember::data, llvm::sys::Path::exists(), llvm::ArchiveMember::flags, llvm::sys::Path::get(), llvm::sys::Path::getMagicNumber(), llvm::sys::Path::getStatusInfo(), llvm::ArchiveMember::HasLongFilenameFlag, llvm::ArchiveMember::HasPathFlag, llvm::sys::IdentifyFileType(), llvm::ArchiveMember::info, members, and llvm::ArchiveMember::path. |
|
Definition at line 269 of file Archive.h. References members. |
|
Definition at line 268 of file Archive.h. References members. |
|
Definition at line 255 of file Archive.h. References members. |
|
Definition at line 254 of file Archive.h. References members. Referenced by getAllModules(), and writeToDisk(). |
|
Check that the archive signature is correct.
Definition at line 204 of file ArchiveReader.cpp. References ARFILE_MAGIC, base, mapfile, and llvm::sys::MappedFile::size(). Referenced by loadArchive(), and loadSymbolTable(). |
|
Create an empty Archive.
Create an empty archive file and associate it with the
Definition at line 66 of file ArchiveWriter.cpp. |
|
Definition at line 265 of file Archive.h. References members. |
|
Definition at line 257 of file Archive.h. References members. |
|
Definition at line 256 of file Archive.h. References members. Referenced by getAllModules(), and writeToDisk(). |
|
Erase a member.
This method erases a Definition at line 286 of file Archive.h. References members. |
|
|
Look up a module by symbol name.
This accessor looks up the
Definition at line 385 of file ArchiveReader.cpp. References archPath, base, firstFileOffset, llvm::sys::Path::get(), llvm::getBytecodeBufferModuleProvider(), llvm::ArchiveMember::getData(), llvm::ArchiveMember::getPath(), llvm::ArchiveMember::getSize(), mapfile, modules, parseMemberHeader(), llvm::sys::MappedFile::size(), and symTab. Referenced by findModulesDefiningSymbols(). |
|
Look up multiple symbols in the archive.
This method is similar to findModuleDefiningSymbol but allows lookup of more than one symbol at a time. If
Definition at line 424 of file ArchiveReader.cpp. References archPath, base, E, findModuleDefiningSymbol(), firstFileOffset, llvm::sys::Path::get(), llvm::GetBytecodeSymbols(), llvm::ArchiveMember::getPath(), llvm::ArchiveMember::getSize(), I, llvm::ArchiveMember::isBytecode(), llvm::ArchiveMember::isCompressedBytecode(), mapfile, modules, parseMemberHeader(), llvm::sys::MappedFile::size(), and symTab. Referenced by llvm::LinkInArchive(). |
|
Definition at line 267 of file Archive.h. References members. |
|
Definition at line 266 of file Archive.h. References members. |
|
Instantiate all the bytecode modules located in the archive.
This method will scan the archive for bytecode modules, interpret them and return a vector of the instantiated modules in
Definition at line 294 of file ArchiveReader.cpp. References archPath, begin(), E, end(), llvm::sys::Path::get(), I, M, and llvm::ParseBytecodeBuffer(). |
|
Get the offset to the first "real" file member in the archive. This method returns the offset in the archive file to the first "real" file member. Archive files, on disk, have a signature and might have a symbol table that precedes the first actual file member. This method allows you to determine what the size of those fields are.
Definition at line 374 of file Archive.h. References firstFileOffset. |
|
Get the iplist of the members. This method is provided so that editing methods can be invoked directly on the Archive's iplist of ArchiveMember. However, it is recommended that the usual STL style iterator interface be used instead.
Definition at line 352 of file Archive.h. References members. |
|
Get the archive path.
Definition at line 345 of file Archive.h. References archPath. |
|
Get the archive's symbol table. This method allows direct query of the Archive's symbol table. The symbol table is a std::map of std::string (the symbol) to unsigned (the file offset). Note that for efficiency reasons, the offset stored in the symbol table is not the actual offset. It is the offset from the beginning of the first "real" file member (after the symbol table). Use the getFirstFileOffset() to obtain that offset and add this value to the offset in the symbol table to obtain the real file offset. Note that there is purposefully no interface provided by Archive to look up members by their offset. Use the findModulesDefiningSymbols and findModuleDefiningSymbol methods instead.
Definition at line 366 of file Archive.h. References symTab. |
|
Load the entire archive.
Definition at line 214 of file ArchiveReader.cpp. References base, checkSignature(), firstFileOffset, foreignST, llvm::ArchiveMember::getData(), llvm::ArchiveMember::getSize(), llvm::ArchiveMember::isBSD4SymbolTable(), llvm::ArchiveMember::isLLVMSymbolTable(), llvm::ArchiveMember::isStringTable(), llvm::ArchiveMember::isSVR4SymbolTable(), mapfile, members, parseMemberHeader(), parseSymbolTable(), llvm::sys::MappedFile::size(), strtab, and symTab. Referenced by OpenAndLoad(). |
|
Load just the symbol table.
Definition at line 313 of file ArchiveReader.cpp. References base, checkSignature(), firstFileOffset, llvm::ArchiveMember::getData(), llvm::ArchiveMember::getSize(), llvm::ArchiveMember::isBSD4SymbolTable(), llvm::ArchiveMember::isLLVMSymbolTable(), llvm::ArchiveMember::isStringTable(), llvm::ArchiveMember::isSVR4SymbolTable(), mapfile, members, parseMemberHeader(), parseSymbolTable(), llvm::sys::MappedFile::size(), strtab, and symTab. Referenced by OpenAndLoadSymbols(). |
|
Open and load an archive file. Open an existing archive and load its contents in preparation for editing. After this call, the member ilist is completely populated based on the contents of the archive file. You should use this form of open if you intend to modify the archive or traverse its contents (e.g. for printing). Definition at line 283 of file ArchiveReader.cpp. References loadArchive(). |
|
Open an existing archive and load its symbols.
This method opens an existing archive file from
Definition at line 374 of file ArchiveReader.cpp. References loadSymbolTable(). Referenced by llvm::LinkInArchive(). |
|
|
Parse the symbol table at
Definition at line 35 of file ArchiveReader.cpp. References readInteger(), symTab, and symTabSize. Referenced by loadArchive(), and loadSymbolTable(). |
|
Definition at line 260 of file Archive.h. References members. |
|
Definition at line 259 of file Archive.h. References members. |
|
Definition at line 262 of file Archive.h. References members. |
|
Definition at line 261 of file Archive.h. References members. |
|
Definition at line 264 of file Archive.h. References members. |
|
Move a member to a new location.
This method splices a Definition at line 279 of file Archive.h. References members. |
|
|
Write the symbol table to an ofstream.
Definition at line 312 of file ArchiveWriter.cpp. References ARFILE_LLVM_SYMTAB_NAME, ARFILE_PAD, llvm::ArchiveMemberHeader::date, E, I, llvm::ArchiveMemberHeader::init(), llvm::Intrinsic::memcpy, llvm::ArchiveMemberHeader::name, llvm::sys::TimeValue::now(), llvm::ArchiveMemberHeader::size, symTab, symTabSize, llvm::sys::TimeValue::toEpochTime(), and writeInteger(). Referenced by writeToDisk(). |
|
Write (possibly modified) archive contents to disk.
This method is the only way to get the archive written to disk. It creates or overwrites the file specified when
Definition at line 360 of file ArchiveWriter.cpp. References archPath, ARFILE_MAGIC, base, begin(), llvm::sys::Path::c_str(), llvm::sys::Path::createTemporaryFile(), llvm::sys::Path::destroyFile(), E, end(), llvm::sys::Path::exists(), foreignST, llvm::sys::Path::get(), I, llvm::sys::MappedFile::map(), mapfile, members, llvm::sys::RemoveFileOnSignal(), llvm::sys::Path::renameFile(), llvm::sys::MappedFile::size(), symTab, symTabSize, llvm::sys::MappedFile::unmap(), writeMember(), and writeSymbolTable(). |
|
Path to the archive file we read/write.
Definition at line 490 of file Archive.h. Referenced by findModuleDefiningSymbol(), findModulesDefiningSymbols(), getAllModules(), getPath(), writeMember(), and writeToDisk(). |
|
Base of the memory mapped file data.
Definition at line 493 of file Archive.h. Referenced by Archive(), checkSignature(), findModuleDefiningSymbol(), findModulesDefiningSymbols(), loadArchive(), loadSymbolTable(), and writeToDisk(). |
|
Offset to first normal file.
Definition at line 497 of file Archive.h. Referenced by findModuleDefiningSymbol(), findModulesDefiningSymbols(), getFirstFileOffset(), loadArchive(), and loadSymbolTable(). |
|
This holds the foreign symbol table.
Definition at line 499 of file Archive.h. Referenced by loadArchive(), and writeToDisk(). |
|
Raw Archive contents mapped into memory.
Definition at line 492 of file Archive.h. Referenced by Archive(), checkSignature(), findModuleDefiningSymbol(), findModulesDefiningSymbols(), loadArchive(), loadSymbolTable(), writeToDisk(), and ~Archive(). |
|
The ilist of ArchiveMember.
Definition at line 491 of file Archive.h. Referenced by addFileBefore(), back(), begin(), empty(), end(), erase(), front(), getMembers(), loadArchive(), loadSymbolTable(), rbegin(), rend(), size(), splice(), and writeToDisk(). |
|
The modules loaded via symbol lookup.
Definition at line 498 of file Archive.h. Referenced by findModuleDefiningSymbol(), findModulesDefiningSymbols(), and ~Archive(). |
|
The string table for long file names.
Definition at line 495 of file Archive.h. Referenced by loadArchive(), loadSymbolTable(), and parseMemberHeader(). |
|
The symbol table.
Definition at line 494 of file Archive.h. Referenced by findModuleDefiningSymbol(), findModulesDefiningSymbols(), getSymbolTable(), loadArchive(), loadSymbolTable(), parseSymbolTable(), writeMember(), writeSymbolTable(), and writeToDisk(). |
|
Size in bytes of symbol table.
Definition at line 496 of file Archive.h. Referenced by parseSymbolTable(), writeMember(), writeSymbolTable(), and writeToDisk(). |