1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmELF.h,v $
6 Date: $Date: 2008-04-14 19:02:24 $
7 Version: $Revision: 1.5 $
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 =========================================================================*/
20 #if !defined(CMAKE_USE_ELF_PARSER)
21 # error "This file may be included only if CMAKE_USE_ELF_PARSER is enabled."
27 * \brief Executable and Link Format (ELF) parser.
32 /** Construct with the name of the ELF input file to parse. */
33 cmELF(const char* fname
);
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. */
51 FileTypeRelocatableObject
,
53 FileTypeSharedLibrary
,
59 /** Represent string table entries. */
62 // The string value itself.
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.
72 // The index of the section entry referencing the string.
76 /** Get the type of the file opened. */
77 FileType
GetFileType() const;
79 /** Get the number of ELF sections present. */
80 unsigned int GetNumberOfSections() const;
82 /** Get the number of DYNAMIC section entries before the first
83 DT_NULL. Returns zero on error. */
84 unsigned int GetDynamicEntryCount() const;
86 /** Get the position of a DYNAMIC section header entry. Returns
88 unsigned long GetDynamicEntryPosition(int index
) const;
90 /** Read bytes from the file. */
91 bool ReadBytes(unsigned long pos
, unsigned long size
, char* buf
) const;
93 /** Get the SONAME field if any. */
94 bool GetSOName(std::string
& soname
);
95 StringEntry
const* GetSOName();
97 /** Get the RPATH field if any. */
98 StringEntry
const* GetRPath();
100 /** Get the RUNPATH field if any. */
101 StringEntry
const* GetRunPath();
103 /** Print human-readable information about the ELF file. */
104 void PrintInfo(std::ostream
& os
) const;
107 friend class cmELFInternal
;
109 cmELFInternal
* Internal
;
110 std::string ErrorMessage
;