LLVM API Documentation

ArchiveInternals.h

Go to the documentation of this file.
00001 //===-- lib/Archive/ArchiveInternals.h -------------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // Internal implementation header for LLVM Archive files.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LIB_ARCHIVE_ARCHIVEINTERNALS_H
00015 #define LIB_ARCHIVE_ARCHIVEINTERNALS_H
00016 
00017 #include "llvm/Bitcode/Archive.h"
00018 #include "llvm/System/TimeValue.h"
00019 #include "llvm/ADT/StringExtras.h"
00020 
00021 #include <cstring>
00022 
00023 #define ARFILE_MAGIC "!<arch>\n"                   ///< magic string
00024 #define ARFILE_MAGIC_LEN (sizeof(ARFILE_MAGIC)-1)  ///< length of magic string
00025 #define ARFILE_SVR4_SYMTAB_NAME "/               " ///< SVR4 symtab entry name
00026 #define ARFILE_LLVM_SYMTAB_NAME "#_LLVM_SYM_TAB_#" ///< LLVM symtab entry name
00027 #define ARFILE_BSD4_SYMTAB_NAME "__.SYMDEF SORTED" ///< BSD4 symtab entry name
00028 #define ARFILE_STRTAB_NAME      "//              " ///< Name of string table
00029 #define ARFILE_PAD "\n"                            ///< inter-file align padding
00030 #define ARFILE_MEMBER_MAGIC "`\n"                  ///< fmag field magic #
00031 
00032 namespace llvm {
00033 
00034   /// The ArchiveMemberHeader structure is used internally for bitcode
00035   /// archives.
00036   /// The header precedes each file member in the archive. This structure is
00037   /// defined using character arrays for direct and correct interpretation
00038   /// regardless of the endianess of the machine that produced it.
00039   /// @brief Archive File Member Header
00040   class ArchiveMemberHeader {
00041     /// @name Data
00042     /// @{
00043     public:
00044       char name[16];  ///< Name of the file member.
00045       char date[12];  ///< File date, decimal seconds since Epoch
00046       char uid[6];    ///< user id in ASCII decimal
00047       char gid[6];    ///< group id in ASCII decimal
00048       char mode[8];   ///< file mode in ASCII octal
00049       char size[10];  ///< file size in ASCII decimal
00050       char fmag[2];   ///< Always contains ARFILE_MAGIC_TERMINATOR
00051 
00052     /// @}
00053     /// @name Methods
00054     /// @{
00055     public:
00056     void init() {
00057       memset(name,' ',16);
00058       memset(date,' ',12);
00059       memset(uid,' ',6);
00060       memset(gid,' ',6);
00061       memset(mode,' ',8);
00062       memset(size,' ',10);
00063       fmag[0] = '`';
00064       fmag[1] = '\n';
00065     }
00066 
00067     bool checkSignature() {
00068       return 0 == memcmp(fmag, ARFILE_MEMBER_MAGIC,2);
00069     }
00070   };
00071   
00072   // Get just the externally visible defined symbols from the bitcode
00073   bool GetBitcodeSymbols(const sys::Path& fName,
00074                           std::vector<std::string>& symbols,
00075                           std::string* ErrMsg);
00076   
00077   ModuleProvider* GetBitcodeSymbols(const unsigned char*Buffer,unsigned Length,
00078                                     const std::string& ModuleID,
00079                                     std::vector<std::string>& symbols,
00080                                     std::string* ErrMsg);
00081 }
00082 
00083 #endif
00084 
00085 // vim: sw=2 ai