X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fllvm-ar%2FArchive.h;h=52622dde3510a8368ba5b32f8aaf8c0814fab088;hb=0a230e0d985625a3909cb78fd867a3abaf434565;hp=2357b13d6300c1ad187eda19943f765e6b48198e;hpb=27ff1f3f7d9a20e02e00fe88dbb7541ce066d33c;p=oota-llvm.git diff --git a/tools/llvm-ar/Archive.h b/tools/llvm-ar/Archive.h index 2357b13d630..52622dde351 100644 --- a/tools/llvm-ar/Archive.h +++ b/tools/llvm-ar/Archive.h @@ -20,9 +20,11 @@ #include "llvm/ADT/ilist.h" #include "llvm/ADT/ilist_node.h" #include "llvm/Support/Path.h" -#include "llvm/Support/PathV1.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/Support/TimeValue.h" #include #include +#include namespace llvm { class MemoryBuffer; @@ -50,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 }; /// @} @@ -72,28 +72,28 @@ class ArchiveMember : public ilist_node { /// have any applicability on non-Unix systems but is a required component /// of the "ar" file format. /// @brief Get the user associated with this archive member. - unsigned getUser() const { return info.getUser(); } + unsigned getUser() const { return User; } /// The "group" is the owning group of the file per Unix security. This /// may not have any applicability on non-Unix systems but is a required /// component of the "ar" file format. /// @brief Get the group associated with this archive member. - unsigned getGroup() const { return info.getGroup(); } + unsigned getGroup() const { return Group; } /// The "mode" specifies the access permissions for the file per Unix /// security. This may not have any applicability on non-Unix systems but is /// a required component of the "ar" file format. /// @brief Get the permission mode associated with this archive member. - unsigned getMode() const { return info.getMode(); } + unsigned getMode() const { return Mode; } /// This method returns the time at which the archive member was last /// modified when it was not in the archive. /// @brief Get the time of last modification of the archive member. - sys::TimeValue getModTime() const { return info.getTimestamp(); } + sys::TimeValue getModTime() const { return ModTime; } /// @returns the size of the archive member in bytes. /// @brief Get the size of the archive member. - uint64_t getSize() const { return info.getSize(); } + uint64_t getSize() const { return Size; } /// This method returns the total size of the archive member as it /// appears on disk. This includes the file content, the header, the @@ -120,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 @@ -149,11 +141,15 @@ class ArchiveMember : public ilist_node { /// @name Data /// @{ private: - Archive* parent; ///< Pointer to parent archive - std::string path; ///< Path of file containing the member - sys::FileStatus info; ///< Status info (size,mode,date) - unsigned flags; ///< Flags about the archive member - const char* data; ///< Data for the member + Archive *parent; ///< Pointer to parent archive + std::string path; ///< Path of file containing the member + uint32_t User; + uint32_t Group; + uint32_t Mode; + sys::TimeValue ModTime; + uint64_t Size; + unsigned flags; ///< Flags about the archive member + const char *data; ///< Data for the member /// @} /// @name Constructors @@ -296,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 @@ -318,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 /// @{ @@ -385,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 ); @@ -439,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); @@ -471,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