1 //===-- lib/Archive/ArchiveInternals.h -------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Internal implementation header for LLVM Archive files.
12 //===----------------------------------------------------------------------===//
14 #ifndef LIB_ARCHIVE_ARCHIVEINTERNALS_H
15 #define LIB_ARCHIVE_ARCHIVEINTERNALS_H
17 #include "llvm/ADT/StringExtras.h"
18 #include "llvm/Bitcode/Archive.h"
19 #include "llvm/Support/TimeValue.h"
22 #define ARFILE_MAGIC "!<arch>\n" ///< magic string
23 #define ARFILE_MAGIC_LEN (sizeof(ARFILE_MAGIC)-1) ///< length of magic string
24 #define ARFILE_SVR4_SYMTAB_NAME "/ " ///< SVR4 symtab entry name
25 #define ARFILE_LLVM_SYMTAB_NAME "#_LLVM_SYM_TAB_#" ///< LLVM symtab entry name
26 #define ARFILE_BSD4_SYMTAB_NAME "__.SYMDEF SORTED" ///< BSD4 symtab entry name
27 #define ARFILE_STRTAB_NAME "// " ///< Name of string table
28 #define ARFILE_PAD "\n" ///< inter-file align padding
29 #define ARFILE_MEMBER_MAGIC "`\n" ///< fmag field magic #
35 /// The ArchiveMemberHeader structure is used internally for bitcode
37 /// The header precedes each file member in the archive. This structure is
38 /// defined using character arrays for direct and correct interpretation
39 /// regardless of the endianess of the machine that produced it.
40 /// @brief Archive File Member Header
41 class ArchiveMemberHeader {
45 char name[16]; ///< Name of the file member.
46 char date[12]; ///< File date, decimal seconds since Epoch
47 char uid[6]; ///< user id in ASCII decimal
48 char gid[6]; ///< group id in ASCII decimal
49 char mode[8]; ///< file mode in ASCII octal
50 char size[10]; ///< file size in ASCII decimal
51 char fmag[2]; ///< Always contains ARFILE_MAGIC_TERMINATOR
68 bool checkSignature() const {
69 return 0 == memcmp(fmag, ARFILE_MEMBER_MAGIC,2);
73 // Get just the externally visible defined symbols from the bitcode
74 bool GetBitcodeSymbols(const sys::Path& fName,
76 std::vector<std::string>& symbols,
79 Module* GetBitcodeSymbols(const char *Buffer, unsigned Length,
80 const std::string& ModuleID,
82 std::vector<std::string>& symbols,