TPDE
Loading...
Searching...
No Matches
tpde::FunctionWriterBase Class Reference

Architecture-independent base for helper class to write function text. More...

#include <FunctionWriter.hpp>

Inheritance diagram for tpde::FunctionWriterBase:
tpde::FunctionWriter< FunctionWriterA64 > tpde::FunctionWriter< FunctionWriterX64 > tpde::FunctionWriter< Derived > tpde::a64::FunctionWriterA64 tpde::x64::FunctionWriterX64

Public Member Functions

SecRef get_sec_ref () const noexcept
 Get the SecRef of the current section.
 
DataSection & get_section () const noexcept
 Get the current section.
 
void switch_section (DataSection &new_section) noexcept
 Switch section writer to new section; must be flushed.
 
size_t offset () const noexcept
 Get the current offset into the section.
 
size_t allocated_size () const noexcept
 Get the current allocated size of the section.
 
u8 * begin_ptr () noexcept
 Pointer to beginning of section data.
 
u8 *& cur_ptr () noexcept
 Modifiable pointer to current writing position of the section.
 
void remove_prologue_bytes (u32 start, u32 size) noexcept
 Remove bytes and adjust labels/relocations accordingly.
 
Labels
Label label_create () noexcept
 Create a new unplaced label.
 
void label_place (Label label, u32 off) noexcept
 Place unplaced label at the specified offset inside the section.
 
void label_ref (Label label, u32 off, LabelFixupKind kind) noexcept
 Reference label at given offset inside the code section.
 
Itanium Exception ABI
void except_add_call_site (u32 text_off, u32 len, Label landing_pad, bool is_cleanup) noexcept
 add an entry to the call-site table must be called in strictly increasing order wrt text_off
 
void except_add_cleanup_action () noexcept
 Add a cleanup action to the action table MUST be the last one.
 
void except_add_action (bool first_action, SymRef type_sym) noexcept
 add an action to the action table An invalid SymRef signals a catch(...)
 

Protected Attributes

u32 func_begin
 Begin offset of the current function.
 
u32 reloc_begin
 Begin of relocations for current function.
 
u32 label_skew
 Offset to subtract from all label offsets.
 
util::SmallVector< u32 > label_offsets
 Label offsets into section, ~0u indicates unplaced label.
 
util::SmallVector< LabelFixup > label_fixups
 Fixups for labels placed after their first use, processed at function end.
 
u32 growth_size = 0x10000
 Growth size for more_space; adjusted exponentially after every grow.
 

DWARF CFI

void eh_advance_raw (u64 size_units) noexcept
 Write CFA_advance_loc; size must be scaled by code alignment factor.
 
void eh_advance (u64 size) noexcept
 Write CFA_advance_loc with code alignment factor 1.
 

Detailed Description

Architecture-independent base for helper class to write function text.

Definition at line 31 of file FunctionWriter.hpp.

Member Function Documentation

◆ cur_ptr()

u8 *& tpde::FunctionWriterBase::cur_ptr ( )
inlinenoexcept

Modifiable pointer to current writing position of the section.

Must not be moved beyond the allocated region.

Definition at line 155 of file FunctionWriter.hpp.

◆ remove_prologue_bytes()

void tpde::FunctionWriterBase::remove_prologue_bytes ( u32 start,
u32 size )
noexcept

Remove bytes and adjust labels/relocations accordingly.

The covered region must be before the first label, i.e., this function can only be used to cut out bytes from the function prologue.


The documentation for this class was generated from the following file: