8080538: hprof does not work well with multiple agents on non-Solaris platforms

Never take the address of Agent_OnLoad.

Reviewed-by: sla, martin
This commit is contained in:
Jeremy Manson 2015-05-18 13:34:56 -07:00
parent eb68509b7d
commit 13c92b58f0

View File

@ -290,19 +290,7 @@ md_get_prelude_path(char *path, int path_len, char *filename)
Dl_info dlinfo;
libdir[0] = 0;
#if defined(LINUX) || defined(_ALLBSD_SOURCE) || defined(AIX)
addr = (void*)&Agent_OnLoad;
#else
/* Just using &Agent_OnLoad will get the first external symbol with
* this name in the first .so, which may not be libhprof.so.
* On Solaris we can actually ask for the address of our Agent_OnLoad.
*/
addr = dlsym(RTLD_SELF, "Agent_OnLoad");
/* Just in case the above didn't work (missing linker patch?). */
if ( addr == NULL ) {
addr = (void*)&Agent_OnLoad;
}
#endif
addr = (void*)&md_get_prelude_path;
/* Use dladdr() to get the full path to libhprof.so, which we use to find
* the prelude file.