LLVM API Documentation
#include <Archive.h>

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. | |
| Module * | findModuleDefiningSymbol (const std::string &symbol, std::string *ErrMessage) |
| Look up a module by symbol name. | |
| bool | findModulesDefiningSymbols (std::set< std::string > &symbols, SmallVectorImpl< Module * > &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, 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 |
| This holds the foreign symbol table. | |
| LLVMContext & | Context |
Constructors | |
| ~Archive () | |
| Destruct in-memory archive. | |
| static Archive * | CreateEmpty (const sys::Path &Filename, LLVMContext &C) |
| Create an empty Archive. | |
| static Archive * | OpenAndLoad (const sys::Path &filePath, LLVMContext &C, std::string *ErrorMessage) |
| Open and load an archive file. | |
| static Archive * | OpenAndLoadSymbols (const sys::Path &Filename, LLVMContext &C, std::string *ErrorMessage=0) |
| Open an existing archive and load its symbols. | |
Implementation | |
| typedef std::map< unsigned, std::pair< Module *, ArchiveMember * > > | ModuleMap |
| Module mapping type. | |
| Archive (const sys::Path &filename, LLVMContext &C) | |
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, 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. | |
This class defines the interface to LLVM Archive files. The Archive class presents the archive file as an ilist of ArchiveMember objects. The members can be rearranged in any fashion either by directly editing the ilist or by using editing methods on the Archive class (recommended). The Archive class also provides several ways of accessing the archive file for various purposes such as editing and linking. Full symbol table support is provided for loading only those files that resolve symbols. Note that read performance of this library is _crucial_ for performance of JIT type applications and the linkers. Consequently, the implementation of the class is optimized for reading.
Definition at line 199 of file Bitcode/Archive.h.
Forward immutable iterator over ArchiveMember.
Definition at line 213 of file Bitcode/Archive.h.
| typedef std::reverse_iterator<const_iterator> llvm::Archive::const_reverse_iterator |
Reverse immutable iterator over ArchiveMember.
Definition at line 219 of file Bitcode/Archive.h.
Forward mutable iterator over ArchiveMember.
Definition at line 210 of file Bitcode/Archive.h.
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
Definition at line 207 of file Bitcode/Archive.h.
typedef std::map<unsigned,std::pair<Module*,ArchiveMember*> > llvm::Archive::ModuleMap [protected] |
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 Module.
Definition at line 508 of file Bitcode/Archive.h.
| typedef std::reverse_iterator<iterator> llvm::Archive::reverse_iterator |
Reverse mutable iterator over ArchiveMember.
Definition at line 216 of file Bitcode/Archive.h.
| typedef std::map<std::string,unsigned> llvm::Archive::SymTabType |
The in-memory version of the symbol table.
Definition at line 222 of file Bitcode/Archive.h.
| Archive::~Archive | ( | ) |
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 191 of file Archive/Archive.cpp.
References cleanUpMemory().
| Archive::Archive | ( | const sys::Path & | filename, |
| LLVMContext & | C | ||
| ) | [explicit, protected] |
Construct an Archive for filename and optionally map it into memory.
Definition at line 146 of file Archive/Archive.cpp.
Add a file to the archive.
This method adds a new file to the archive. The filename is examined to determine just enough information to create an ArchiveMember object which is then inserted into the Archive object's ilist at the location given by where.
| filename | The file to be added |
| where | Insertion point |
| ErrMsg | Optional error message location |
Definition at line 159 of file ArchiveWriter.cpp.
References llvm::sys::fs::file_magic::bitcode, llvm::ArchiveMember::BitcodeFlag, llvm::sys::fs::exists(), llvm::sys::PathWithStatus::getFileStatus(), llvm::ArchiveMember::HasLongFilenameFlag, llvm::ArchiveMember::HasPathFlag, llvm::sys::fs::identify_magic(), llvm::iplist< NodeTy, Traits >::insert(), members, llvm::sys::Path::str(), and llvm::sys::fs::file_magic::unknown.
| const ArchiveMember& llvm::Archive::back | ( | ) | const [inline] |
Definition at line 242 of file Bitcode/Archive.h.
References llvm::iplist< NodeTy, Traits >::back(), and members.
| ArchiveMember& llvm::Archive::back | ( | ) | [inline] |
Definition at line 243 of file Bitcode/Archive.h.
References llvm::iplist< NodeTy, Traits >::back(), and members.
| iterator llvm::Archive::begin | ( | ) | [inline] |
Definition at line 228 of file Bitcode/Archive.h.
References llvm::iplist< NodeTy, Traits >::begin(), and members.
Referenced by getAllModules(), isBitcodeArchive(), and writeToDisk().
| const_iterator llvm::Archive::begin | ( | ) | const [inline] |
Definition at line 229 of file Bitcode/Archive.h.
References llvm::iplist< NodeTy, Traits >::begin(), and members.
| bool Archive::checkSignature | ( | std::string * | ErrMessage | ) | [protected] |
Check that the archive signature is correct.
| ErrMessage | Set to address of a std::string to get error messages |
Definition at line 237 of file ArchiveReader.cpp.
References ARFILE_MAGIC, base, llvm::MemoryBuffer::getBufferSize(), mapfile, and llvm::LibFunc::memcmp.
Referenced by loadArchive(), and loadSymbolTable().
| void Archive::cleanUpMemory | ( | ) | [protected] |
Frees all the members and unmaps the archive file.
Definition at line 164 of file Archive/Archive.cpp.
References base, firstFileOffset, foreignST, I, mapfile, modules, symTab, and symTabSize.
Referenced by writeToDisk(), and ~Archive().
| Archive * Archive::CreateEmpty | ( | const sys::Path & | Filename, |
| LLVMContext & | C | ||
| ) | [static] |
Create an empty Archive.
Create an empty archive file and associate it with the Filename. This method does not actually create the archive disk file. It creates an empty Archive object. If the writeToDisk method is called, the archive file Filename will be created at that point, with whatever content the returned Archive object has at that time.
| Filename | Name of the archive to (eventually) create. |
| C | Context to use for global information |
Definition at line 70 of file ArchiveWriter.cpp.
| bool llvm::Archive::empty | ( | ) | const [inline] |
Definition at line 239 of file Bitcode/Archive.h.
References llvm::iplist< NodeTy, Traits >::empty(), and members.
| iterator llvm::Archive::end | ( | ) | [inline] |
Definition at line 230 of file Bitcode/Archive.h.
References llvm::iplist< NodeTy, Traits >::end(), and members.
Referenced by getAllModules(), isBitcodeArchive(), and writeToDisk().
| const_iterator llvm::Archive::end | ( | ) | const [inline] |
Definition at line 231 of file Bitcode/Archive.h.
References llvm::iplist< NodeTy, Traits >::end(), and members.
Erase a member.
This method erases a target member from the archive. When the archive is written, it will no longer contain target. The associated ArchiveMember is deleted.
Definition at line 260 of file Bitcode/Archive.h.
References llvm::iplist< NodeTy, Traits >::erase(), and members.
| bool Archive::fillHeader | ( | const ArchiveMember & | mbr, |
| ArchiveMemberHeader & | hdr, | ||
| int | sz, | ||
| bool | TruncateNames | ||
| ) | const [protected] |
Fill in an ArchiveMemberHeader from ArchiveMember.
Definition at line 82 of file ArchiveWriter.cpp.
References ARFILE_BSD4_SYMTAB_NAME, ARFILE_LLVM_SYMTAB_NAME, ARFILE_STRTAB_NAME, ARFILE_SVR4_SYMTAB_NAME, llvm::ArchiveMember::getGroup(), llvm::ArchiveMember::getMode(), llvm::ArchiveMember::getModTime(), llvm::ArchiveMember::getPath(), llvm::ArchiveMember::getUser(), llvm::ArchiveMember::isBSD4SymbolTable(), llvm::ArchiveMember::isLLVMSymbolTable(), llvm::ArchiveMember::isStringTable(), llvm::ArchiveMember::isSVR4SymbolTable(), llvm::LibFunc::memcpy, llvm::LibFunc::sprintf, llvm::sys::Path::str(), llvm::sys::TimeValue::toEpochTime(), and llvm::utostr().
Referenced by writeMember().
| Module * Archive::findModuleDefiningSymbol | ( | const std::string & | symbol, |
| std::string * | ErrMessage | ||
| ) |
Look up a module by symbol name.
This accessor looks up the symbol in the archive's symbol table and returns the associated module that defines that symbol. This method can be called as many times as necessary. This is handy for linking the archive into another module based on unresolved symbols. Note that the Module returned by this accessor should not be deleted by the caller. It is managed internally by the Archive class. It is possible that multiple calls to this accessor will return the same Module instance because the associated module defines multiple symbols.
symbol. | symbol | Symbol to be sought |
| ErrMessage | Error message storage, if non-zero |
Definition at line 457 of file ArchiveReader.cpp.
References archPath, base, Context, firstFileOffset, llvm::MemoryBuffer::getBufferEnd(), llvm::getLazyBitcodeModule(), llvm::MemoryBuffer::getMemBufferCopy(), mapfile, llvm::A64CC::MI, modules, parseMemberHeader(), llvm::sys::Path::str(), and symTab.
Referenced by findModulesDefiningSymbols().
| bool Archive::findModulesDefiningSymbols | ( | std::set< std::string > & | symbols, |
| SmallVectorImpl< Module * > & | modules, | ||
| std::string * | ErrMessage | ||
| ) |
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 symbols contains a list of undefined symbols in some module, then calling this method is like making one complete pass through the archive to resolve symbols but is more efficient than looking at the individual members. Note that on exit, the symbols resolved by this method will be removed from symbols to ensure they are not re-searched on a subsequent call. If you need to retain the list of symbols, make a copy.
| symbols | Symbols to be sought |
| modules | The modules matching symbols |
| ErrMessage | Error msg storage, if non-zero |
Definition at line 504 of file ArchiveReader.cpp.
References archPath, base, Context, findModuleDefiningSymbol(), firstFileOffset, llvm::GetBitcodeSymbols(), llvm::MemoryBuffer::getBufferEnd(), llvm::ArchiveMember::getPath(), llvm::ArchiveMember::getSize(), I, llvm::SmallPtrSet< PtrType, SmallSize >::insert(), llvm::ArchiveMember::isBitcode(), mapfile, modules, parseMemberHeader(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::sys::Path::str(), and symTab.
| const ArchiveMember& llvm::Archive::front | ( | ) | const [inline] |
Definition at line 240 of file Bitcode/Archive.h.
References llvm::iplist< NodeTy, Traits >::front(), and members.
| ArchiveMember& llvm::Archive::front | ( | ) | [inline] |
Definition at line 241 of file Bitcode/Archive.h.
References llvm::iplist< NodeTy, Traits >::front(), and members.
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 Modules. If an error occurs, this method will return true. If ErrMessage is not null and an error occurs, *ErrMessage will be set to a string explaining the error that occurred.
Definition at line 341 of file ArchiveReader.cpp.
References archPath, begin(), Context, end(), llvm::MemoryBuffer::getMemBufferCopy(), I, llvm::ParseBitcodeFile(), and llvm::sys::Path::str().
| unsigned llvm::Archive::getFirstFileOffset | ( | ) | [inline] |
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 353 of file Bitcode/Archive.h.
References firstFileOffset.
| MembersList& llvm::Archive::getMembers | ( | ) | [inline] |
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 331 of file Bitcode/Archive.h.
References members.
| const sys::Path& llvm::Archive::getPath | ( | ) | [inline] |
Get the archive path.
Definition at line 324 of file Bitcode/Archive.h.
References archPath.
| const SymTabType& llvm::Archive::getSymbolTable | ( | ) | [inline] |
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 345 of file Bitcode/Archive.h.
References symTab.
| bool Archive::isBitcodeArchive | ( | ) |
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 successful.
Definition at line 594 of file ArchiveReader.cpp.
References archPath, begin(), Context, end(), llvm::MemoryBuffer::getMemBufferCopy(), I, loadArchive(), loadSymbolTable(), llvm::ParseBitcodeFile(), llvm::sys::Path::str(), and symTab.
| bool Archive::loadArchive | ( | std::string * | ErrMessage | ) | [protected] |
Load the entire archive.
| ErrMessage | Set to address of a std::string to get error messages |
Definition at line 251 of file ArchiveReader.cpp.
References base, 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().
| bool Archive::loadSymbolTable | ( | std::string * | ErrMessage | ) | [protected] |
Load just the symbol table.
| ErrMessage | Set to address of a std::string to get error messages |
Definition at line 365 of file ArchiveReader.cpp.
References base, 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().
| bool Archive::mapToMemory | ( | std::string * | ErrMsg | ) | [protected] |
Maps archive into memory.
Definition at line 152 of file Archive/Archive.cpp.
References archPath, base, llvm::sys::Path::c_str(), ARMBuildAttrs::File, llvm::MemoryBuffer::getBufferStart(), llvm::MemoryBuffer::getFile(), mapfile, and llvm::OwningPtr< T >::take().
| Archive * Archive::OpenAndLoad | ( | const sys::Path & | filePath, |
| LLVMContext & | C, | ||
| std::string * | ErrorMessage | ||
| ) | [static] |
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).
| filePath | The file path to open and load |
| C | The context to use for global information |
| ErrorMessage | An optional error string |
Definition at line 329 of file ArchiveReader.cpp.
References llvm::OwningPtr< T >::take().
| Archive * Archive::OpenAndLoadSymbols | ( | const sys::Path & | Filename, |
| LLVMContext & | C, | ||
| std::string * | ErrorMessage = 0 |
||
| ) | [static] |
Open an existing archive and load its symbols.
This method opens an existing archive file from Filename and reads in its symbol table without reading in any of the archive's members. This reduces both I/O and cpu time in opening the archive if it is to be used solely for symbol lookup (e.g. during linking). The Filename must exist and be an archive file or an error will be returned. This form of opening the archive is intended for read-only operations that need to locate members via the symbol table for link editing. Since the archve members are not read by this method, the archive will appear empty upon return. If editing operations are performed on the archive, they will completely replace the contents of the archive! It is recommended that if this form of opening the archive is used that only the symbol table lookup methods (getSymbolTable, findModuleDefiningSymbol, and findModulesDefiningSymbols) be used.
| Filename | Name of the archive file to open |
| C | The context to use for global info |
| ErrorMessage | An optional error string |
Definition at line 443 of file ArchiveReader.cpp.
References llvm::OwningPtr< T >::take().
| ArchiveMember * Archive::parseMemberHeader | ( | const char *& | At, |
| const char * | End, | ||
| std::string * | error | ||
| ) | [protected] |
Parse the header of a member starting at At.
| At | The pointer to the location we're parsing |
| End | The pointer to the end of the archive |
| error | Optional error message catcher |
Definition at line 74 of file ArchiveReader.cpp.
References ARFILE_BSD4_SYMTAB_NAME, ARFILE_LLVM_SYMTAB_NAME, ARFILE_STRTAB_NAME, ARFILE_SVR4_SYMTAB_NAME, llvm::LibFunc::atoi, llvm::sys::Bitcode_FileType, llvm::ArchiveMember::BitcodeFlag, llvm::ArchiveMember::BSD4SymbolTableFlag, llvm::sys::FileStatus::fileSize, llvm::sys::TimeValue::fromEpochTime(), llvm::sys::FileStatus::group, llvm::ArchiveMember::HasLongFilenameFlag, llvm::sys::IdentifyFileType(), llvm::LibFunc::isdigit, llvm::ArchiveMember::LLVMSymbolTableFlag, llvm::LibFunc::memchr, llvm::LibFunc::memcmp, llvm::sys::FileStatus::mode, llvm::sys::FileStatus::modTime, llvm::sys::Path::set(), llvm::LibFunc::sscanf, llvm::ArchiveMember::StringTableFlag, strtab, llvm::ArchiveMember::SVR4SymbolTableFlag, and llvm::sys::FileStatus::user.
Referenced by findModuleDefiningSymbol(), findModulesDefiningSymbols(), loadArchive(), and loadSymbolTable().
Parse the symbol table at data.
| data | The symbol table data to be parsed |
| len | The length of the symbol table data |
| error | Set to address of a std::string to get error messages |
Definition at line 41 of file ArchiveReader.cpp.
References readInteger(), size(), symTab, and symTabSize.
Referenced by loadArchive(), and loadSymbolTable().
| reverse_iterator llvm::Archive::rbegin | ( | ) | [inline] |
Definition at line 233 of file Bitcode/Archive.h.
References members, and llvm::iplist< NodeTy, Traits >::rbegin().
| const_reverse_iterator llvm::Archive::rbegin | ( | ) | const [inline] |
Definition at line 234 of file Bitcode/Archive.h.
References members, and llvm::iplist< NodeTy, Traits >::rbegin().
| reverse_iterator llvm::Archive::rend | ( | ) | [inline] |
Definition at line 235 of file Bitcode/Archive.h.
References members, and llvm::iplist< NodeTy, Traits >::rend().
| const_reverse_iterator llvm::Archive::rend | ( | ) | const [inline] |
Definition at line 236 of file Bitcode/Archive.h.
References members, and llvm::iplist< NodeTy, Traits >::rend().
| size_t llvm::Archive::size | ( | ) | const [inline] |
Definition at line 238 of file Bitcode/Archive.h.
References members, and llvm::iplist< NodeTy, Traits >::size().
Referenced by parseSymbolTable().
Move a member to a new location.
This method splices a src member from an archive (possibly this), to a position just before the member given by dest in this. When the archive is written, src will be written in its new location.
Definition at line 253 of file Bitcode/Archive.h.
References members, and llvm::iplist< NodeTy, Traits >::splice().
| bool Archive::writeMember | ( | const ArchiveMember & | member, |
| std::ofstream & | ARFile, | ||
| bool | CreateSymbolTable, | ||
| bool | TruncateNames, | ||
| std::string * | ErrMessage | ||
| ) | [protected] |
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.
error set to error message. | member | The member to be written |
| ARFile | The file to write member onto |
| CreateSymbolTable | Should symbol table be created? |
| TruncateNames | Should names be truncated to 11 chars? |
| ErrMessage | If non-null, place were error msg is set |
Definition at line 203 of file ArchiveWriter.cpp.
References archPath, ARFILE_PAD, llvm::sys::Path::c_str(), Context, ARMBuildAttrs::File, 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(), llvm::sys::Path::str(), symTab, symTabSize, and llvm::OwningPtr< T >::take().
Referenced by writeToDisk().
| void Archive::writeSymbolTable | ( | std::ofstream & | ARFile | ) | [protected] |
Write the symbol table to an ofstream.
Definition at line 294 of file ArchiveWriter.cpp.
References ARFILE_LLVM_SYMTAB_NAME, ARFILE_PAD, llvm::sys::Process::GetCurrentGroupId(), llvm::sys::Process::GetCurrentUserId(), I, llvm::LibFunc::memcpy, llvm::sys::TimeValue::now(), llvm::LibFunc::sprintf, symTab, symTabSize, llvm::sys::TimeValue::toEpochTime(), and writeInteger().
Referenced by writeToDisk().
| bool Archive::writeToDisk | ( | bool | CreateSymbolTable = false, |
| bool | TruncateNames = false, |
||
| std::string * | ErrMessage = 0 |
||
| ) |
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 this was created or opened. The arguments provide options for writing the archive. If CreateSymbolTable is true, the archive is scanned for bitcode files and a symbol table of the externally visible function and global variable names is created. If TruncateNames is true, the names of the archive members will have their path component stripped and the file name will be truncated at 15 characters. If Compress is specified, all archive members will be compressed before being written. If PrintSymTab is true, the symbol table will be printed to std::cout.
error set to error message; returns false if the writing succeeded. | CreateSymbolTable | Create Symbol table |
| TruncateNames | Truncate the filename to 15 chars |
| ErrMessage | If non-null, where error msg is set |
Definition at line 352 of file ArchiveWriter.cpp.
References archPath, ARFILE_MAGIC, base, begin(), llvm::sys::Path::c_str(), cleanUpMemory(), llvm::sys::Path::createTemporaryFileOnDisk(), llvm::iplist< NodeTy, Traits >::empty(), end(), llvm::sys::Path::eraseFromDisk(), foreignST, llvm::MemoryBuffer::getBufferSize(), llvm::MemoryBuffer::getFile(), I, llvm::sys::Path::makeReadableOnDisk(), llvm::sys::Path::makeWriteableOnDisk(), mapfile, members, out, llvm::sys::RemoveFileOnSignal(), llvm::sys::Path::renamePathOnDisk(), llvm::sys::Path::str(), symTab, symTabSize, llvm::LibFunc::trunc, writeMember(), and writeSymbolTable().
sys::Path llvm::Archive::archPath [protected] |
Path to the archive file we read/write.
Definition at line 515 of file Bitcode/Archive.h.
Referenced by findModuleDefiningSymbol(), findModulesDefiningSymbols(), getAllModules(), getPath(), isBitcodeArchive(), mapToMemory(), writeMember(), and writeToDisk().
const char* llvm::Archive::base [protected] |
Base of the memory mapped file data.
Definition at line 518 of file Bitcode/Archive.h.
Referenced by checkSignature(), cleanUpMemory(), findModuleDefiningSymbol(), findModulesDefiningSymbols(), loadArchive(), loadSymbolTable(), mapToMemory(), and writeToDisk().
LLVMContext& llvm::Archive::Context [protected] |
This holds global data.
Definition at line 525 of file Bitcode/Archive.h.
Referenced by findModuleDefiningSymbol(), findModulesDefiningSymbols(), getAllModules(), isBitcodeArchive(), and writeMember().
unsigned llvm::Archive::firstFileOffset [protected] |
Offset to first normal file.
Definition at line 522 of file Bitcode/Archive.h.
Referenced by cleanUpMemory(), findModuleDefiningSymbol(), findModulesDefiningSymbols(), getFirstFileOffset(), loadArchive(), and loadSymbolTable().
ArchiveMember* llvm::Archive::foreignST [protected] |
This holds the foreign symbol table.
Definition at line 524 of file Bitcode/Archive.h.
Referenced by cleanUpMemory(), loadArchive(), and writeToDisk().
MemoryBuffer* llvm::Archive::mapfile [protected] |
Raw Archive contents mapped into memory.
Definition at line 517 of file Bitcode/Archive.h.
Referenced by checkSignature(), cleanUpMemory(), findModuleDefiningSymbol(), findModulesDefiningSymbols(), loadArchive(), loadSymbolTable(), mapToMemory(), and writeToDisk().
MembersList llvm::Archive::members [protected] |
The ilist of ArchiveMember.
Definition at line 516 of file Bitcode/Archive.h.
Referenced by addFileBefore(), back(), begin(), empty(), end(), erase(), front(), getMembers(), loadArchive(), loadSymbolTable(), rbegin(), rend(), size(), splice(), and writeToDisk().
ModuleMap llvm::Archive::modules [protected] |
The modules loaded via symbol lookup.
Definition at line 523 of file Bitcode/Archive.h.
Referenced by cleanUpMemory(), findModuleDefiningSymbol(), and findModulesDefiningSymbols().
std::string llvm::Archive::strtab [protected] |
The string table for long file names.
Definition at line 520 of file Bitcode/Archive.h.
Referenced by loadArchive(), loadSymbolTable(), and parseMemberHeader().
SymTabType llvm::Archive::symTab [protected] |
The symbol table.
Definition at line 519 of file Bitcode/Archive.h.
Referenced by cleanUpMemory(), findModuleDefiningSymbol(), findModulesDefiningSymbols(), getSymbolTable(), isBitcodeArchive(), loadArchive(), loadSymbolTable(), parseSymbolTable(), writeMember(), writeSymbolTable(), and writeToDisk().
unsigned llvm::Archive::symTabSize [protected] |
Size in bytes of symbol table.
Definition at line 521 of file Bitcode/Archive.h.
Referenced by cleanUpMemory(), parseSymbolTable(), writeMember(), writeSymbolTable(), and writeToDisk().