Current limits and trust

Only application content is supported: a CIA (encrypted ones decrypted with the user's keys as above, without seed crypto), a cartridge image's game partition and update partition, a standalone update and a DLC beside their game, and a bare NCCH — not a cartridge's manual or DLP partitions as content of their own, system titles or nonstandard NCCH media units/platforms. A cartridge image may be as large as a card (8 GiB), since it is read where it lies; a CIA's input, the total materialized output and a RomFS view are each capped at 4 GiB (the runtime's policy, not a format limit); metadata tables at 16 MiB, code at 64 MiB, entries at 100000, and RomFS nesting at 64. Host filenames must be portable safe components (maximum 255 UTF-8 bytes); unsafe/reserved names are rejected rather than silently renamed. Host paths with control characters are refused to prevent log/banner injection. Larger/unsupported inputs fail closed.

The CRO loader implements ldr:ro's Initialize (0x1), LoadCRO (0x4), LoadCRO_New (0x9), UnloadCRO (0x5), Link (0x6), Unlink (0x7) and Shutdown (0x8), ported from Azahar's ldr_ro.cpp and cro_helper.cpp at a4b335e.

Hashes are integrity checks, not signature authentication. RSA/ECDSA signatures, certificate trust, ticket rights and ExHeader access-descriptor signatures are not authenticated. The headers' and superblocks' hashes (NCCH ExHeader, ExeFS and RomFS superblocks, the TMD's tables) are checked every time. The whole-data ones (each CIA content, each ExeFS file, the input itself) are checked by an extraction only, not by the launch that reads a game where it lies, where they cost seconds on a retail title; an extraction to a folder given hashes no input. The internal IVFC hash tree is not separately verified. The NCSD header's RSA signature is read and ignored, as a CIA's sections' are. AOT execution is not a host security sandbox. Run only images you trust: compiler correctness is not isolation, and native loading can execute host constructors before descriptor validation. A launch loads the <title ID>_code.so an earlier compile published in the game's folder when it still matches the build's module ABI and the image's identity, so the extraction folder must be as trusted as the program itself. Do not treat ABI/hash checks, host native modules or an editable extraction manifest as authenticated permissions.

The image loader derives layout from raw ExHeader and requires exact page-packed expanded .code; it ignores manifest.ini for execution. Its compatibility hash covers a versioned domain, full ExHeader and full expanded code. It is not yet a complete cache key (CIA/resources, compiler/build/configuration versions and resume policy still need a separate design). Initial AOT also requires a word-multiple declared text length. Text-page padding beyond declared text has no static entry, even if its page is executable: it compiles at run time, as any code the static graph lacks does. The static graph is bounded by the text itself (each instruction slot is visited once in each instruction set). Objects together are capped at 1 GiB and the linked module at 1 GiB, and only the module is kept, beside the game as <title ID>_code.so. The chunks are of 512 blocks, compiled on the aot_threads threads (75% of the physical cores by default).

Build and test

scarletnx-3ds holds the AOT compiler, and its presenter and audio output use SDL3 and Vulkan headers, which CMake fetches as for the Switch runtime. With the normal Clang and CMake prerequisites:

cmake -S . -B build/3ds -DSNX_BUILD_NX=OFF -DSNX_BUILD_GNUABI=OFF -DSNX_BUILD_GUI=OFF
cmake --build build/3ds
ctest --test-dir build/3ds --output-on-failure
build/3ds/scarletnx-3ds --model new --board-info
build/3ds/scarletnx-3ds --output work/small-title --max-blocks 100000 small.cia

The 3DS tests are named 3ds_* and ctr_* (ctest -R "3ds|ctr", 3ds_cci the cartridge images' and bare NCCHs'), and the ARM CPU tests the 3DS shares with the Switch's 32-bit games arm_*. Use -DSNX_BUILD_GUI=ON to include the launcher and its regression tests. -DSNX_BUILD_3DS=OFF omits the driver with its compiler and runtime (the GUI diagnoses its absence). Additional static AOT tests are explicitly opt-in:

cmake -S . -B build/arm11 -DSNX_BUILD_NX=OFF -DSNX_BUILD_GNUABI=OFF \
  -DSNX_BUILD_GUI=OFF -DSNX_TEST_ARM_AOT=ON
cmake --build build/arm11
ctest --test-dir build/arm11 --output-on-failure

SNX_TEST_ARM_DIFF=ON additionally requires Python unicorn==2.1.4, and enables ARM11 MPCore plus shared A57 integer/VFP/NEON/Thumb regressions of the native back ends' blocks. See src/common/cpu/arm/README.md for the codegen contract and exact limitations. The compiler links its objects with the recompiler's own linker, so a game compiles on a machine without a C compiler. On Windows scarletnx-3ds carries the runtime's application manifest (long paths, UTF-8 code page), and the module is a DLL linked with DEP and ASLR compatibility, exporting only its descriptor. Add SNX_TEST_ARM_AOT=ON for the CPU tests as well as the pipeline's. To run the optional external SuperTux bootstrap gate, set SNX_TEST_3DS_SUPERTUX=/absolute/path/to/Supertux.cia. SNX_TEST_ARM_DIFF=ON additionally compares its first-SVC GPR/CPSR and complete data/stack/TLS snapshots against pinned Unicorn ARM11 MPCore. A second CPU comparison reaches ConnectToPort with test-scripted HLE effects and complete heap/linear snapshots. The second comparison validates CPU behavior under that transcript, not hardware kernel semantics. A third comparison continues through scripted srv: connection/registration effects to before APT lookup, again matching all GPRs/CPSR and complete RAM snapshots without independently proving IPC policy. Unicorn is never a runtime engine. The same native witness subsequently observes CRT entry into main, successful RomFS file/archive opens, scalar VFP execution and the archive timestamp request answered with success, then runs a fixed number of blocks more one at a time and a few of the driver's polled slices. Separate native CIA and unit tests exercise actual worker wakeups, resources and rollback. Service policy is not independently hardware-validated. No sample binaries are downloaded or distributed.


Made from docs/platforms/3ds/README.md at 69237645142c. GPL-3.0-or-later.