Implement self-dlopen. Closes #1359.

Caveats: I'm not sure how this impacts the old shared library code, since the tests have all degenerated since the feature was deprecated. I tried building a simple shared module using the code on `incoming` and also ran into problems. Perhaps I'm doing it wrong? I couldn't find much documentation on this, so I just used the `BUILD_AS_SHARED_LIBRARY` environment variable. Nonetheless, as long as one sticks to calling dlopen with just `NULL`, things should work fine. I am opening this PR to get comments first, and will work on integrating it with `dlopen` on external libraries later if deemed necessary.