DWARF_ADD_FRAME_FDE(3)
okay so bestie, this is the libdwarf manual page for dwarf_add_frame_fde(3), and itβs literally about adding call frame descriptors to a DWARF producer instance. The DWARF Access Library vibe is libdwarf with -ldwarf, and weβre obsessed β¨.
πΈ NAME πΈ
dwarf_add_frame_fde β add a call frame descriptor to a DWARF producer instance. Thatβs the assignment, no cap π
.
π LIBRARY π
DWARF Access Library (libdwarf, -ldwarf) β yes bestie, thatβs the library and thatβs the link flag, iconic.
β¨ SYNOPSIS β¨
#include <libdwarf.h>
Dwarf_Unsigned
dwarf_add_frame_fde(Dwarf_P_Debug dbg, Dwarf_P_Fde fde, Dwarf_P_Die die,
Dwarf_Unsigned cie, Dwarf_Addr virt_addr, Dwarf_Unsigned code_len,
Dwarf_Unsigned symbol_index, Dwarf_Error *err);
Dwarf_Unsigned
dwarf_add_frame_fde_b(Dwarf_P_Debug dbg, Dwarf_P_Fde fde,
Dwarf_P_Die die, Dwarf_Unsigned cie, Dwarf_Addr virt_addr,
Dwarf_Unsigned code_len, Dwarf_Unsigned symbol_index,
Dwarf_Unsigned end_symbol_index, Dwarf_Addr offset_from_end_sym,
Dwarf_Error *err);
π DESCRIPTION π
So dwarf_add_frame_fde_b() is the one doing the adding: you hand it the call frame descriptor that fde references, and it adds that to a producer instance. Main character energy fr fr π«Ά.
- Your
dbgshould reference a DWARF producer instance allocated usingdwarf_producer_init(3)ordwarf_producer_init_b(3). Vibe-check that pointer, bestie. - Your
fdeshould reference a frame descriptor allocated usingdwarf_new_fde(3). - Fair warning:
dieis ignored by this implementation of the DWARF Access Library (libdwarf,-ldwarf). Literally ignored. Not me side-eyeing a whole argument π. ciegives the index of the call frame common information entry for the frame descriptor. Valid indices are exactly the ones returned by functiondwarf_add_frame_cie(3).symbol_indexis the ELF symbol index of the first symbol to be used for relocation.
Now the way that end_symbol_index flips the meaning of virt_addr, code_len, and offset_from_end_sym is lowkey iconic. Itβs giving conditional logic π:
- If
end_symbol_indexis zero, thenvirt_addrspecifies the relocatable address of the start of the function associated with the frame descriptor.code_lenspecifies the size in bytes of the machine instructions for this function.symbol_indexspecifies the ELF symbol to be used for relocating the address invirt_addr. Andoffset_from_end_symbolis ignored β yes, ignored, donβt stress it π . - If
end_symbol_indexis non-zero, it specifies the ELF symbol index of the second symbol to be used for relocation. In that case,virt_addrspecifies an offset from the relocatable symbol specified bysymbol_index,offset_from_end_symbolshould specify an offset from the symbol named byend_symbol_index, andcode_lenwill be ignored. TheDW_DLC_SYMBOLIC_RELOCATIONSflag should also have been set on the DWARF producer instance β highkey important, okay? π₯
Application code can retrieve the relocation entries for the symbol pair by calling function dwarf_get_relocation_info(3). The relocation entry for the first symbol will have type dwarf_drt_first_of_length_pair, and the relocation entry for the second symbol will have type dwarf_drt_second_of_length_pair. Slay, relocation pair π.
If err is not NULL, it will be used to store error information in case of an error.
Function dwarf_add_frame_fde() is similar to function dwarf_add_frame_fde_b() except that it supports only one relocation symbol. Lowkey the simpler icon, periodt.
β RETURN VALUES β
On success, these functions return the index value for the added frame descriptor. In case of an error, these functions return DW_DLV_NOCOUNT and set the argument err. So: happy path gives you an index, sad path gives you DW_DLV_NOCOUNT and err info. Not slay, but useful π.
π ERRORS π
These functions can fail with:
[DW_DLE_ARGUMENT]β One of the argumentsdbgorfdewasNULL.[DW_DLE_ARGUMENT]β The frame descriptor referenced by argumentfdedid not belong to the producer instance referenced by argumentdbg.[DW_DLE_ARGUMENT]β The common information entry index specified by argumentciewas invalid.[DW_DLE_ARGUMENT]β Argumentend_symbol_indexwas non-zero, but the flagDW_DLC_SYMBOLIC_RELOCATIONSwas not set on the producer instance.
π¦ SEE ALSO π¦
Go read these too, iykyk:
dwarf(3)dwarf_add_fde_inst(3)dwarf_add_frame_cie(3)dwarf_fde_cfa_offset(3)dwarf_get_relocation_info(3)dwarf_new_fde(3)dwarf_producer_init(3)dwarf_producer_init_b(3)
Thatβs the whole page, bestie. Source/version energy: Debian; date: September 26, 2011. Bye! πβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: libdwarf 15.0.0
- Copyright (c) 2011 Kai Wang
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms