Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/runtime/7107135/Test7107135.sh
32284 views
1
#!/bin/sh
2
3
#
4
# Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
5
# Copyright (c) 2011 SAP AG. All Rights Reserved.
6
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7
#
8
# This code is free software; you can redistribute it and/or modify it
9
# under the terms of the GNU General Public License version 2 only, as
10
# published by the Free Software Foundation.
11
#
12
# This code is distributed in the hope that it will be useful, but WITHOUT
13
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15
# version 2 for more details (a copy is included in the LICENSE file that
16
# accompanied this code).
17
#
18
# You should have received a copy of the GNU General Public License version
19
# 2 along with this work; if not, write to the Free Software Foundation,
20
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21
#
22
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23
# or visit www.oracle.com if you need additional information or have any
24
# questions.
25
#
26
27
##
28
## @test Test7107135.sh
29
## @bug 7107135
30
## @bug 8021296
31
## @summary Stack guard pages lost after loading library with executable stack.
32
## @run shell Test7107135.sh
33
##
34
35
if [ "${TESTSRC}" = "" ]
36
then
37
TESTSRC=${PWD}
38
echo "TESTSRC not set. Using "${TESTSRC}" as default"
39
fi
40
echo "TESTSRC=${TESTSRC}"
41
## Adding common setup Variables for running shell tests.
42
. ${TESTSRC}/../../test_env.sh
43
44
# set platform-dependent variables
45
OS=`uname -s`
46
case "$OS" in
47
Linux)
48
echo "Testing on Linux"
49
gcc_cmd=`which gcc`
50
if [ "x$gcc_cmd" == "x" ]; then
51
echo "WARNING: gcc not found. Cannot execute test." 2>&1
52
exit 0;
53
fi
54
;;
55
*)
56
echo "Test passed; only valid for Linux"
57
exit 0;
58
;;
59
esac
60
61
ARCH=`uname -m`
62
63
THIS_DIR=.
64
65
cp ${TESTSRC}${FS}*.java ${THIS_DIR}
66
${TESTJAVA}${FS}bin${FS}javac *.java
67
68
$gcc_cmd -fPIC -shared -c -o test.o \
69
-I${TESTJAVA}${FS}include -I${TESTJAVA}${FS}include${FS}linux \
70
${TESTSRC}${FS}test.c
71
72
ld -shared -z execstack -o libtest-rwx.so test.o
73
ld -shared -z noexecstack -o libtest-rw.so test.o
74
75
76
LD_LIBRARY_PATH=${THIS_DIR}
77
echo LD_LIBRARY_PATH = ${LD_LIBRARY_PATH}
78
export LD_LIBRARY_PATH
79
80
# This should not fail.
81
echo Check testprogram. Expected to pass:
82
echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rw
83
${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rw
84
85
echo
86
echo Test changing of stack protection:
87
echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rwx
88
${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} Test test-rwx
89
JAVA_RETVAL=$?
90
91
if [ "$JAVA_RETVAL" == "0" ]
92
then
93
echo
94
echo ${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} TestMT test-rwx
95
${TESTJAVA}${FS}bin${FS}java -cp ${THIS_DIR} TestMT test-rwx
96
JAVA_RETVAL=$?
97
fi
98
99
exit $JAVA_RETVAL
100
101