Ah ha! I found it. Testing with dynamically loading a library which
depends on libpthread triggers the problem when libpthread is not
built into the main program.
For example, if I test with libusb.so.2 with a program compiled without
-pthread, it triggers the problem. If I test with libusb.so.2 with
a program compiled with -pthread, it does not trigger the problem.
So the issue here is that libpthread is not built into the main
program and it needs to be, simple as that. If the main program is
compiled/linked with -pthread, the problem should go away.
--
In terms of making this work as-is with some sort of fix to rtld-elf...
that's problematic. A lot of these shared libraries are not designed
to be unloaded. It would take some time to vet them all.
For now I think the best solution is to adjust the port to compile/link
SBCL with -pthread.
-Matt