From 91da7fa5a0b6c316a311c81ab849e9ac959483a8 Mon Sep 17 00:00:00 2001 From: suchismith Date: Wed, 15 Nov 2023 18:00:55 +0000 Subject: [PATCH] Move mapping function to aix specific file. --- src/hotspot/os/aix/os_aix.cpp | 13 +++++++++++++ src/hotspot/os/aix/os_aix.hpp | 2 ++ src/hotspot/share/prims/jvmtiAgent.cpp | 23 +++++++---------------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp index c29e666c0fc4c..e5c7754d2ceba 100644 --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -3059,3 +3059,16 @@ int os::Aix::stat64x_via_LIBPATH(const char* path, struct stat64x* stat) { FREE_C_HEAP_ARRAY(char*, libpath); return ret; } + +// Provide alternate path for shared objects in AIX +void os::Aix::mapAlternateName(char* buffer,const char *extension){ + + unsigned long end=strlen(buffer); + while(end>0 && buffer[end]!='.') + { + end--; + } + buffer[end]='\0'; + strcat(buffer,extension); + } + diff --git a/src/hotspot/os/aix/os_aix.hpp b/src/hotspot/os/aix/os_aix.hpp index f2596874b051a..2aa30f8f0c8fe 100644 --- a/src/hotspot/os/aix/os_aix.hpp +++ b/src/hotspot/os/aix/os_aix.hpp @@ -177,6 +177,8 @@ class os::Aix { // Simulate the library search algorithm of dlopen() (in os::dll_load) static int stat64x_via_LIBPATH(const char* path, struct stat64x* stat); + static void mapAlternateName(char* buffer, const char *extension); + }; #endif // OS_AIX_OS_AIX_HPP diff --git a/src/hotspot/share/prims/jvmtiAgent.cpp b/src/hotspot/share/prims/jvmtiAgent.cpp index 505770dd55f07..36c4c7b23e32d 100644 --- a/src/hotspot/share/prims/jvmtiAgent.cpp +++ b/src/hotspot/share/prims/jvmtiAgent.cpp @@ -41,6 +41,7 @@ #include "runtime/os.inline.hpp" #include "runtime/thread.inline.hpp" #include "utilities/defaultStream.hpp" + static inline const char* copy_string(const char* str) { return str != nullptr ? os::strdup(str, mtServiceability) : nullptr; } @@ -320,16 +321,6 @@ static void* load_agent_from_absolute_path(JvmtiAgent* agent, bool vm_exit_on_er AIX_ONLY(if (library != nullptr) save_library_signature(agent, agent->name());) return library; } -static void mapAlternateName(char* buffer,const char *extension) -{ - unsigned long end=strlen(buffer); - while(end>0 && buffer[end]!='.') - { - end--; - } - buffer[end]='\0'; - strcat(buffer,extension); -} // Agents with relative paths are loaded from the standard dll directory. static void* load_agent_from_relative_path(JvmtiAgent* agent, bool vm_exit_on_error) { @@ -348,17 +339,17 @@ static void* load_agent_from_relative_path(JvmtiAgent* agent, bool vm_exit_on_er if (library != nullptr) { AIX_ONLY(save_library_signature(agent, &buffer[0]);) return library; - } - AIX_ONLY( - if (library == nullptr){ - mapAlternateName(buffer,AIX_EXTENSION); + } + #ifdef AIX + if (library == nullptr) { + os::Aix::mapAlternateName(buffer,AIX_EXTENSION); library=os::dll_load(&buffer[0], &ebuf[0], sizeof ebuf); - if(library!=nullptr){ + if(library!=nullptr) { save_library_signature(agent, &buffer[0]); return library; } } - ) + #endif if (vm_exit_on_error) { vm_exit(agent, " on the library path, with error: ", missing_module_error_msg); }