X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fllvm-ar%2FArchive.h;h=52622dde3510a8368ba5b32f8aaf8c0814fab088;hb=0a230e0d985625a3909cb78fd867a3abaf434565;hp=0fe72f42053cf2a03300c71a9f2089189ddb9164;hpb=63e8ba9bcf1d83422f56ae2454dbd7190c1e2a41;p=oota-llvm.git diff --git a/tools/llvm-ar/Archive.h b/tools/llvm-ar/Archive.h index 0fe72f42053..52622dde351 100644 --- a/tools/llvm-ar/Archive.h +++ b/tools/llvm-ar/Archive.h @@ -20,6 +20,7 @@ #include "llvm/ADT/ilist.h" #include "llvm/ADT/ilist_node.h" #include "llvm/Support/Path.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Support/TimeValue.h" #include #include @@ -51,10 +52,8 @@ class ArchiveMember : public ilist_node { enum Flags { SVR4SymbolTableFlag = 1, ///< Member is a SVR4 symbol table BSD4SymbolTableFlag = 2, ///< Member is a BSD4 symbol table - BitcodeFlag = 4, ///< Member is bitcode - HasPathFlag = 8, ///< Member has a full or partial path - HasLongFilenameFlag = 16, ///< Member uses the long filename syntax - StringTableFlag = 32 ///< Member is an ar(1) format string table + HasLongFilenameFlag = 8, ///< Member uses the long filename syntax + StringTableFlag = 16 ///< Member is an ar(1) format string table }; /// @} @@ -121,14 +120,6 @@ class ArchiveMember : public ilist_node { /// @brief Determine if this member is the ar(1) string table. bool isStringTable() const { return flags&StringTableFlag; } - /// @returns true iff the archive member is a bitcode file. - /// @brief Determine if this member is a bitcode file. - bool isBitcode() const { return flags&BitcodeFlag; } - - /// @returns true iff the file name contains a path (directory) component. - /// @brief Determine if the member has a path - bool hasPath() const { return flags&HasPathFlag; } - /// Long filenames are an artifact of the ar(1) file format which allows /// up to sixteen characters in its header and doesn't allow a path /// separator character (/). To avoid this, a "long format" member name is @@ -301,20 +292,6 @@ class Archive { /// @brief Get the iplist of the members MembersList& getMembers() { return members; } - /// 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. - /// @returns the Archive's symbol table. - /// @brief Get the archive's symbol table - const SymTabType& getSymbolTable() { return symTab; } - /// 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 @@ -323,55 +300,6 @@ class Archive { /// @brief Get the offset to the first "real" file member in the archive. unsigned getFirstFileOffset() { return firstFileOffset; } - /// This method will scan the archive for bitcode modules, interpret them - /// and return a vector of the instantiated modules in \p Modules. If an - /// error occurs, this method will return true. If \p ErrMessage is not null - /// and an error occurs, \p *ErrMessage will be set to a string explaining - /// the error that occurred. - /// @returns true if an error occurred - /// @brief Instantiate all the bitcode modules located in the archive - bool getAllModules(std::vector& Modules, std::string* ErrMessage); - - /// This accessor looks up the \p 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. - /// @returns The Module* found or null if the archive does not contain a - /// module that defines the \p symbol. - /// @brief Look up a module by symbol name. - Module* findModuleDefiningSymbol( - const std::string& symbol, ///< Symbol to be sought - std::string* ErrMessage ///< Error message storage, if non-zero - ); - - /// This method is similar to findModuleDefiningSymbol but allows lookup of - /// more than one symbol at a time. If \p 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 \p - /// symbols to ensure they are not re-searched on a subsequent call. If - /// you need to retain the list of symbols, make a copy. - /// @brief Look up multiple symbols in the archive. - bool findModulesDefiningSymbols( - std::set& symbols, ///< Symbols to be sought - SmallVectorImpl& modules, ///< The modules matching \p symbols - std::string* ErrMessage ///< Error msg storage, if non-zero - ); - - /// 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. - /// @returns true if the archive is a proper llvm bitcode archive - /// @brief Determine whether the archive is a proper llvm bitcode archive. - bool isBitcodeArchive(); - /// @} /// @name Mutators /// @{ @@ -390,8 +318,6 @@ class Archive { /// returns false if the writing succeeded. /// @brief Write (possibly modified) archive contents to disk bool writeToDisk( - bool CreateSymbolTable=false, ///< Create Symbol table - bool TruncateNames=false, ///< Truncate the filename to 15 chars std::string* ErrMessage=0 ///< If non-null, where error msg is set ); @@ -444,15 +370,13 @@ class Archive { /// returns true if writing member failed, \p error set to error message. bool writeMember( const ArchiveMember& member, ///< The member to be written - std::ofstream& ARFile, ///< The file to write member onto - bool CreateSymbolTable, ///< Should symbol table be created? - bool TruncateNames, ///< Should names be truncated to 11 chars? + raw_fd_ostream& ARFile, ///< The file to write member onto std::string* ErrMessage ///< If non-null, place were error msg is set ); /// @brief Fill in an ArchiveMemberHeader from ArchiveMember. bool fillHeader(const ArchiveMember&mbr, - ArchiveMemberHeader& hdr,int sz, bool TruncateNames) const; + ArchiveMemberHeader& hdr,int sz) const; /// @brief Maps archive into memory bool mapToMemory(std::string* ErrMsg); @@ -476,12 +400,9 @@ class Archive { 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; ///< This holds global data. /// @} /// @name Hidden