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   class LLVMContext;
00035 
00036   /// The ArchiveMemberHeader structure is used internally for bitcode
00037   /// archives.
00038   /// The header precedes each file member in the archive. This structure is
00039   /// defined using character arrays for direct and correct interpretation
00040   /// regardless of the endianess of the machine that produced it.
00041   /// @brief Archive File Member Header
00042   class ArchiveMemberHeader {
00043     /// @name Data
00044     /// @{
00045     public:
00046       char name[16];  ///< Name of the file member.
00047       char date[12];  ///< File date, decimal seconds since Epoch
00048       char uid[6];    ///< user id in ASCII decimal
00049       char gid[6];    ///< group id in ASCII decimal
00050       char mode[8];   ///< file mode in ASCII octal
00051       char size[10];  ///< file size in ASCII decimal
00052       char fmag[2];   ///< Always contains ARFILE_MAGIC_TERMINATOR
00053 
00054     /// @}
00055     /// @name Methods
00056     /// @{
00057     public:
00058     void init() {
00059       memset(name,' ',16);
00060       memset(date,' ',12);
00061       memset(uid,' ',6);
00062       memset(gid,' ',6);
00063       memset(mode,' ',8);
00064       memset(size,' ',10);
00065       fmag[0] = '`';
00066       fmag[1] = '\n';
00067     }
00068 
00069     bool checkSignature() {
00070       return 0 == memcmp(fmag, ARFILE_MEMBER_MAGIC,2);
00071     }
00072   };
00073   
00074   // Get just the externally visible defined symbols from the bitcode
00075   bool GetBitcodeSymbols(const sys::Path& fName,
00076                           LLVMContext& Context,
00077                           std::vector<std::string>& symbols,
00078                           std::string* ErrMsg);
00079   
00080   ModuleProvider* GetBitcodeSymbols(const unsigned char*Buffer,unsigned Length,
00081                                     const std::string& ModuleID,
00082                                     LLVMContext& Context,
00083                                     std::vector<std::string>& symbols,
00084                                     std::string* ErrMsg);
00085 }
00086 
00087 #endif
00088 
00089 // vim: sw=2 ai