Fix build of set_haiku_revision.cpp with gcc2 (on haiku)
* move template method implementations out of class body, as otherwise gcc2 bails with internal compiler error - thanks to Christof Lutteroth for reporting
This commit is contained in:
@@ -450,7 +450,89 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
template<typename EhdrType, typename ShdrType>
|
template<typename EhdrType, typename ShdrType>
|
||||||
void _ParseELFHeader()
|
void _ParseELFHeader();
|
||||||
|
|
||||||
|
template<typename ShdrType>
|
||||||
|
bool _ReadSectionHeader(int index, SectionInfo& info);
|
||||||
|
|
||||||
|
// _SwapUInt16
|
||||||
|
static inline uint16_t _SwapUInt16(uint16_t value)
|
||||||
|
{
|
||||||
|
return ((value & 0xff) << 8) | (value >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
// _SwapUInt32
|
||||||
|
static inline uint32_t _SwapUInt32(uint32_t value)
|
||||||
|
{
|
||||||
|
return ((uint32_t)_SwapUInt16(value & 0xffff) << 16)
|
||||||
|
| _SwapUInt16(uint16_t(value >> 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
// _SwapUInt64
|
||||||
|
static inline uint64_t _SwapUInt64(uint64_t value)
|
||||||
|
{
|
||||||
|
return ((uint64_t)_SwapUInt32(value & 0xffffffff) << 32)
|
||||||
|
| _SwapUInt32(uint32_t(value >> 32));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int fFD;
|
||||||
|
uint8_t fELFClass;
|
||||||
|
bool fHostEndianess;
|
||||||
|
off_t fFileSize;
|
||||||
|
size_t fELFHeaderSize;
|
||||||
|
off_t fSectionHeaderTableOffset;
|
||||||
|
size_t fSectionHeaderSize;
|
||||||
|
size_t fSectionHeaderCount;
|
||||||
|
char* fSectionHeaderStrings;
|
||||||
|
uint32_t fSectionHeaderStringsLength;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
int16_t ELFObject::GetValue(int16_t& value)
|
||||||
|
{
|
||||||
|
return (fHostEndianess ? value : _SwapUInt16(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
uint16_t ELFObject::GetValue(uint16_t& value)
|
||||||
|
{
|
||||||
|
return (fHostEndianess ? value : _SwapUInt16(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
int32_t ELFObject::GetValue(int32_t& value)
|
||||||
|
{
|
||||||
|
return (fHostEndianess ? value : _SwapUInt32(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
uint32_t ELFObject::GetValue(uint32_t& value)
|
||||||
|
{
|
||||||
|
return (fHostEndianess ? value : _SwapUInt32(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
int64_t ELFObject::GetValue(int64_t& value)
|
||||||
|
{
|
||||||
|
return (fHostEndianess ? value : _SwapUInt64(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
uint64_t ELFObject::GetValue(uint64_t& value)
|
||||||
|
{
|
||||||
|
return (fHostEndianess ? value : _SwapUInt64(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename EhdrType, typename ShdrType>
|
||||||
|
void ELFObject::_ParseELFHeader()
|
||||||
{
|
{
|
||||||
// read ELF header
|
// read ELF header
|
||||||
EhdrType fileHeader;
|
EhdrType fileHeader;
|
||||||
@@ -530,8 +612,9 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename ShdrType>
|
template<typename ShdrType>
|
||||||
bool _ReadSectionHeader(int index, SectionInfo& info)
|
bool ELFObject::_ReadSectionHeader(int index, SectionInfo& info)
|
||||||
{
|
{
|
||||||
off_t shOffset = fSectionHeaderTableOffset
|
off_t shOffset = fSectionHeaderTableOffset
|
||||||
+ index * fSectionHeaderSize;
|
+ index * fSectionHeaderSize;
|
||||||
@@ -582,81 +665,6 @@ private:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// _SwapUInt16
|
|
||||||
static inline uint16_t _SwapUInt16(uint16_t value)
|
|
||||||
{
|
|
||||||
return ((value & 0xff) << 8) | (value >> 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
// _SwapUInt32
|
|
||||||
static inline uint32_t _SwapUInt32(uint32_t value)
|
|
||||||
{
|
|
||||||
return ((uint32_t)_SwapUInt16(value & 0xffff) << 16)
|
|
||||||
| _SwapUInt16(uint16_t(value >> 16));
|
|
||||||
}
|
|
||||||
|
|
||||||
// _SwapUInt64
|
|
||||||
static inline uint64_t _SwapUInt64(uint64_t value)
|
|
||||||
{
|
|
||||||
return ((uint64_t)_SwapUInt32(value & 0xffffffff) << 32)
|
|
||||||
| _SwapUInt32(uint32_t(value >> 32));
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
int fFD;
|
|
||||||
uint8_t fELFClass;
|
|
||||||
bool fHostEndianess;
|
|
||||||
off_t fFileSize;
|
|
||||||
size_t fELFHeaderSize;
|
|
||||||
off_t fSectionHeaderTableOffset;
|
|
||||||
size_t fSectionHeaderSize;
|
|
||||||
size_t fSectionHeaderCount;
|
|
||||||
char* fSectionHeaderStrings;
|
|
||||||
uint32_t fSectionHeaderStringsLength;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template<>
|
|
||||||
int16_t ELFObject::GetValue(int16_t& value)
|
|
||||||
{
|
|
||||||
return (fHostEndianess ? value : _SwapUInt16(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<>
|
|
||||||
uint16_t ELFObject::GetValue(uint16_t& value)
|
|
||||||
{
|
|
||||||
return (fHostEndianess ? value : _SwapUInt16(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<>
|
|
||||||
int32_t ELFObject::GetValue(int32_t& value)
|
|
||||||
{
|
|
||||||
return (fHostEndianess ? value : _SwapUInt32(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<>
|
|
||||||
uint32_t ELFObject::GetValue(uint32_t& value)
|
|
||||||
{
|
|
||||||
return (fHostEndianess ? value : _SwapUInt32(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<>
|
|
||||||
int64_t ELFObject::GetValue(int64_t& value)
|
|
||||||
{
|
|
||||||
return (fHostEndianess ? value : _SwapUInt64(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<>
|
|
||||||
uint64_t ELFObject::GetValue(uint64_t& value)
|
|
||||||
{
|
|
||||||
return (fHostEndianess ? value : _SwapUInt64(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// main
|
// main
|
||||||
int
|
int
|
||||||
|
|||||||
Reference in New Issue
Block a user