Skip to content

ElfBuf

Description

Borrowed handle to the parser’s owned byte buffer. Cross-namespace readers (Dwarf*BuildFromElf, …) need section bytes off the loaded file; this is the public seam they go through instead of reaching at self->data directly.

Usage example (Cross-references)

Usage examples (Cross-references)
        U64Vec pending_dir_offsets  = VecInitT(pending_dir_offsets, alloc);
    
        BufIter section_cur = BufIterFromMemory(BufData(ElfBuf(elf)) + line_section->offset, line_section->size);
    
        bool ok = true;
        const ElfSection *str_sec    = ElfFindSection(elf, ".debug_str");
    
        const u8 *info_b   = info_sec ? BufData(ElfBuf(elf)) + info_sec->offset : NULL;
        u64       info_n   = info_sec ? info_sec->size : 0;
        const u8 *abbrev_b = abbrev_sec ? BufData(ElfBuf(elf)) + abbrev_sec->offset : NULL;
        const u8 *info_b   = info_sec ? BufData(ElfBuf(elf)) + info_sec->offset : NULL;
        u64       info_n   = info_sec ? info_sec->size : 0;
        const u8 *abbrev_b = abbrev_sec ? BufData(ElfBuf(elf)) + abbrev_sec->offset : NULL;
        u64       abbrev_n = abbrev_sec ? abbrev_sec->size : 0;
        const u8 *str_b    = str_sec ? BufData(ElfBuf(elf)) + str_sec->offset : NULL;
        const u8 *abbrev_b = abbrev_sec ? BufData(ElfBuf(elf)) + abbrev_sec->offset : NULL;
        u64       abbrev_n = abbrev_sec ? abbrev_sec->size : 0;
        const u8 *str_b    = str_sec ? BufData(ElfBuf(elf)) + str_sec->offset : NULL;
        u64       str_n    = str_sec ? str_sec->size : 0;
        return DwarfFunctionsBuildFromSlices(out, info_b, info_n, abbrev_b, abbrev_n, str_b, str_n, alloc);
        out->eh_frame_addr = eh->addr;
    
        const u8 *section_data = BufData(ElfBuf(elf)) + eh->offset;
    
        BufIter section_cur = BufIterFromMemory(section_data, eh->size);
Last updated on