Skip to content

Commit 19c050f

Browse files
authored
Merge pull request ibmruntimes#375 from jasonkatonica/katonica/issue/fixjlinkjre17
Tolerate OpenJCEPlus FIPS binaries with jlink
2 parents eb870f1 + c242df0 commit 19c050f

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

src/jdk.jlink/linux/classes/jdk/tools/jlink/internal/plugins/StripNativeDebugSymbolsPlugin.java

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
* or visit www.oracle.com if you need additional information or have any
2323
* questions.
2424
*/
25+
/*
26+
* ===========================================================================
27+
* (c) Copyright IBM Corp. 2024, 2024 All Rights Reserved
28+
* ===========================================================================
29+
*/
2530
package jdk.tools.jlink.internal.plugins;
2631

2732
import java.io.InputStream;
@@ -104,9 +109,7 @@ public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
104109
stripBin);
105110
in.transformAndCopy((resource) -> {
106111
ResourcePoolEntry res = resource;
107-
if ((resource.type() == ResourcePoolEntry.Type.NATIVE_LIB &&
108-
resource.path().endsWith(SHARED_LIBS_EXT)) ||
109-
resource.type() == ResourcePoolEntry.Type.NATIVE_CMD) {
112+
if (shouldStrip(resource)) {
110113
Optional<StrippedDebugInfoBinary> strippedBin = builder.build(resource);
111114
if (strippedBin.isPresent()) {
112115
StrippedDebugInfoBinary sb = strippedBin.get();
@@ -131,6 +134,35 @@ public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
131134
return out.build();
132135
}
133136

137+
/**
138+
* Method to determine if a particular resource should be stripped.
139+
*
140+
* Particular paths are added here to handle libraries within the openjceplus module.
141+
* The FIPS certified library located in the C/icc directory is sensitive to
142+
* any modifications to the native library. Performing any modifications to the library
143+
* in any way, causes the FIPS library to fail to load due to a self verification check made.
144+
*
145+
* @param resource the resource to examine for stripping eligibility
146+
* @return return true if stripping should be done on a particular resource, false otherwise
147+
*/
148+
private static boolean shouldStrip(ResourcePoolEntry resource) {
149+
switch (resource.type()) {
150+
case NATIVE_CMD:
151+
return true;
152+
case NATIVE_LIB:
153+
String path = resource.path();
154+
if (path.endsWith(SHARED_LIBS_EXT)) {
155+
if (!(resource.moduleName().equals("openjceplus") && path.contains("/C/icc/"))) {
156+
return true;
157+
}
158+
}
159+
break;
160+
default:
161+
break;
162+
}
163+
return false;
164+
}
165+
134166
private void logError(ResourcePoolEntry resource, String msgKey) {
135167
String msg = getMessage(msgKey,
136168
NAME,

0 commit comments

Comments
 (0)