Skip to documentation
SLOP

tiny.stabilizer.Runtime

Reference tiny.stabilizer Runtime

Defined in tiny.stabilizer.

API (31)

Actions

Public operations.

Fields and members

Public fields and members.

No direct callersNo direct callstiny.stabilizerRuntime
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/stabilizer/src/runtime.zig:14

zig
pub const Runtime = struct {    allocator: Allocator,    config: config.Config,    heap: ShuffleAllocator,    stack: stack.StackPads,    code: CodeRandomizer,    rng: Marsaglia,    stack_pad_slots: std.ArrayListUnmanaged(*u8) = .empty,    constructors: std.ArrayListUnmanaged(ConstructorFn) = .empty,    pub fn init(allocator: Allocator, runtime_config: config.Config) !Runtime {        var rng = Marsaglia.init(runtime_config.seed);        var stack_pads = try stack.StackPads.init(allocator, runtime_config.stack, &rng);        errdefer stack_pads.deinit();        return .{            .allocator = allocator,            .config = runtime_config,            .heap = ShuffleAllocator.init(allocator, runtime_config.heap, runtime_config.seed ^ 0x4845_4150),            .stack = stack_pads,            .code = CodeRandomizer.init(allocator, runtime_config.code, runtime_config.seed ^ 0x434f_4445),            .rng = rng,        };    }    pub fn deinit(self: *Runtime) void {        self.constructors.deinit(self.allocator);        self.stack_pad_slots.deinit(self.allocator);        self.code.deinit();        self.stack.deinit();        self.heap.deinit();        self.* = undefined;    }    pub fn randomizedAllocator(self: *Runtime) Allocator {        return self.heap.allocator();    }    pub fn malloc(self: *Runtime, len: usize) ![*]u8 {        return self.heap.malloc(len);    }    pub fn calloc(self: *Runtime, count: usize, len: usize) ![*]u8 {        return self.heap.calloc(count, len);    }    pub fn realloc(self: *Runtime, ptr: ?[*]u8, new_len: usize) !?[*]u8 {        return self.heap.realloc(ptr, new_len);    }    pub fn free(self: *Runtime, ptr: ?[*]u8) void {        self.heap.freePointer(ptr);    }    pub fn freeIfOwned(self: *Runtime, ptr: ?[*]u8) bool {        return self.heap.freePointerIfOwned(ptr);    }    pub fn ownsPointer(self: *const Runtime, ptr: ?[*]u8) bool {        return self.heap.ownsPointer(ptr);    }    pub fn registerStackPad(self: *Runtime, slot: *u8) !void {        for (self.stack_pad_slots.items) |existing| {            if (existing == slot) return;        }        try self.stack_pad_slots.append(self.allocator, slot);    }    pub fn registeredStackPadCount(self: *const Runtime) usize {        return self.stack_pad_slots.items.len;    }    pub fn registerConstructor(self: *Runtime, constructor: ConstructorFn) !void {        try self.constructors.append(self.allocator, constructor);    }    pub fn constructorCount(self: *const Runtime) usize {        return self.constructors.items.len;    }    pub fn runConstructors(self: *Runtime) void {        for (self.constructors.items) |constructor| constructor();    }    pub fn registerFunctionRange(self: *Runtime, options: code_mod.FunctionRangeOptions) !code_mod.FunctionId {        return self.code.registerFunctionRange(options);    }    pub fn enterFunction(self: *Runtime, id: code_mod.FunctionId, roots: []const usize) !?usize {        const location = try self.code.enterFunction(id, roots);        return if (location) |active| active.base else null;    }    pub fn trapFunction(self: *Runtime, id: code_mod.FunctionId, roots: []const usize) !usize {        const location = try self.code.trap(id, roots);        return location.base;    }    pub fn adjustAddress(self: *const Runtime, address: usize) usize {        return self.code.adjustAddress(address);    }    pub fn adjustBacktrace(self: *const Runtime, adjusted: []usize, real: []const usize) []usize {        const count = @min(adjusted.len, real.len);        for (real[0..count], adjusted[0..count]) |address, *out| {            out.* = self.adjustAddress(address);        }        return adjusted[0..count];    }    pub fn runProgram(self: *Runtime, main: anytype, args: anytype) @TypeOf(@call(.auto, main, args)) {        self.code.trapRegisteredFunctions();        self.runConstructors();        return @call(.auto, main, args);    }    pub fn nextStackPad(self: *Runtime) stack.StackPad {        return self.stack.next(&self.rng);    }    pub fn rerandomize(self: *Runtime) void {        _ = self.rerandomizeAt(0);    }    pub fn rerandomizeAt(self: *Runtime, instruction_pointer: usize) usize {        if (self.config.code.enabled) {            if (self.code.functionCount() == 0) self.rerandomizeStackPads();            return self.code.beginRerandomizationAt(instruction_pointer);        } else {            self.rerandomizeStackPads();            return instruction_pointer;        }    }    fn rerandomizeStackPads(self: *Runtime) void {        if (!self.config.stack.enabled) return;        self.stack.refill(&self.rng);        for (self.stack_pad_slots.items) |slot| {            slot.* = self.rng.nextByte();        }    }};

Source: lib/stabilizer/src/root.zig:72

zig
pub const Runtime = runtime_mod.Runtime;
Called byCallsprivate sourcelib.stabilizer.src.properties.runtime.Runtime...propertyRuntimeadjustBacktracetest sourcelib.stabilizer.src.runtimetest: runtime adjusts relocated addre...test sourcelib.stabilizer.src.runtimetest: runtime enterFunction relocates...CodeRandomizeradjustAddressRuntimeadjustAddress
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate sourcelib.stabilizer.src.properties.runtime.Runtime...propertytest sourcelib.stabilizer.src.runtimetest: runtime adjusts relocated addre...RuntimeadjustAddressRuntimeadjustBacktrace
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersShuffleAllocatorcallocRuntimecalloc
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.stabilizer.src.properties.runtime.Constru...propertytest sourcelib.stabilizer.src.runtimetest: runtime runs registered constru...RuntimeconstructorCount
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.stabilizer.src.runtimetest: runtime adjusts relocated addre...test sourcelib.stabilizer.src.runtimetest: runtime arms code and runs cons...test sourcelib.stabilizer.src.runtimetest: runtime enterFunction relocates...test sourcelib.stabilizer.src.runtimetest: runtime rerandomizeAt preserves...test sourcelib.stabilizer.src.runtimetest: runtime rerandomize forwards in...+2 moreCodeRandomizerdeinitShuffleAllocatordeinitStackPadsdeinitRuntimedeinit
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsprivate sourcelib.stabilizer.src.properties.runtime.Runtime...propertyprivate sourcelib.stabilizer.src.properties.runtime.Runtime...propertytest sourcelib.stabilizer.src.properties.stacktest: runtime refills stack pads only...test sourcelib.stabilizer.src.runtimetest: runtime arms code and runs cons...test sourcelib.stabilizer.src.runtimetest: runtime enterFunction relocates...test sourcelib.stabilizer.src.runtimetest: runtime rerandomize forwards in...CodeRandomizerenterFunctionRuntimeenterFunction
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersShuffleAllocatorfreePointerRuntimefree
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersShuffleAllocatorfreePointerIfOwnedRuntimefreeIfOwned
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.stabilizer.src.runtimetest: runtime adjusts relocated addre...test sourcelib.stabilizer.src.runtimetest: runtime arms code and runs cons...test sourcelib.stabilizer.src.runtimetest: runtime enterFunction relocates...test sourcelib.stabilizer.src.runtimetest: runtime rerandomizeAt preserves...test sourcelib.stabilizer.src.runtimetest: runtime rerandomize forwards in...+2 moreCodeRandomizerinitShuffleAllocatorinitMarsagliainitStackPadsdeinitStackPadsinitRuntimeinit
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersShuffleAllocatormallocRuntimemalloc
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate sourcelib.stabilizer.src.properties.runtime.StackPa...propertytest sourcelib.stabilizer.src.properties.stacktest: stack pad draw stays within byt...test sourcelib.stabilizer.src.runtimetest: runtime rerandomizeAt preserves...test sourcelib.stabilizer.src.runtimetest: runtime rerandomizes registered...StackPadsnextRuntimenextStackPad
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersShuffleAllocatorownsPointerRuntimeownsPointer
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersShuffleAllocatorallocatorRuntimerandomizedAllocator
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersShuffleAllocatorreallocRuntimerealloc
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.stabilizer.src.properties.runtime.Constru...propertyprivate sourcelib.stabilizer.src.properties.runtime.Runtime...propertytest sourcelib.stabilizer.src.runtimetest: runtime arms code and runs cons...test sourcelib.stabilizer.src.runtimetest: runtime runs registered constru...RuntimeregisterConstructor
Static calls · unresolved targets: 1 · external targets: 0.
Called byCallsNo direct callersCodeRandomizerregisterFunctionRangeRuntimeregisterFunctionRange
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.stabilizer.src.properties.runtime.StackPa...propertytest sourcelib.stabilizer.src.runtimetest: runtime rerandomizes registered...RuntimeregisterStackPad
Static calls · unresolved targets: 1 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.stabilizer.src.properties.runtime.StackPa...propertytest sourcelib.stabilizer.src.runtimetest: runtime rerandomizes registered...RuntimeregisteredStackPadCount
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate sourcelib.stabilizer.src.properties.runtime.StackPa...propertytest sourcelib.stabilizer.src.properties.stacktest: runtime refills stack pads only...test sourcelib.stabilizer.src.runtimetest: runtime enterFunction relocates...test sourcelib.stabilizer.src.runtimetest: runtime rerandomizes registered...RuntimererandomizeAtRuntimererandomize
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate sourcelib.stabilizer.src.properties.runtime.Runtime...propertyRuntimererandomizetest sourcelib.stabilizer.src.runtimetest: runtime rerandomizeAt preserves...test sourcelib.stabilizer.src.runtimetest: runtime rerandomize forwards in...CodeRandomizerbeginRerandomizationAtCodeRandomizerfunctionCountprivate sourcelib.stabilizer.src.runtime.RuntimererandomizeStackPadsRuntimererandomizeAt
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.stabilizer.src.properties.runtime.Constru...propertyRuntimerunProgramtest sourcelib.stabilizer.src.runtimetest: runtime runs registered constru...RuntimerunConstructors
Static calls · unresolved targets: 1 · external targets: 0.
Called byCallsprivate sourcelib.stabilizer.src.properties.runtime.Runtime...propertytest sourcelib.stabilizer.src.runtimetest: runtime arms code and runs cons...CodeRandomizertrapRegisteredFunctionsRuntimerunConstructorsRuntimerunProgram
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersCodeRandomizertrapRuntimetrapFunction
Static calls · unresolved targets: 0 · external targets: 0.

Complete caller list for Runtime.deinit

7 direct callers.

Complete caller list for Runtime.init

7 direct callers.

Audit

Definitions24
Public names24
Members8
Version26.7.0
Revisiondaab053ee433