LLVM API Documentation
#include <Archive.h>
Collaboration diagram for llvm::Archive:

Constructors | |
| ~Archive () | |
| Destruct in-memory archive. | |
| Archive * | CreateEmpty (const sys::Path &Filename) |
| Create an empty Archive. | |
| Archive * | OpenAndLoad (const sys::Path &filePath, std::string *ErrorMessage) |
| Open and load an archive file. | |
| Archive * | OpenAndLoadSymbols (const sys::Path &Filename, std::string *ErrorMessage=0) |
| 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) | |
Construct an Archive for filename and optionally map it into memory. | |
| bool | parseSymbolTable (const void *data, unsigned len, std::string *error) |
Parse the symbol table at data. | |
| ArchiveMember * | parseMemberHeader (const char *&At, const char *End, std::string *error) |
Parse the header of a member starting at At. | |
| bool | checkSignature (std::string *ErrMessage) |
| Check that the archive signature is correct. | |
| bool | loadArchive (std::string *ErrMessage) |
| Load the entire archive. | |
| bool | loadSymbolTable (std::string *ErrMessage) |
| Load just the symbol table. | |
| void | writeSymbolTable (std::ofstream &ARFile) |
| Write the symbol table to an ofstream. | |
| bool | writeMember (const ArchiveMember &member, std::ofstream &ARFile, bool CreateSymbolTable, bool TruncateNames, bool ShouldCompress, std::string *ErrMessage) |
| bool | fillHeader (const ArchiveMember &mbr, ArchiveMemberHeader &hdr, int sz, bool TruncateNames) const |
| Fill in an ArchiveMemberHeader from ArchiveMember. | |
| bool | mapToMemory (std::string *ErrMsg) |
| Maps archive into memory. | |
| void | cleanUpMemory () |
| Frees all the members and unmaps the archive file. | |
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 |
| size_t | 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 bitcode modules located in the archive. | |
| ModuleProvider * | findModuleDefiningSymbol (const std::string &symbol, std::string *ErrMessage) |
| Look up a module by symbol name. | |
| bool | findModulesDefiningSymbols (std::set< std::string > &symbols, std::set< ModuleProvider * > &modules, std::string *ErrMessage) |
| Look up multiple symbols in the archive. | |
| bool | isBitcodeArchive () |
| Determine whether the archive is a proper llvm bitcode archive. | |
Mutators | |
| bool | writeToDisk (bool CreateSymbolTable=false, bool TruncateNames=false, bool Compress=false, std::string *ErrMessage=0) |
| Write (possibly modified) archive contents to disk. | |
| bool | addFileBefore (const sys::Path &filename, iterator where, std::string *ErrMsg) |
| 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. | |
| MemoryBuffer * | 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 |
Definition at line 206 of file Archive.h.
|
|
Forward immutable iterator over ArchiveMember.
|
|
|
Reverse immutable iterator over ArchiveMember.
|
|
|
Forward mutable iterator over ArchiveMember.
Definition at line 217 of file Archive.h. Referenced by getAllModules(), and isBitcodeArchive(). |
|
|
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 bitcode 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 182 of file Archive.cpp. References cleanUpMemory(). |
|
|
Construct an Archive for
Definition at line 141 of file Archive.cpp. Referenced by CreateEmpty(), OpenAndLoad(), and OpenAndLoadSymbols(). |
|
||||||||||||||||
|
Add a file to the archive.
This method adds a new file to the archive. The
Definition at line 157 of file ArchiveWriter.cpp. References llvm::ArchiveMember::data, llvm::sys::Path::exists(), llvm::ArchiveMember::flags, llvm::sys::PathWithStatus::getFileStatus(), llvm::sys::Path::getMagicNumber(), llvm::sys::IdentifyFileType(), llvm::ArchiveMember::info, llvm::iplist< NodeTy, Traits >::insert(), members, llvm::ArchiveMember::path, and llvm::sys::Path::toString(). |
|
|
|
|
|
|
|
|
|
|
|
Definition at line 235 of file Archive.h. Referenced by getAllModules(), isBitcodeArchive(), and writeToDisk(). |
|
|
Check that the archive signature is correct.
Definition at line 237 of file ArchiveReader.cpp. References ARFILE_MAGIC, base, llvm::MemoryBuffer::getBufferSize(), and mapfile. Referenced by loadArchive(), and loadSymbolTable(). |
|
|
Frees all the members and unmaps the archive file.
Definition at line 155 of file Archive.cpp. References base, firstFileOffset, foreignST, mapfile, modules, symTab, and symTabSize. Referenced by writeToDisk(), and ~Archive(). |
|
|
Create an empty Archive.
Create an empty archive file and associate it with the
Definition at line 68 of file ArchiveWriter.cpp. References Archive(). |
|
|
|
|
|
|
|
|
Definition at line 237 of file Archive.h. Referenced by getAllModules(), isBitcodeArchive(), and writeToDisk(). |
|
|
Erase a member.
This method erases a |
|
||||||||||||||||||||
|
||||||||||||
|
Look up a module by symbol name.
This accessor looks up the
Definition at line 455 of file ArchiveReader.cpp. References archPath, base, llvm::getBitcodeModuleProvider(), llvm::MemoryBuffer::getBufferEnd(), llvm::MemoryBuffer::getBufferStart(), llvm::ArchiveMember::getData(), llvm::MemoryBuffer::getNewMemBuffer(), llvm::ArchiveMember::getPath(), llvm::ArchiveMember::getSize(), mapfile, modules, parseMemberHeader(), symTab, and llvm::sys::Path::toString(). 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 502 of file ArchiveReader.cpp. References archPath, base, findModuleDefiningSymbol(), llvm::GetBitcodeSymbols(), llvm::MemoryBuffer::getBufferEnd(), llvm::ArchiveMember::getPath(), llvm::ArchiveMember::getSize(), llvm::ArchiveMember::isBitcode(), mapfile, modules, parseMemberHeader(), symTab, and llvm::sys::Path::toString(). Referenced by llvm::Linker::LinkInArchive(). |
|
|
|
|
|
|
|
||||||||||||
|
Instantiate all the bitcode modules located in the archive.
This method will scan the archive for bitcode modules, interpret them and return a vector of the instantiated modules in
Definition at line 341 of file ArchiveReader.cpp. References archPath, begin(), end(), llvm::MemoryBuffer::getBufferStart(), llvm::MemoryBuffer::getNewMemBuffer(), iterator, llvm::ParseBitcodeFile(), and llvm::sys::Path::toString(). |
|
|
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.
|
|
|
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.
|
|
|
Get the archive path.
|
|
|
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.
|
|
|
Determine whether the archive is a proper llvm bitcode archive. This method determines whether the archive is a properly formed llvm bitcode archive. It first makes sure the symbol table has been loaded and has a non-zero size. If it does, then it is an archive. If not, then it tries to load all the bitcode modules of the archive. Finally, it returns whether it was successfull.
Definition at line 587 of file ArchiveReader.cpp. References archPath, begin(), end(), llvm::MemoryBuffer::getBufferStart(), llvm::MemoryBuffer::getNewMemBuffer(), iterator, loadArchive(), loadSymbolTable(), llvm::ParseBitcodeFile(), symTab, and llvm::sys::Path::toString(). Referenced by llvm::Linker::LinkInArchive(). |
|
|
Load the entire archive.
Definition at line 251 of file ArchiveReader.cpp. References checkSignature(), llvm::iplist< NodeTy, Traits >::clear(), firstFileOffset, foreignST, llvm::MemoryBuffer::getBufferEnd(), llvm::ArchiveMember::getData(), llvm::ArchiveMember::getSize(), llvm::ArchiveMember::isBSD4SymbolTable(), llvm::ArchiveMember::isLLVMSymbolTable(), llvm::ArchiveMember::isStringTable(), llvm::ArchiveMember::isSVR4SymbolTable(), mapfile, members, parseMemberHeader(), parseSymbolTable(), llvm::iplist< NodeTy, Traits >::push_back(), strtab, and symTab. Referenced by isBitcodeArchive(). |
|
|
Load just the symbol table.
Definition at line 364 of file ArchiveReader.cpp. References checkSignature(), llvm::iplist< NodeTy, Traits >::clear(), firstFileOffset, llvm::MemoryBuffer::getBufferEnd(), llvm::ArchiveMember::getData(), llvm::ArchiveMember::getSize(), llvm::ArchiveMember::isBSD4SymbolTable(), llvm::ArchiveMember::isLLVMSymbolTable(), llvm::ArchiveMember::isStringTable(), llvm::ArchiveMember::isSVR4SymbolTable(), mapfile, members, parseMemberHeader(), parseSymbolTable(), llvm::iplist< NodeTy, Traits >::push_back(), strtab, and symTab. Referenced by isBitcodeArchive(). |
|
|
Maps archive into memory.
Definition at line 147 of file Archive.cpp. References archPath, base, llvm::sys::Path::c_str(), llvm::MemoryBuffer::getBufferStart(), llvm::MemoryBuffer::getFile(), and mapfile. |
|
||||||||||||
|
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 329 of file ArchiveReader.cpp. References Archive(). |
|
||||||||||||
|
Open an existing archive and load its symbols.
This method opens an existing archive file from
Definition at line 443 of file ArchiveReader.cpp. References Archive(). |
|
||||||||||||||||
|
||||||||||||||||
|
Parse the symbol table at
Definition at line 37 of file ArchiveReader.cpp. References readInteger(), symTab, and symTabSize. Referenced by loadArchive(), and loadSymbolTable(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||||||||
|
Move a member to a new location.
This method splices a Definition at line 260 of file Archive.h. References members. |
|
||||||||||||||||||||||||||||
|
Writes one ArchiveMember to an ofstream. If an error occurs, returns false, otherwise true. If an error occurs and error is non-null then it will be set to an error message.
Definition at line 197 of file ArchiveWriter.cpp. References archPath, llvm::sys::Path::c_str(), fillHeader(), llvm::GetBitcodeSymbols(), llvm::MemoryBuffer::getBufferSize(), llvm::MemoryBuffer::getBufferStart(), llvm::ArchiveMember::getData(), llvm::MemoryBuffer::getFile(), llvm::ArchiveMember::getPath(), llvm::ArchiveMember::getSize(), llvm::ArchiveMember::isBitcode(), numVbrBytes(), symTab, symTabSize, and llvm::sys::Path::toString(). Referenced by writeToDisk(). |
|
|
Write the symbol table to an ofstream.
Definition at line 287 of file ArchiveWriter.cpp. References ARFILE_LLVM_SYMTAB_NAME, llvm::ArchiveMemberHeader::date, llvm::ArchiveMemberHeader::gid, llvm::ArchiveMemberHeader::init(), llvm::ArchiveMemberHeader::mode, llvm::ArchiveMemberHeader::name, llvm::sys::TimeValue::now(), llvm::ArchiveMemberHeader::size, symTab, symTabSize, llvm::sys::TimeValue::toEpochTime(), llvm::ArchiveMemberHeader::uid, 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 341 of file ArchiveWriter.cpp. References archPath, ARFILE_MAGIC, base, begin(), llvm::sys::Path::c_str(), cleanUpMemory(), llvm::sys::Path::clear(), llvm::Compress(), llvm::sys::Path::createTemporaryFileOnDisk(), llvm::iplist< NodeTy, Traits >::empty(), end(), llvm::sys::Path::eraseFromDisk(), llvm::sys::Path::exists(), foreignST, llvm::MemoryBuffer::getBufferSize(), llvm::sys::Path::makeReadableOnDisk(), llvm::sys::Path::makeWriteableOnDisk(), mapfile, members, llvm::sys::RemoveFileOnSignal(), llvm::sys::Path::renamePathOnDisk(), symTab, symTabSize, llvm::sys::Path::toString(), writeMember(), and writeSymbolTable(). |
|
|
Path to the archive file we read/write.
Definition at line 523 of file Archive.h. Referenced by findModuleDefiningSymbol(), findModulesDefiningSymbols(), getAllModules(), isBitcodeArchive(), mapToMemory(), writeMember(), and writeToDisk(). |
|
|
Base of the memory mapped file data.
Definition at line 526 of file Archive.h. Referenced by checkSignature(), cleanUpMemory(), findModuleDefiningSymbol(), findModulesDefiningSymbols(), mapToMemory(), and writeToDisk(). |
|
|
Offset to first normal file.
Definition at line 530 of file Archive.h. Referenced by cleanUpMemory(), loadArchive(), and loadSymbolTable(). |
|
|
This holds the foreign symbol table. Definition at line 532 of file Archive.h. Referenced by cleanUpMemory(), loadArchive(), and writeToDisk(). |
|
|
Raw Archive contents mapped into memory.
Definition at line 525 of file Archive.h. Referenced by checkSignature(), cleanUpMemory(), findModuleDefiningSymbol(), findModulesDefiningSymbols(), loadArchive(), loadSymbolTable(), mapToMemory(), and writeToDisk(). |
|
|
The ilist of ArchiveMember.
Definition at line 524 of file Archive.h. Referenced by addFileBefore(), loadArchive(), loadSymbolTable(), splice(), and writeToDisk(). |
|
|
The modules loaded via symbol lookup.
Definition at line 531 of file Archive.h. Referenced by cleanUpMemory(), findModuleDefiningSymbol(), and findModulesDefiningSymbols(). |
|
|
The string table for long file names.
Definition at line 528 of file Archive.h. Referenced by loadArchive(), loadSymbolTable(), and parseMemberHeader(). |
|
|
The symbol table.
Definition at line 527 of file Archive.h. Referenced by cleanUpMemory(), findModuleDefiningSymbol(), findModulesDefiningSymbols(), isBitcodeArchive(), loadArchive(), loadSymbolTable(), parseSymbolTable(), writeMember(), writeSymbolTable(), and writeToDisk(). |
|
|
Size in bytes of symbol table.
Definition at line 529 of file Archive.h. Referenced by cleanUpMemory(), parseSymbolTable(), |