Resets non-previously-reset parts of the global state of several ext libs when detaching is in progress. Also adds a DR API routine to query whether a detach is in progress. For testing, adds a regression test that re-attaches with static-DR 100x and triggers #4769 (closed). This test is based on burst_malloc and it takes 16sec on a debug build (much faster than burst_malloc with 100 reattaches mostly thanks to use of -record_dynsym_only option and simpler do_some_work() functionality).
Fixes: #4769 (closed)