// Copyright (C) 2026 SharpEmu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later using SharpEmu.Core.Memory; namespace SharpEmu.Core.Loader; public sealed class SelfImage { private readonly ulong _imageBase; public SelfImage( bool isSelf, ElfHeader elfHeader, IReadOnlyList programHeaders, IReadOnlyList mappedRegions, IReadOnlyDictionary? importStubs = null, IReadOnlyDictionary? runtimeSymbols = null, IReadOnlyList? importedRelocations = null, IReadOnlyList? preInitializerFunctions = null, IReadOnlyList? initializerFunctions = null, ulong initFunctionEntryPoint = 0, ulong imageBase = 0, ulong procParamAddress = 0, string? title = null, string? titleId = null, string? version = null) { ArgumentNullException.ThrowIfNull(programHeaders); ArgumentNullException.ThrowIfNull(mappedRegions); IsSelf = isSelf; ElfHeader = elfHeader; ProgramHeaders = programHeaders; MappedRegions = mappedRegions; ImportStubs = importStubs ?? new Dictionary(); RuntimeSymbols = runtimeSymbols ?? new Dictionary(StringComparer.Ordinal); ImportedRelocations = importedRelocations ?? Array.Empty(); PreInitializerFunctions = preInitializerFunctions ?? Array.Empty(); InitializerFunctions = initializerFunctions ?? Array.Empty(); InitFunctionEntryPoint = initFunctionEntryPoint; _imageBase = imageBase; ProcParamAddress = procParamAddress; Title = title; TitleId = titleId; Version = version; } public bool IsSelf { get; } public ElfHeader ElfHeader { get; } public IReadOnlyList ProgramHeaders { get; } public IReadOnlyList MappedRegions { get; } public IReadOnlyDictionary ImportStubs { get; } public IReadOnlyDictionary RuntimeSymbols { get; } public IReadOnlyList ImportedRelocations { get; } public IReadOnlyList PreInitializerFunctions { get; } public IReadOnlyList InitializerFunctions { get; } public ulong InitFunctionEntryPoint { get; } public ulong EntryPoint => ElfHeader.EntryPoint + _imageBase; public ulong ProcParamAddress { get; } public string? Title { get; } public string? TitleId { get; } public string? Version { get; } }