Resync (forgot to add new files?)
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmELF.h
blobe47d69ca7579496c395eb214717ec6f41e5af13a
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmELF.h,v $
5 Language: C++
6 Date: $Date: 2008-03-02 21:19:40 $
7 Version: $Revision: 1.4 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef cmELF_h
18 #define cmELF_h
20 #if !defined(CMAKE_USE_ELF_PARSER)
21 # error "This file may be included only if CMAKE_USE_ELF_PARSER is enabled."
22 #endif
24 class cmELFInternal;
26 /** \class cmELF
27 * \brief Executable and Link Format (ELF) parser.
29 class cmELF
31 public:
32 /** Construct with the name of the ELF input file to parse. */
33 cmELF(const char* fname);
35 /** Destruct. */
36 ~cmELF();
38 /** Get the error message if any. */
39 std::string const& GetErrorMessage() const
41 return this->ErrorMessage;
44 /** Boolean conversion. True if the ELF file is valid. */
45 operator bool() const { return this->Valid(); }
47 /** Enumeration of ELF file types. */
48 enum FileType
50 FileTypeInvalid,
51 FileTypeRelocatableObject,
52 FileTypeExecutable,
53 FileTypeSharedLibrary,
54 FileTypeCore,
55 FileTypeSpecificOS,
56 FileTypeSpecificProc
59 /** Represent string table entries. */
60 struct StringEntry
62 // The string value itself.
63 std::string Value;
65 // The position in the file at which the string appears.
66 unsigned long Position;
68 // The size of the string table entry. This includes the space
69 // allocated for one or more null terminators.
70 unsigned long Size;
73 /** Get the type of the file opened. */
74 FileType GetFileType() const;
76 /** Get the number of ELF sections present. */
77 unsigned int GetNumberOfSections() const;
79 /** Get the SONAME field if any. */
80 bool GetSOName(std::string& soname);
81 StringEntry const* GetSOName();
83 /** Get the RPATH field if any. */
84 StringEntry const* GetRPath();
86 /** Get the RUNPATH field if any. */
87 StringEntry const* GetRunPath();
89 /** Print human-readable information about the ELF file. */
90 void PrintInfo(std::ostream& os) const;
92 private:
93 friend class cmELFInternal;
94 bool Valid() const;
95 cmELFInternal* Internal;
96 std::string ErrorMessage;
99 #endif