microfmt
Zero-allocation C++ formatting for constrained environments
Loading...
Searching...
No Matches
Classes | Namespaces | Functions
dl_elf_enumerator.hpp File Reference

`dlfcn.h`/`dl_iterate_phdr`-backed microfmt::elf_image_enumerator_ref implementation for Linux and BSD. More...

#include <cstdint>
#include <cstring>
#include <dlfcn.h>
#include <link.h>
#include "../microfmt.hpp"
#include "elf_enumerator.hpp"
Include dependency graph for dl_elf_enumerator.hpp:

Go to the source code of this file.

Classes

struct  microfmt::detail::dl_enumerate_state
 Mutable state threaded through dl_enumerate_callback. More...
 
struct  microfmt::detail::dl_find_size_state
 State used by dl_find_size_callback to locate the PT_LOAD (and, where available, PT_ARM_EXIDX/PT_GNU_EH_FRAME) bounds of the image whose load base was already resolved via dladdr. More...
 
struct  microfmt::dl_elf_enumerator_tag
 Tag selecting the dlfcn.h/dl_iterate_phdr-backed elf_image_enumerator_traits specialization. More...
 
struct  microfmt::dl_elf_enumerator_context
 Empty context for dl_elf_enumerator_tag: dladdr and dl_iterate_phdr query the dynamic linker directly and require no per-instance state. More...
 
struct  microfmt::elf_image_enumerator_traits< dl_elf_enumerator_tag >
 Traits binding dl_elf_enumerator_tag to dladdr/ dl_iterate_phdr-based ELF image introspection. More...
 

Namespaces

namespace  microfmt
 
namespace  microfmt::detail
 

Functions

bool microfmt::detail::dl_phdr_image_bounds (const dl_phdr_info &info, uintptr_t &out_base, uintptr_t &out_size) noexcept
 Computes the runtime [base, base + size) range covered by an image's PT_LOAD segments.
 
RELOCO_BEGIN_UNSAFE_CODE int microfmt::detail::dl_enumerate_callback (dl_phdr_info *info, size_t, void *data) noexcept
 dl_iterate_phdr callback that fills dl_enumerate_state::buffer with one elf_image_info per loaded image, stopping once full.
 
RELOCO_END_UNSAFE_CODE bool microfmt::detail::dl_enumerate_images (span< elf_image_info > out_buffer, size_t &out_count) noexcept
 Fills out_buffer with every image currently reported by dl_iterate_phdr, up to its capacity.
 
RELOCO_BEGIN_UNSAFE_CODE int microfmt::detail::dl_find_size_callback (dl_phdr_info *info, size_t, void *data) noexcept
 dl_iterate_phdr callback that records the mapped size (and, where available, the .ARM.exidx/.eh_frame bounds) of the image whose base address matches dl_find_size_state::target_base.
 
RELOCO_END_UNSAFE_CODE RELOCO_BEGIN_UNSAFE_CODE bool microfmt::detail::dl_find_by_pc (uintptr_t pc, elf_image_info &out_info) noexcept
 Resolves the image owning pc via dladdr, then cross-references dl_iterate_phdr to fill in the image's mapped size and, where available, its .ARM.exidx/.eh_frame bounds.
 

Detailed Description

`dlfcn.h`/`dl_iterate_phdr`-backed microfmt::elf_image_enumerator_ref implementation for Linux and BSD.