Skip to documentation
SLOP

tiny.tldr.formats.elf.liveness.state

Reference tiny.tldr formats elf liveness state

Defined in formats.elf.liveness.

API (5)

Actions

Public operations.

Types and contracts

Public types and contracts.

No direct callersNo direct callsformats.elf.livenessstate
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Called byCallsNo direct callsprivate; no linkfun.sdfii.src.backend.accy.executor.Devicedeinitprivate; no linkfun.sdfii.src.profiling.field.march.runbenchmarkFrameMarchWithConfigtiny.accyexecutable.LoadedFragmentdeinittiny.accyexecutable.CompiledFragmentdeinitprivate sourcelib.accy.src.integration.testrunPrefixSumFamilyOnLiveCuda+179 moreformats.elf.liveness.statedeinit
Static calls · unresolved targets: 0 · external targets: 2.
Called byCallsformats.elf.livenessdiscardUnreachableformats.elf.section_stateensureDiscardedSectionsformats.elf.liveness.statediscardUnmarked
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsformats.elf.livenessdiscardUnreachableprivate sourcelib.tldr.src.formats.elf.liveness.statecountSectionsformats.elf.liveness.stateinit
Static calls · unresolved targets: 2 · external targets: 2.
Called byCallsformats.elf.liveness.groupsmarkformats.elf.liveness.rootsmarkReservedformats.elf.liveness.rootsmarkRetainedformats.elf.liveness.symbolsmarkprivate sourcelib.tldr.src.formats.elf.liveness.symbolsmarkSyntheticBoundarySectionsformats.elf.section_statesectionDiscardedformats.elf.liveness.statemarkSection
Static calls · unresolved targets: 0 · external targets: 1.

Source: lib/tldr/src/formats/elf/liveness/root.zig:5

zig
pub const state = @import("state.zig");

Source: lib/tldr/src/formats/elf/liveness/state.zig

zig
const std = @import("std");const root = @import("../../../root.zig");const elf = @import("../root.zig");const Allocator = std.mem.Allocator;const model = root.model;const ObjectFile = elf.parser.ObjectFile;const SectionRef = elf.parser.SectionRef;const ensureDiscardedSections = elf.section_state.ensureDiscardedSections;const sectionDiscarded = elf.section_state.sectionDiscarded;pub const State = struct {    live_sections: [][]bool,    live_count: usize,    pending: std.ArrayListUnmanaged(SectionRef),};pub fn init(allocator: Allocator, objects: []const ObjectFile) model.Error!State {    var live_sections = try allocator.alloc([]bool, objects.len);    var live_count: usize = 0;    errdefer {        for (live_sections[0..live_count]) |sections| allocator.free(sections);        allocator.free(live_sections);    }    for (objects, 0..) |object, object_index| {        live_sections[object_index] = try allocator.alloc(bool, object.sections.len);        @memset(live_sections[object_index], false);        live_count += 1;    }    var pending: std.ArrayListUnmanaged(SectionRef) = .empty;    errdefer pending.deinit(allocator);    try pending.ensureTotalCapacity(allocator, try countSections(objects));    return .{        .live_sections = live_sections,        .live_count = live_count,        .pending = pending,    };}pub fn deinit(live: *State, allocator: Allocator) void {    live.pending.deinit(allocator);    for (live.live_sections[0..live.live_count]) |sections| allocator.free(sections);    allocator.free(live.live_sections);    live.* = .{        .live_sections = &.{},        .live_count = 0,        .pending = .empty,    };}pub fn markSection(    live: *State,    objects: []const ObjectFile,    section_ref: SectionRef,) model.Error!void {    if (section_ref.object_index >= objects.len) return error.InvalidObject;    const object = objects[section_ref.object_index];    if (section_ref.section_index >= object.sections.len) return error.MissingSection;    if (sectionDiscarded(object, section_ref.section_index)) return;    if (live.live_sections[section_ref.object_index][section_ref.section_index]) return;    live.live_sections[section_ref.object_index][section_ref.section_index] = true;    live.pending.appendAssumeCapacity(section_ref);}pub fn discardUnmarked(    live: *State,    allocator: Allocator,    objects: []ObjectFile,) model.Error!void {    for (objects, 0..) |*object, object_index| {        const discarded_sections = try ensureDiscardedSections(allocator, object);        for (object.sections, 0..) |section, section_index| {            if (discarded_sections[section_index]) continue;            if ((section.flags & std.elf.SHF_ALLOC) == 0) continue;            if (!live.live_sections[object_index][section_index]) {                discarded_sections[section_index] = true;            }        }    }}fn countSections(objects: []const ObjectFile) model.Error!usize {    var total: usize = 0;    for (objects) |object| {        if (object.sections.len > std.math.maxInt(usize) - total) return error.InvalidObject;        total += object.sections.len;    }    return total;}

Complete caller list for formats.elf.liveness.state.deinit

184 direct callers.

Audit

Definitions6
Public names6
Members3
Version26.7.0
Revisiondaab053ee433