1.1 --- a/src/share/vm/prims/whitebox.cpp Fri Mar 30 20:09:45 2018 +0000 1.2 +++ b/src/share/vm/prims/whitebox.cpp Tue Jan 16 04:20:19 2018 -0500 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -158,6 +158,9 @@ 1.11 } 1.12 WB_END 1.13 1.14 +#ifdef LINUX 1.15 +#include "utilities/elfFile.hpp" 1.16 +#endif 1.17 1.18 WB_ENTRY(jlong, WB_GetCompressedOopsMaxHeapSize(JNIEnv* env, jobject o)) { 1.19 return (jlong)Arguments::max_heap_for_compressed_oops(); 1.20 @@ -1010,6 +1013,21 @@ 1.21 } 1.22 } 1.23 1.24 +// Checks that the library libfile has the noexecstack bit set. 1.25 +WB_ENTRY(jboolean, WB_CheckLibSpecifiesNoexecstack(JNIEnv* env, jobject o, jstring libfile)) 1.26 + jboolean ret = false; 1.27 +#ifdef LINUX 1.28 + // Can't be in VM when we call JNI. 1.29 + ThreadToNativeFromVM ttnfv(thread); 1.30 + const char* lf = env->GetStringUTFChars(libfile, NULL); 1.31 + CHECK_JNI_EXCEPTION_(env, 0); 1.32 + ElfFile ef(lf); 1.33 + ret = (jboolean) ef.specifies_noexecstack(); 1.34 + env->ReleaseStringUTFChars(libfile, lf); 1.35 +#endif 1.36 + return ret; 1.37 +WB_END 1.38 + 1.39 #define CC (char*) 1.40 1.41 static JNINativeMethod methods[] = { 1.42 @@ -1121,6 +1139,8 @@ 1.43 (void*)&WB_GetNMethod }, 1.44 {CC"isMonitorInflated", CC"(Ljava/lang/Object;)Z", (void*)&WB_IsMonitorInflated }, 1.45 {CC"forceSafepoint", CC"()V", (void*)&WB_ForceSafepoint }, 1.46 + {CC"checkLibSpecifiesNoexecstack", CC"(Ljava/lang/String;)Z", 1.47 + (void*)&WB_CheckLibSpecifiesNoexecstack}, 1.48 }; 1.49 1.50 #undef CC