diff src/os/bsd/vm/os_bsd.cpp @ 17684:d1621038becf

8031968: Mac OS X: VM starts the agent by calling both Agent_OnAttach and Agent_OnAttach_L functions if its agent library is dynamically linked. Summary: Make sure we only look for statically linked agents in the main process image Reviewed-by: dsamersoff, bpittore, dcubed
author sla
date Thu, 23 Jan 2014 09:06:21 +0100
parents 3b32d287da89
children 5944dba4badc bbfbe9b06038
line wrap: on
line diff
--- a/src/os/bsd/vm/os_bsd.cpp	Tue Feb 11 08:49:37 2014 -0800
+++ b/src/os/bsd/vm/os_bsd.cpp	Thu Jan 23 09:06:21 2014 +0100
@@ -1557,6 +1557,17 @@
 }
 #endif /* !__APPLE__ */
 
+void* os::get_default_process_handle() {
+#ifdef __APPLE__
+  // MacOS X needs to use RTLD_FIRST instead of RTLD_LAZY
+  // to avoid finding unexpected symbols on second (or later)
+  // loads of a library.
+  return (void*)::dlopen(NULL, RTLD_FIRST);
+#else
+  return (void*)::dlopen(NULL, RTLD_LAZY);
+#endif
+}
+
 // XXX: Do we need a lock around this as per Linux?
 void* os::dll_lookup(void* handle, const char* name) {
   return dlsym(handle, name);