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