Skip to content

Commit 0304d25

Browse files
committed
backport 871362870ea8dc5f4ac186876e91023116891a5b
1 parent a6014d0 commit 0304d25

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/hotspot/os/aix/os_aix.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ bool os::dll_address_to_library_name(address addr, char* buf,
11081108
return true;
11091109
}
11101110

1111-
static void* dll_load_library(const char *filename, char *ebuf, int ebuflen) {
1111+
static void* dll_load_library(const char *filename, int *eno, char *ebuf, int ebuflen) {
11121112

11131113
log_info(os)("attempting shared library load of %s", filename);
11141114
if (ebuf && ebuflen > 0) {
@@ -1135,7 +1135,7 @@ static void* dll_load_library(const char *filename, char *ebuf, int ebuflen) {
11351135

11361136
void* result;
11371137
const char* error_report = nullptr;
1138-
result = Aix_dlopen(filename, dflags, &error_report);
1138+
result = Aix_dlopen(filename, dflags, eno, &error_report);
11391139
if (result != nullptr) {
11401140
Events::log_dll_message(nullptr, "Loaded shared library %s", filename);
11411141
// Reload dll cache. Don't do this in signal handling.
@@ -1166,12 +1166,13 @@ void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
11661166
const char new_extension[] = ".a";
11671167
STATIC_ASSERT(sizeof(old_extension) >= sizeof(new_extension));
11681168
// First try to load the existing file.
1169-
result = dll_load_library(filename, ebuf, ebuflen);
1169+
int eno=0;
1170+
result = dll_load_library(filename, &eno, ebuf, ebuflen);
11701171
// If the load fails,we try to reload by changing the extension to .a for .so files only.
11711172
// Shared object in .so format dont have braces, hence they get removed for archives with members.
1172-
if (result == nullptr && pointer_to_dot != nullptr && strcmp(pointer_to_dot, old_extension) == 0) {
1173+
if (result == nullptr && eno == ENOENT && pointer_to_dot != nullptr && strcmp(pointer_to_dot, old_extension) == 0) {
11731174
snprintf(pointer_to_dot, sizeof(old_extension), "%s", new_extension);
1174-
result = dll_load_library(file_path, ebuf, ebuflen);
1175+
result = dll_load_library(file_path, &eno, ebuf, ebuflen);
11751176
}
11761177
FREE_C_HEAP_ARRAY(char, file_path);
11771178
return result;

src/hotspot/os/aix/porting_aix.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ static bool search_file_in_LIBPATH(const char* path, struct stat64x* stat) {
10351035
// specific AIX versions for ::dlopen() and ::dlclose(), which handles the struct g_handletable
10361036
// This way we mimic dl handle equality for a library
10371037
// opened a second time, as it is implemented on other platforms.
1038-
void* Aix_dlopen(const char* filename, int Flags, const char** error_report) {
1038+
void* Aix_dlopen(const char* filename, int Flags, int *eno, const char** error_report) {
10391039
assert(error_report != nullptr, "error_report is nullptr");
10401040
void* result;
10411041
struct stat64x libstat;
@@ -1047,6 +1047,7 @@ void* Aix_dlopen(const char* filename, int Flags, const char** error_report) {
10471047
assert(result == nullptr, "dll_load: Could not stat() file %s, but dlopen() worked; Have to improve stat()", filename);
10481048
#endif
10491049
*error_report = "Could not load module .\nSystem error: No such file or directory";
1050+
*eno = ENOENT;
10501051
return nullptr;
10511052
}
10521053
else {
@@ -1090,6 +1091,7 @@ void* Aix_dlopen(const char* filename, int Flags, const char** error_report) {
10901091
p_handletable = new_tab;
10911092
}
10921093
// Library not yet loaded; load it, then store its handle in handle table
1094+
errno = 0;
10931095
result = ::dlopen(filename, Flags);
10941096
if (result != nullptr) {
10951097
g_handletable_used++;
@@ -1101,6 +1103,7 @@ void* Aix_dlopen(const char* filename, int Flags, const char** error_report) {
11011103
}
11021104
else {
11031105
// error analysis when dlopen fails
1106+
*eno = errno;
11041107
*error_report = ::dlerror();
11051108
if (*error_report == nullptr) {
11061109
*error_report = "dlerror returned no error description";

src/hotspot/os/aix/porting_aix.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,6 @@ class AixMisc {
115115

116116
};
117117

118-
void* Aix_dlopen(const char* filename, int Flags, const char** error_report);
118+
void* Aix_dlopen(const char* filename, int Flags, int *eno, const char** error_report);
119119

120120
#endif // OS_AIX_PORTING_AIX_HPP

0 commit comments

Comments
 (0)