8320005: Allow loading of shared objects with .a extension on AIX
Reviewed-by: amitkumar, stuefe, jkern, mdoerr
This commit is contained in:
parent
5d3d40d962
commit
e85355ada4
@ -1127,10 +1127,9 @@ bool os::dll_address_to_library_name(address addr, char* buf,
|
||||
return true;
|
||||
}
|
||||
|
||||
void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
||||
static void* dll_load_library(const char *filename, char *ebuf, int ebuflen) {
|
||||
|
||||
log_info(os)("attempting shared library load of %s", filename);
|
||||
|
||||
if (ebuf && ebuflen > 0) {
|
||||
ebuf[0] = '\0';
|
||||
ebuf[ebuflen - 1] = '\0';
|
||||
@ -1178,6 +1177,26 @@ void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
// Load library named <filename>
|
||||
// If filename matches <name>.so, and loading fails, repeat with <name>.a.
|
||||
void *os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
||||
void* result = nullptr;
|
||||
char* const file_path = strdup(filename);
|
||||
char* const pointer_to_dot = strrchr(file_path, '.');
|
||||
const char old_extension[] = ".so";
|
||||
const char new_extension[] = ".a";
|
||||
STATIC_ASSERT(sizeof(old_extension) >= sizeof(new_extension));
|
||||
// First try to load the existing file.
|
||||
result = dll_load_library(filename, ebuf, ebuflen);
|
||||
// If the load fails,we try to reload by changing the extension to .a for .so files only.
|
||||
// Shared object in .so format dont have braces, hence they get removed for archives with members.
|
||||
if (result == nullptr && pointer_to_dot != nullptr && strcmp(pointer_to_dot, old_extension) == 0) {
|
||||
snprintf(pointer_to_dot, sizeof(old_extension), "%s", new_extension);
|
||||
result = dll_load_library(file_path, ebuf, ebuflen);
|
||||
}
|
||||
FREE_C_HEAP_ARRAY(char, file_path);
|
||||
return result;
|
||||
}
|
||||
|
||||
void os::print_dll_info(outputStream *st) {
|
||||
st->print_cr("Dynamic libraries:");
|
||||
|
Loading…
x
Reference in New Issue
Block a user