20 #define FOLLY_EXPERIMENTAL_SYMBOLIZER_ELF_H_ 26 #include <initializer_list> 28 #include <system_error> 36 namespace symbolizer {
57 explicit ElfFile(
const char*
name,
bool readOnly =
true);
73 const char** msg =
nullptr)
noexcept;
82 void open(
const char* name,
bool readOnly = true);
91 return at<ElfEhdr>(0);
155 std::initializer_list<uint32_t> types,
172 std::initializer_list<uint32_t> types,
182 typedef std::pair<const ElfShdr*, const ElfSym*>
Symbol;
203 return valueAt<T>(*section, symbol->st_value);
222 return valueAt<T>(*section,
addr);
234 bool init(
const char** msg);
249 "Offset (%zu + %zu) is not contained within our mmapped" 250 " file (%s) of length %zu",
258 return *
reinterpret_cast<T*
>(
file_ + offset);
274 "Only exectuables and shared objects are supported");
276 addr >= section.sh_addr &&
277 (addr +
sizeof(
T)) <= (section.sh_addr + section.sh_size),
278 "Address is not contained within the provided segment");
280 return at<T>(section.sh_offset + (addr - section.sh_addr));
const ElfShdr * iterateSectionsWithTypes(std::initializer_list< uint32_t > types, Fn fn) const
char filepath_[kFilepathMaxLen]
Symbol getDefinitionByAddress(uintptr_t address) const
const char * getSymbolName(Symbol symbol) const
const T & getAddressValue(const ElfAddr addr) const
const ElfPhdr * iterateProgramHeaders(Fn fn) const
const ElfShdr * getSectionContainingAddress(ElfAddr addr) const
const T & getSymbolValue(const ElfSym *symbol) const
int openAndFollow(const char *name, bool readOnly=true, const char **msg=nullptr) noexcept
const ElfShdr * iterateSectionsWithType(uint32_t type, Fn fn) const
const ElfShdr * getSectionByIndex(size_t idx) const
folly::StringPiece getSectionBody(const ElfShdr §ion) const
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
const ElfShdr * iterateSections(Fn fn) const
const char * getString(const ElfShdr &stringTable, size_t offset) const
const ElfSym * iterateSymbolsWithTypes(const ElfShdr §ion, std::initializer_list< uint32_t > types, Fn fn) const
void validateStringTable(const ElfShdr &stringTable) const
void open(const char *name, bool readOnly=true)
int openNoThrow(const char *name, bool readOnly=true, const char **msg=nullptr) noexcept
const ElfEhdr & elfHeader() const
const ElfShdr * getSectionByName(const char *name) const
Symbol getSymbolByName(const char *name) const
static constexpr size_t kFilepathMaxLen
ElfFile & operator=(ElfFile &&other)
static const char *const value
#define FOLLY_SAFE_CHECK(expr, msg)
bool init(const char **msg)
const ElfSym * iterateSymbols(const ElfShdr §ion, Fn fn) const
const std::enable_if< std::is_pod< T >::value, T >::type & at(ElfOff offset) const
const T & valueAt(const ElfShdr §ion, const ElfAddr addr) const
const ElfSym * iterateSymbolsWithType(const ElfShdr §ion, uint32_t type, Fn fn) const
ThreadPoolListHook * addr
std::pair< const ElfShdr *, const ElfSym * > Symbol
const char * iterateStrings(const ElfShdr &stringTable, Fn fn) const
uintptr_t getBaseAddress() const
const char * getSectionName(const ElfShdr §ion) const