Commit d7050ad5 authored by Peter Griess's avatar Peter Griess Committed by Owen Yamauchi

Enable Elf::at<T> only for POD data types

Summary:
- Make sure that the utility function Elf::at<T> only works for POD
datatypes, as it uses reinterpret_cast<T>.

Test Plan: - Unit tests

Reviewed By: simpkins@fb.com

FB internal diff: D748314
parent a6198d25
...@@ -123,7 +123,8 @@ class ElfFile { ...@@ -123,7 +123,8 @@ class ElfFile {
void validateStringTable(const ElfW(Shdr)& stringTable) const; void validateStringTable(const ElfW(Shdr)& stringTable) const;
template <class T> template <class T>
const T& at(off_t offset) const { const typename std::enable_if<std::is_pod<T>::value, T>::type&
at(off_t offset) const {
return *reinterpret_cast<T*>(file_ + offset); return *reinterpret_cast<T*>(file_ + offset);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment