summaryrefslogtreecommitdiffstats
path: root/Source/cmELF.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-02-27 21:26:35 (GMT)
committerBrad King <brad.king@kitware.com>2008-02-27 21:26:35 (GMT)
commit4c137bad6b663ff342064c293a49fecf03498207 (patch)
treee12f64e2c7056c860cf62508c482bfc86f9222e3 /Source/cmELF.h
parent69ad23a6e73e7eda68b79b4711723190e7bdcdcd (diff)
downloadCMake-4c137bad6b663ff342064c293a49fecf03498207.zip
CMake-4c137bad6b663ff342064c293a49fecf03498207.tar.gz
CMake-4c137bad6b663ff342064c293a49fecf03498207.tar.bz2
ENH: Add ELF file parsing
- Enabled when system provides elf.h - Introduce cmELF class to parse ELF files - Use in cmSystemTools::GuessLibrarySOName to really get soname
Diffstat (limited to 'Source/cmELF.h')
-rw-r--r--Source/cmELF.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/Source/cmELF.h b/Source/cmELF.h
new file mode 100644
index 0000000..11bf354
--- /dev/null
+++ b/Source/cmELF.h
@@ -0,0 +1,76 @@
+/*=========================================================================
+
+ Program: CMake - Cross-Platform Makefile Generator
+ Module: $RCSfile$
+ Language: C++
+ Date: $Date$
+ Version: $Revision$
+
+ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
+ See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+#ifndef cmELF_h
+#define cmELF_h
+
+#if !defined(CMAKE_USE_ELF_PARSER)
+# error "This file may be included only if CMAKE_USE_ELF_PARSER is enabled."
+#endif
+
+class cmELFInternal;
+
+/** \class cmELF
+ * \brief Executable and Link Format (ELF) parser.
+ */
+class cmELF
+{
+public:
+ /** Construct with the name of the ELF input file to parse. */
+ cmELF(const char* fname);
+
+ /** Destruct. */
+ ~cmELF();
+
+ /** Get the error message if any. */
+ std::string const& GetErrorMessage() const
+ {
+ return this->ErrorMessage;
+ }
+
+ /** Boolean conversion. True if the ELF file is valid. */
+ operator bool() const { return this->Valid(); }
+
+ /** Enumeration of ELF file types. */
+ enum FileType
+ {
+ FileTypeInvalid,
+ FileTypeRelocatableObject,
+ FileTypeExecutable,
+ FileTypeSharedLibrary,
+ FileTypeCore
+ };
+
+ /** Get the type of the file opened. */
+ FileType GetFileType() const;
+
+ /** Get the number of ELF sections present. */
+ unsigned int GetNumberOfSections() const;
+
+ /** Get the SONAME field if any. */
+ bool GetSOName(std::string& soname);
+
+ /** Print human-readable information about the ELF file. */
+ void PrintInfo(std::ostream& os) const;
+
+private:
+ friend class cmELFInternal;
+ bool Valid() const;
+ cmELFInternal* Internal;
+ std::string ErrorMessage;
+};
+
+#endif