shop audit

This commit is contained in:
2026-02-14 14:00:27 -06:00
parent e80e615634
commit 8ec56e85fa
26 changed files with 19402 additions and 19132 deletions

View File

@@ -200,6 +200,9 @@ JSValue CELL_USE_NAME(JSContext *js) { \
JS_SetPropertyFunctionList(js, mod, FUNCS, countof(FUNCS)); \
return mod; }
#define CELL_PROGRAM_INIT(c) \
JSValue CELL_USE_NAME(JSContext *js) { do { c ; } while(0); }
#ifdef __cplusplus
}

View File

@@ -480,6 +480,31 @@ JSValue cell_rt_native_module_load(JSContext *ctx, void *dl_handle) {
return result;
}
/* Load a native module from a dylib handle, trying a named symbol first.
Falls back to cell_main if the named symbol is not found. */
JSValue cell_rt_native_module_load_named(JSContext *ctx, void *dl_handle, const char *sym_name) {
cell_compiled_fn fn = NULL;
if (sym_name)
fn = (cell_compiled_fn)dlsym(dl_handle, sym_name);
if (!fn)
fn = (cell_compiled_fn)dlsym(dl_handle, "cell_main");
if (!fn)
return JS_ThrowTypeError(ctx, "symbol not found in native module dylib");
void *prev_handle = g_current_dl_handle;
g_current_dl_handle = dl_handle;
JSValue *frame = calloc(512, sizeof(JSValue));
if (!frame) {
g_current_dl_handle = prev_handle;
return JS_ThrowTypeError(ctx, "frame allocation failed");
}
JSValue result = fn(ctx, frame);
g_current_dl_handle = prev_handle;
return result;
}
/* Backward-compat: uses RTLD_DEFAULT (works when dylib opened with RTLD_GLOBAL) */
JSValue cell_rt_module_entry(JSContext *ctx) {
void *handle = dlopen(NULL, RTLD_LAZY);