3 import core
.stdc
.string
;
4 import core
.sys
.posix
.dlfcn
;
6 shared uint tlsDtor
, dtor
;
7 void staticDtorHook() { atomicOp
!"+="(tlsDtor
, 1); }
8 void sharedStaticDtorHook() { atomicOp
!"+="(dtor
, 1); }
10 void runTest(string name
)
12 auto h
= Runtime
.loadLibrary(name
);
15 *cast(void function()*).dlsym(h
, "_D9lib_1341414staticDtorHookOPFZv") = &staticDtorHook
;
16 *cast(void function()*).dlsym(h
, "_D9lib_1341420sharedStaticDtorHookOPFZv") = &sharedStaticDtorHook
;
18 Runtime
.unloadLibrary(h
);
19 version (CRuntime_Musl
)
21 // On Musl, unloadLibrary is a no-op because dlclose is a no-op
32 void main(string
[] args
)
34 auto name
= args
[0] ~ '\0';
35 const pathlen
= strrchr(name
.ptr
, '/') - name
.ptr
+ 1;
36 name
= name
[0 .. pathlen
] ~ "lib_13414.so";