The runtime library's module tables hold 32 modules, not the release's MOD_COUNT: an install's plugins fit (#845)

loader.c and memory.c sized their tables by MOD_COUNT of the layout.h make_release.py built libtotkrt.a against (3:
main, subsdk0, sdk). An install whose rebuild adds a plugin has 4, and its service run stopped at once with "loader: 4
modules in the layout"; dev builds compile those files against their own layout and never saw it. RT_MAX_MODULES
(host.h) is the bound now; the loader still refuses a layout above it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-11-17 10:35:49 +03:00
1 parent c97ceb6451
commit c477b67a09
4 files changed
+11 -7

No files matched your search

+4 -4
View File
@@ -47,11 +47,11 @@ typedef struct {
uint64_t *plt_slot, *plt_stub, nplt; // PLT stubs sorted by GOT slot (ldr_plt_stub), built on first use
// statistics
uint64_t kinds[K_COUNT], sym_import, sym_own;
uint32_t imports, import_to[MOD_COUNT], weak_unresolved, strong_unresolved;
uint32_t imports, import_to[RT_MAX_MODULES], weak_unresolved, strong_unresolved;
uint32_t init_off;
} Mod;
static Mod mods[MOD_COUNT];
static Mod mods[RT_MAX_MODULES];
GuestFn ldr_plugin_import;
static int nmods;
static uint64_t identity_refs, stubs;
@@ -503,7 +503,7 @@ static void seal(Mod *m) {
void ldr_load(const char *exefs_dir) {
if (nmods) rt_fatal("ldr_load called twice");
if (!mem_layout()->pool) rt_fatal("ldr_load before mem_init");
if (rt_layout_count > MOD_COUNT) rt_fatal("loader: %d modules in the layout", rt_layout_count);
if (rt_layout_count > RT_MAX_MODULES) rt_fatal("loader: %d modules in the layout", rt_layout_count);
int n = 0;
for (int i = 0; i < rt_layout_count; i++) {
// A mod plugin's file that is gone or changed since the build is left out at play time: its patch set cannot
@@ -622,7 +622,7 @@ uint64_t ldr_plt_stub(const char *module, const char *name) {
typedef struct {
const char *name;
uint64_t kinds[K_COUNT], total, sym_import, sym_own;
uint32_t imports, to[MOD_COUNT], weak, init_off, init_array;
uint32_t imports, to[RT_MAX_MODULES], weak, init_off, init_array;
} Expect;
static const Expect expect_121[] = {
{"main", {508816, 1415, 32, 641}, 510904, 2088, 0, 675, {0, 16, 647}, 12, 0x30, 10673},