Repository navigation
Masa v1.2.0 — Masa Danroot Layer 1
Masa v1.2.0 — Masa Danroot Layer 1
The Masa Danroot loader (masa run / masa danroot) now loads dynamic
libraries, and the built-in libSystem shim grows the POSIX and Darwin
system calls a linked program needs.
Dynamic library loading
- Follows
LC_LOAD_DYLIB,LC_LOAD_WEAK_DYLIBandLC_REEXPORT_DYLIBin
bothMH_EXECUTEandMH_DYLIBimages, recursively, so a library's own
dependencies are loaded too. A module is registered before recursing, so
a cyclic reference resolves instead of looping. - Resolves dependency paths the
dyldway:@executable_path/,
@loader_path/and@rpath/(againstLC_RPATH, plus
MASA_LIBRARY_PATH/DYLD_LIBRARY_PATH), absolute paths, and bare
names on those search paths and the loading image's directory. - A missing required dependency is a clear error; a missing weak one is
skipped and a weak import binds toNULL. /usr/lib/libSystem.B.dyliband/usr/lib/libSystem.dylibare never
read from disk — the built-in shim satisfies them.- Indexes each image's exports from
LC_DYLD_EXPORTS_TRIE(with an
LC_SYMTABfallback) and resolves cross-image binds, applying chained
fixups (DYLD_CHAINED_PTR_64/_64_OFFSET) or the classic
LC_DYLD_INFO_ONLYrebase/bind opcodes per module.
Expanded libSystem shim
- Standard I/O:
fopen,fclose,fread,fwrite,fgets,fputs,
fseek,ftell,feof,ferror,fflush,sprintf,snprintf,
vsnprintf,sscanf. - File descriptors:
lseek,access,unlink,mkdir,rmdir,
getcwd,chdir. - Strings/memory:
strcat,strncat,strchr,strrchr,strstr,
strdup,strndup,strerror. - Process/environment:
setenv,unsetenv,getpid,getuid,isatty,
usleep,sleep. - Darwin system information:
uname(reportingDarwin) and
sysctlbyname(kern.ostype,kern.osrelease,hw.machine,
hw.ncpu,hw.memsize, ...). - Dynamic linker:
dlopen,dlsym,dlclose,dlerror, wired into the
same resolver. Standard streams exposed as data symbols (__stdoutp
and friends).
Stub SDK
- Adds a
dylib1.olink stub somasa cc -dynamicliblinks, expands the
libSystem.tbdsymbol list, and addsunistd.h,fcntl.h,dlfcn.h,
sys/stat.h,sys/utsname.h,sys/sysctl.h.
Example
masa sdk init-stub /opt/masa/sdk
MASA_SDK_PATH=/opt/masa/sdk masa cc -dynamiclib helper.c -o libhelper.dylib \
-install_name @rpath/libhelper.dylib
MASA_SDK_PATH=/opt/masa/sdk masa cc main.c -L. -lhelper \
-Wl,-rpath,@executable_path -o app
masa run ./appVerification
102 tests run, 0 failed, 1 skipped (the optional SDL2 GUI target), clean
under AddressSanitizer + UndefinedBehaviorSanitizer with -Werror, on
both gcc and clang; the Windows (MinGW-w64) cross-build is clean.
This release was prepared by an AI agent (OpenHands) on behalf of the
repository owner.