I can now confirm that the part of the document
http://dlang.org/dll-linux.html
about loading D dynamic libraries from a D main program is
experimentally apparently correct with a real world largish
executable.
The machinery to initialize the runtime in the dynamic library
in
http://stackoverflow.com/questions/9759880/automatically-executed-functions-when-loading-shared-libraries
is apparently unnecessary in this case, though I have seen some
hints it may be necessary when having a C main program load a D
dynamic library.
If you want a D dynamic library to call-back functions in the D
main program that loaded it, you may need to supply the linker
with the -export-dynamic flag (on the dmd command line with
-L-export-dynamic ) so as to expose symbols in the main program
for automatic linkage to the dynamic library at the point it is
loaded. This worked nicely for me.
On Ubuntu amd64 I found that no special build of a C client that
loads a D dynamic library using dlopen (etc) is necessary for
callback linkage from the library to the client. So
-export-dynamic is unnecessary! However, the machinery mentioned
here
http://stackoverflow.com/questions/9759880/automatically-executed-functions-when-loading-shared-libraries
IS necessary so that the runtime in the dynamic library is
initialized when it is loaded.