// STUB to load and init the so file #include #include #include #include void * libnix4Base = 0; // linked first stub __attribute__((section(".dlist_so_libnix4"))) long __so_libnix4_start[1] = {0}; // init all references by name void __so_libnix4_open() { libnix4Base = OldOpenLibrary("libnix4.library"); if (!libnix4Base) { FPuts(Output(), "failed to load libnix4.library\n"); exit(10); } register long * a0 asm("a0") = &__so_libnix4_start[1]; register void * a6 asm("a6") = libnix4Base; char const * s; asm volatile("jsr (-30,a6); move.l d0,%0": "=r"(s): "r"(a0), "r"(a6)); if (s) { BPTR out = Output(); FPuts(out, "can't resolve "); FPuts(out, s); FPuts(out, "\n"); exit(10); } } void __so_libnix4_close() { if (libnix4Base) CloseLibrary(libnix4Base); } ADD2INIT(__so_libnix4_open, -78); // priority one less than __initlibraries ADD2EXIT(__so_libnix4_close, -78);