summaryrefslogtreecommitdiffstats
path: root/Source/cmELF.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmELF.cxx')
-rw-r--r--Source/cmELF.cxx49
1 files changed, 25 insertions, 24 deletions
diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx
index 26f1a44..15755cb 100644
--- a/Source/cmELF.cxx
+++ b/Source/cmELF.cxx
@@ -13,8 +13,8 @@
#include "cmELF.h"
+#include <cm_auto_ptr.hxx>
#include <cmsys/FStream.hxx>
-#include <cmsys/auto_ptr.hxx>
// Include the ELF format information system header.
#if defined(__OpenBSD__)
@@ -107,7 +107,7 @@ public:
};
// Construct and take ownership of the file stream object.
- cmELFInternal(cmELF* external, cmsys::auto_ptr<cmsys::ifstream>& fin,
+ cmELFInternal(cmELF* external, CM_AUTO_PTR<cmsys::ifstream>& fin,
ByteOrderType order)
: External(external)
, Stream(*fin.release())
@@ -143,7 +143,7 @@ public:
{
this->Stream.seekg(pos);
this->Stream.read(buf, size);
- return this->Stream ? true : false;
+ return !this->Stream.fail();
}
// Lookup the SONAME in the DYNAMIC section.
@@ -237,24 +237,24 @@ public:
typedef typename Types::tagtype tagtype;
// Construct with a stream and byte swap indicator.
- cmELFInternalImpl(cmELF* external, cmsys::auto_ptr<cmsys::ifstream>& fin,
+ cmELFInternalImpl(cmELF* external, CM_AUTO_PTR<cmsys::ifstream>& fin,
ByteOrderType order);
// Return the number of sections as specified by the ELF header.
- virtual unsigned int GetNumberOfSections() const
+ unsigned int GetNumberOfSections() const CM_OVERRIDE
{
return static_cast<unsigned int>(this->ELFHeader.e_shnum);
}
// Get the file position and size of a dynamic section entry.
- virtual unsigned int GetDynamicEntryCount();
- virtual unsigned long GetDynamicEntryPosition(int j);
+ unsigned int GetDynamicEntryCount() CM_OVERRIDE;
+ unsigned long GetDynamicEntryPosition(int j) CM_OVERRIDE;
// Lookup a string from the dynamic section with the given tag.
- virtual StringEntry const* GetDynamicSectionString(unsigned int tag);
+ StringEntry const* GetDynamicSectionString(unsigned int tag) CM_OVERRIDE;
// Print information about the ELF file.
- virtual void PrintInfo(std::ostream& os) const
+ void PrintInfo(std::ostream& os) const CM_OVERRIDE
{
os << "ELF " << Types::GetName();
if (this->ByteOrder == ByteOrderMSB) {
@@ -497,7 +497,7 @@ private:
this->NeedSwap) {
ByteSwap(x);
}
- return this->Stream ? true : false;
+ return !this->Stream.fail();
}
bool Read(ELF_Dyn& x)
{
@@ -505,7 +505,7 @@ private:
this->NeedSwap) {
ByteSwap(x);
}
- return this->Stream ? true : false;
+ return !this->Stream.fail();
}
bool LoadSectionHeader(ELF_Half i)
@@ -537,8 +537,9 @@ private:
};
template <class Types>
-cmELFInternalImpl<Types>::cmELFInternalImpl(
- cmELF* external, cmsys::auto_ptr<cmsys::ifstream>& fin, ByteOrderType order)
+cmELFInternalImpl<Types>::cmELFInternalImpl(cmELF* external,
+ CM_AUTO_PTR<cmsys::ifstream>& fin,
+ ByteOrderType order)
: cmELFInternal(external, fin, order)
{
// Read the main header.
@@ -672,7 +673,7 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString(
if (dssi->second.Position > 0) {
return &dssi->second;
}
- return 0;
+ return CM_NULLPTR;
}
// Create an entry for this tag. Assume it is missing until found.
@@ -683,14 +684,14 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString(
// Try reading the dynamic section.
if (!this->LoadDynamicSection()) {
- return 0;
+ return CM_NULLPTR;
}
// Get the string table referenced by the DYNAMIC section.
ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex];
if (sec.sh_link >= this->SectionHeaders.size()) {
this->SetErrorMessage("Section DYNAMIC has invalid string table index.");
- return 0;
+ return CM_NULLPTR;
}
ELF_Shdr const& strtab = this->SectionHeaders[sec.sh_link];
@@ -705,7 +706,7 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString(
if (dyn.d_un.d_val >= strtab.sh_size) {
this->SetErrorMessage("Section DYNAMIC references string beyond "
"the end of its string section.");
- return 0;
+ return CM_NULLPTR;
}
// Seek to the position reported by the entry.
@@ -734,7 +735,7 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString(
if (!this->Stream) {
this->SetErrorMessage("Dynamic section specifies unreadable RPATH.");
se.Value = "";
- return 0;
+ return CM_NULLPTR;
}
// The value has been read successfully. Report it.
@@ -745,17 +746,17 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString(
return &se;
}
}
- return 0;
+ return CM_NULLPTR;
}
//============================================================================
// External class implementation.
cmELF::cmELF(const char* fname)
- : Internal(0)
+ : Internal(CM_NULLPTR)
{
// Try to open the file.
- cmsys::auto_ptr<cmsys::ifstream> fin(new cmsys::ifstream(fname));
+ CM_AUTO_PTR<cmsys::ifstream> fin(new cmsys::ifstream(fname));
// Quit now if the file could not be opened.
if (!fin.get() || !*fin) {
@@ -879,7 +880,7 @@ cmELF::StringEntry const* cmELF::GetSOName()
this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary) {
return this->Internal->GetSOName();
} else {
- return 0;
+ return CM_NULLPTR;
}
}
@@ -890,7 +891,7 @@ cmELF::StringEntry const* cmELF::GetRPath()
this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) {
return this->Internal->GetRPath();
} else {
- return 0;
+ return CM_NULLPTR;
}
}
@@ -901,7 +902,7 @@ cmELF::StringEntry const* cmELF::GetRunPath()
this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) {
return this->Internal->GetRunPath();
} else {
- return 0;
+ return CM_NULLPTR;
}
}