fn parse(
/// The virtual address of the FDE we're parsing, *excluding* its entry header (i.e. the
/// address is after the header). If `fde_bytes` is backed by the memory of a loaded
/// module's `.eh_frame` section, this will equal `fde_bytes.ptr`.
fde_vaddr: u64,
fde_bytes: []const u8,
cie: *const CommonInformationEntry,
endian: Endian,
) !FrameDescriptionEntry fde_vaddr: u64The virtual address of the FDE we're parsing, excluding its entry header (i.e. the address is after the header). If fde_bytes is backed by the memory of a loaded module's .eh_frame section, this will equal fde_bytes.ptr.
fde_bytes: []const u8cie: *const CommonInformationEntryendian: Endian427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465 fn parse(
/// The virtual address of the FDE we're parsing, *excluding* its entry header (i.e. the
/// address is after the header). If `fde_bytes` is backed by the memory of a loaded
/// module's `.eh_frame` section, this will equal `fde_bytes.ptr`.
fde_vaddr: u64,
fde_bytes: []const u8,
cie: *const CommonInformationEntry,
endian: Endian,
) !FrameDescriptionEntry {
if (cie.segment_selector_size != 0) return error.UnsupportedAddrSize;
var r: Reader = .fixed(fde_bytes);
const pc_begin = try readEhPointer(&r, cie.fde_pointer_enc, cie.addr_size_bytes, .{
.pc_rel_base = fde_vaddr,
}, endian);
// I swear I'm not kidding when I say that PC Range is encoded with `cie.fde_pointer_enc`, but ignoring `rel`.
const pc_range = switch (try readEhPointerAbs(&r, cie.fde_pointer_enc.type, cie.addr_size_bytes, endian)) {
.unsigned => |x| x,
.signed => |x| cast(u64, x) orelse return bad(),
};
switch (cie.augmentation_kind) {
.none, .gcc_eh => {},
.lsb_z => {
// There is augmentation data, but it's irrelevant to us -- it
// only contains the LSDA pointer, which we don't care about.
const aug_data_len = try r.takeLeb128(usize);
_ = try r.discardAll(aug_data_len);
},
}
return .{
.pc_begin = pc_begin,
.pc_range = pc_range,
.instructions = r.buffered(),
};
}
This function expects to read the FDE starting at the PC Begin field. The returned struct references memory backed by
fde_bytes.