[cmake-commits] king committed cmELF.cxx 1.7 1.8
cmake-commits at cmake.org
cmake-commits at cmake.org
Mon Mar 3 08:48:39 EST 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv28231/Source
Modified Files:
cmELF.cxx
Log Message:
COMP: Fix cmELF to build when ET_LOOS, ET_HIOS, ET_LOPROC, ET_HIPROC may not be defined.
Index: cmELF.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmELF.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- cmELF.cxx 2 Mar 2008 21:31:06 -0000 1.7
+++ cmELF.cxx 3 Mar 2008 13:48:37 -0000 1.8
@@ -334,6 +334,29 @@
}
}
+ bool FileTypeValid(ELF_Half et)
+ {
+ unsigned int eti = static_cast<unsigned int>(et);
+ if(eti == ET_NONE || eti == ET_REL || eti == ET_EXEC ||
+ eti == ET_DYN || eti == ET_CORE)
+ {
+ return true;
+ }
+#if defined(ET_LOOS) && defined(ET_HIOS)
+ if(eti >= ET_LOOS && eti <= ET_HIOS)
+ {
+ return true;
+ }
+#endif
+#if defined(ET_LOPROC) && defined(ET_HIPROC)
+ if(eti >= ET_LOPROC && eti <= ET_HIPROC)
+ {
+ return true;
+ }
+#endif
+ return false;
+ }
+
bool Read(ELF_Ehdr& x)
{
// Read the header from the file.
@@ -353,18 +376,10 @@
{
cmELFByteSwap(et);
}
- unsigned int eti = static_cast<unsigned int>(et);
- if(!(eti == ET_NONE || eti == ET_REL || eti == ET_EXEC ||
- eti == ET_DYN || eti == ET_CORE ||
- (eti >= ET_LOOS && eti <= ET_HIOS) ||
- (eti >= ET_LOPROC && eti <= ET_HIPROC)))
+ if(!this->FileTypeValid(et))
{
cmELFByteSwap(et);
- eti = static_cast<unsigned int>(et);
- if(eti == ET_NONE || eti == ET_REL || eti == ET_EXEC ||
- eti == ET_DYN || eti == ET_CORE ||
- (eti >= ET_LOOS && eti <= ET_HIOS) ||
- (eti >= ET_LOPROC && eti <= ET_HIPROC))
+ if(this->FileTypeValid(et))
{
// The previous byte order guess was wrong. Flip it.
this->NeedSwap = !this->NeedSwap;
@@ -446,7 +461,7 @@
switch(this->ELFHeader.e_type)
{
case ET_NONE:
- this->SetErrorMessage("No ELF file type.");
+ this->SetErrorMessage("ELF file type is NONE.");
return;
case ET_REL:
this->ELFType = cmELF::FileTypeRelocatableObject;
@@ -461,22 +476,27 @@
this->ELFType = cmELF::FileTypeCore;
break;
default:
- unsigned int et = static_cast<unsigned int>(this->ELFHeader.e_type);
- if(et >= ET_LOOS && et <= ET_HIOS)
+ {
+ unsigned int eti = static_cast<unsigned int>(this->ELFHeader.e_type);
+#if defined(ET_LOOS) && defined(ET_HIOS)
+ if(eti >= ET_LOOS && eti <= ET_HIOS)
{
this->ELFType = cmELF::FileTypeSpecificOS;
break;
}
- else if(et >= ET_LOPROC && et <= ET_HIPROC)
+#endif
+#if defined(ET_LOPROC) && defined(ET_HIPROC)
+ if(eti >= ET_LOPROC && eti <= ET_HIPROC)
{
this->ELFType = cmELF::FileTypeSpecificProc;
break;
}
- else
- {
- this->SetErrorMessage("Unknown ELF file type.");
- return;
- }
+#endif
+ cmOStringStream e;
+ e << "Unknown ELF file type " << eti;
+ this->SetErrorMessage(e.str().c_str());
+ return;
+ }
}
// Load the section headers.
More information about the Cmake-commits
mailing list