1627 void * result = NULL;
1628 bool load_attempted = false;
1629
1630 // Check whether the library to load might change execution rights
1631 // of the stack. If they are changed, the protection of the stack
1632 // guard pages will be lost. We need a safepoint to fix this.
1633 //
1634 // See Linux man page execstack(8) for more info.
1635 if (os::uses_stack_guard_pages() && !os::Linux::_stack_is_executable) {
1636 if (!ElfFile::specifies_noexecstack(filename)) {
1637 if (!is_init_completed()) {
1638 os::Linux::_stack_is_executable = true;
1639 // This is OK - No Java threads have been created yet, and hence no
1640 // stack guard pages to fix.
1641 //
1642 // This should happen only when you are building JDK7 using a very
1643 // old version of JDK6 (e.g., with JPRT) and running test_gamma.
1644 //
1645 // Dynamic loader will make all stacks executable after
1646 // this function returns, and will not do that again.
1647 #ifdef ASSERT
1648 ThreadsListHandle tlh;
1649 assert(tlh.length() == 0, "no Java threads should exist yet.");
1650 #endif
1651 } else {
1652 warning("You have loaded library %s which might have disabled stack guard. "
1653 "The VM will try to fix the stack guard now.\n"
1654 "It's highly recommended that you fix the library with "
1655 "'execstack -c <libfile>', or link it with '-z noexecstack'.",
1656 filename);
1657
1658 assert(Thread::current()->is_Java_thread(), "must be Java thread");
1659 JavaThread *jt = JavaThread::current();
1660 if (jt->thread_state() != _thread_in_native) {
1661 // This happens when a compiler thread tries to load a hsdis-<arch>.so file
1662 // that requires ExecStack. Cannot enter safe point. Let's give up.
1663 warning("Unable to fix stack guard. Giving up.");
1664 } else {
1665 if (!LoadExecStackDllInVMThread) {
1666 // This is for the case where the DLL has an static
1667 // constructor function that executes JNI code. We cannot
1668 // load such DLLs in the VMThread.
1669 result = os::Linux::dlopen_helper(filename, ebuf, ebuflen);
1670 }
|
1627 void * result = NULL;
1628 bool load_attempted = false;
1629
1630 // Check whether the library to load might change execution rights
1631 // of the stack. If they are changed, the protection of the stack
1632 // guard pages will be lost. We need a safepoint to fix this.
1633 //
1634 // See Linux man page execstack(8) for more info.
1635 if (os::uses_stack_guard_pages() && !os::Linux::_stack_is_executable) {
1636 if (!ElfFile::specifies_noexecstack(filename)) {
1637 if (!is_init_completed()) {
1638 os::Linux::_stack_is_executable = true;
1639 // This is OK - No Java threads have been created yet, and hence no
1640 // stack guard pages to fix.
1641 //
1642 // This should happen only when you are building JDK7 using a very
1643 // old version of JDK6 (e.g., with JPRT) and running test_gamma.
1644 //
1645 // Dynamic loader will make all stacks executable after
1646 // this function returns, and will not do that again.
1647 assert(Threads::number_of_threads() == 0, "no Java threads should exist yet.");
1648 } else {
1649 warning("You have loaded library %s which might have disabled stack guard. "
1650 "The VM will try to fix the stack guard now.\n"
1651 "It's highly recommended that you fix the library with "
1652 "'execstack -c <libfile>', or link it with '-z noexecstack'.",
1653 filename);
1654
1655 assert(Thread::current()->is_Java_thread(), "must be Java thread");
1656 JavaThread *jt = JavaThread::current();
1657 if (jt->thread_state() != _thread_in_native) {
1658 // This happens when a compiler thread tries to load a hsdis-<arch>.so file
1659 // that requires ExecStack. Cannot enter safe point. Let's give up.
1660 warning("Unable to fix stack guard. Giving up.");
1661 } else {
1662 if (!LoadExecStackDllInVMThread) {
1663 // This is for the case where the DLL has an static
1664 // constructor function that executes JNI code. We cannot
1665 // load such DLLs in the VMThread.
1666 result = os::Linux::dlopen_helper(filename, ebuf, ebuflen);
1667 }
|