Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions make/autoconf/flags-cflags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# Setup flags for C/C++ compiler
#

###############################################################################
################################################################################
#
# How to compile shared libraries.
#
Expand All @@ -37,7 +37,10 @@ AC_DEFUN([FLAGS_SETUP_SHARED_LIBS],
if test "x$TOOLCHAIN_TYPE" = xgcc; then
# Default works for linux, might work on other platforms as well.
SHARED_LIBRARY_FLAGS='-shared'
SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
# --disable-new-dtags forces use of RPATH instead of RUNPATH for rpaths.
# This protects internal library dependencies within the JDK from being
# overridden using LD_LIBRARY_PATH. See JDK-8326891 for more information.
SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1 -Wl,--disable-new-dtags'
SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'

Expand All @@ -60,6 +63,9 @@ AC_DEFUN([FLAGS_SETUP_SHARED_LIBS],
# Default works for linux, might work on other platforms as well.
SHARED_LIBRARY_FLAGS='-shared'
SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
if test "x$OPENJDK_TARGET_OS" = xlinux; then
SET_EXECUTABLE_ORIGIN="$SET_EXECUTABLE_ORIGIN -Wl,--disable-new-dtags"
fi
SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'

# arm specific settings
Expand Down
23 changes: 11 additions & 12 deletions test/jdk/tools/launcher/RunpathTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -24,7 +24,8 @@
/*
* @test
* @bug 7190813 8022719
* @summary Check for extended RPATHs on *nixes
* @summary Check for extended RPATHs on Linux
* @requires os.family == "linux"
* @compile -XDignore.symbol.file RunpathTest.java
* @run main RunpathTest
* @author ksrini
Expand Down Expand Up @@ -57,25 +58,23 @@ void elfCheck(String javacmd, String expectedRpath) {
final TestResult tr = doExec(elfreaderCmd, "-d", javacmd);
if (!tr.matches(expectedRpath)) {
System.out.println(tr);
throw new RuntimeException("FAILED: RPATH/RUNPATH strings " +
throw new RuntimeException("FAILED: RPATH strings " +
expectedRpath + " not found in " + javaCmd);
}
System.out.println(javacmd + " contains expected RPATHS/RUNPATH");
System.out.println(javacmd + " contains expected RPATHS");
}

void testRpath() {
String expectedRpath = ".*R(UN)?PATH.*\\$ORIGIN/../lib.*";
String expectedRpath = ".*RPATH.*\\$ORIGIN/../lib.*";
elfCheck(javaCmd, expectedRpath);
}

public static void main(String... args) throws Exception {
if (isLinux) {
RunpathTest rp = new RunpathTest();
if (rp.elfreaderCmd == null) {
System.err.println("Warning: test passes vacuously");
return;
}
rp.testRpath();
RunpathTest rp = new RunpathTest();
if (rp.elfreaderCmd == null) {
System.err.println("Warning: test passes vacuously");
return;
}
rp.testRpath();
}
}