ROSE  0.9.10.103
LibraryInfo.h
1 #ifndef LIBRARY_INFO_H
2 #define LIBRARY_INFO_H
3 
4 #include <BinaryAstHash.h>
5 #include <time.h>
6 #include "Combinatorics.h"
7 
16 namespace LibraryIdentification
17 {
19  {
20  public:
35  LibraryInfo(const std::string& ilibName, const std::string& ilibVersion, const std::string& ilibHash, const std::string& iarchitecture) :
36  libName(ilibName), libVersion(ilibVersion), libHash(ilibHash), architecture(iarchitecture) {
37  analysisTime = time(NULL);
38  };
39 
40 
58  /* LibraryInfo(const std::string& ilibName, const std::string& ilibVersion, SgAsmGenericFile* libraryFile) :
59  libName(ilibName), libVersion(ilibVersion)
60  {
61  SgAsmGenericHeader* genericHeader = libraryFile->get_header(SgAsmExecutableFileFormat::ExecFamily::FAMILY_ELF);
62  SgAsmElfFileHeader* elfHeader = dynamic_cast<SgAsmElfFileHeader*>(genericHeader);
63  ASSERT_require(elfHeader != NULL);
64 
65  //Get the architecture
66  //SgAsmExecutableFileFormat::InsSetArchitecture enumArchitecture = elfHeader->get_isa();
67  architecture = "x86"; //stringify::SgAsmExecutableFileFormat::InsSetArchitecture(enumArchitecture);
68 
69  //Generate hash of library contents
70  //Should make the hash optional via factory method in Combinatorics.h
71  Rose::Combinatorics::HasherFnv fnvHash;
72 
73  SgFileContentList content = libraryFile->content();
74  fnvHash.append(&content[0], content.size());
75  libHash = fnvHash.toString();
76  }
77  */
86  LibraryInfo(const std::string& ilibHash) : libHash(ilibHash) { };
87 
88 
89  friend bool operator<(const LibraryInfo& lhs,const LibraryInfo& rhs)
90  {
91  return lhs.libHash < rhs.libHash;
92  }
93 
94 
102  {
103  return LibraryInfo("UNKNOWN", "UNKNOWN", "UNKNOWN", "UNKNOWN");
104  };
105 
106 
107 
108 
109  // TODO: add accessors
110  // private:
111  //@brief The name of the library
112  std::string libName;
113 
114  //@brief The version of the library
115  std::string libVersion;
116 
117  //@brief A hash that should uniquely identify the library
118  std::string libHash;
119 
120  //@brief Enumeration of instruction set library was build for
121  std::string architecture;
122 
123  //@brief The time when this library was processed
124  time_t analysisTime;
125 
126  };
127 
128 }
129 
130 
131 
132 #endif //LIBRARY_INFO
static LibraryInfo getUnknownLibraryInfo()
getUnknownLibraryInfo
Definition: LibraryInfo.h:101
LibraryInfo(const std::string &ilibName, const std::string &ilibVersion, const std::string &ilibHash, const std::string &iarchitecture)
LibraryInfo.
Definition: LibraryInfo.h:35
LibraryInfo(const std::string &ilibHash)
LibraryInfo.
Definition: LibraryInfo.h:86