You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quick reference for the main functions in spec-elf. Functions marked public are exported by the library; the rest
are implementation details and may change without notice.
Creates a new archive, copies the launcher, compresses each payload as an independent checksummed Zstandard frame, then appends the manifest and footer. Refuses to overwrite an existing output.
read_back(path)
Public
Validates the footer and manifest, selects the best compatible payload, decompresses it, and returns its original bytes.
is_archive(path)
Public
Checks the fixed footer magic and marker without parsing or extracting the complete archive.
read_u32(file)
Internal
Reads one little-endian u32 from the current file position.
read_u64(file)
Internal
Reads one little-endian u64 from the current file position.
ensure_available(file, end, size)
Internal
Verifies that a manifest read stays inside the declared manifest range and cannot overflow.
decompress_payload(file, entry)
Internal
Decompresses only the selected Zstandard frame, verifies its checksum and exact declared size, and enforces the 1 GiB safety limit.
find_optimal(entries, native_hash)
Internal
Supplies the current CPU level and native identity to the deterministic selection function.
Selects matching native first, then falls back from the highest supported standardized level to baseline.
payload_label(name)
Internal
Removes a final case-insensitive .exe extension before payload-name matching.
label_matches(label, target)
Internal
Matches a target as the complete label or as a suffix separated by - or _.
src/arch/x86.rs — CPU detection
Function
Visibility
What it does
detect_x86_level()
Public
Uses CPUID plus enabled OS register state to classify the host as baseline x86-64, v2, v3, or v4.
native_hasher()
Public
Hashes the host OS, architecture, CPU identity, feature bits, and extended-register state for safe native matching. Returns None when required CPU identity data is unavailable.
push_feature(parts, name, enabled)
Internal
Adds an enabled CPU feature to the normalized input used by native_hasher.
X86Level
The public X86Level enum is ordered from least to most capable:
X86_64 < V2 < V3 < V4
That ordering lets payload selection reject targets above the detected host level and choose the highest available
compatible fallback.
Tests
Test
Protects against
normal_file_is_not_archive
Treating ordinary files as packed launchers.
packed_file_is_archive
Failing to recognize a valid packed launcher.
packed_file_reads_best_payload
Extracting the wrong CPU variant.
selection_falls_back_to_a_lower_level
Failing when the exact highest variant is absent.
selection_accepts_windows_executable_names
Mishandling .exe suffixes or mixed -/_ target names.
malformed_manifest_range_is_rejected
Integer overflow and invalid manifest ranges.
payloads_are_zstd_compressed
Accidentally storing raw payload bytes or breaking Zstandard round trips.
corrupted_zstd_payload_is_rejected
Accepting payloads that fail Zstandard frame checksum validation.
language_detection_ignores_c_headers
Misclassifying C++ projects because of shared C headers.
language_detection_rejects_ties
Silently choosing one language when source counts tie.
reads_explicit_cargo_binary_name
Copying the wrong Rust executable when [[bin]] differs from the package name.