Print this page
10366 ld(1) should support GNU-style linker sets
10367 ld(1) tests should be a real test suite
10368 want an ld(1) regression test for i386 LD tls transition (10267)
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/sgs/test/ld/assert-deflib/test-deflib.sh
+++ new/usr/src/test/elf-tests/tests/assert-deflib/test-deflib.sh
1 1 #!/bin/bash
2 2 #
3 3 # This file and its contents are supplied under the terms of the
4 4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 5 # You may only use this file in accordance with the terms of version
6 6 # 1.0 of the CDDL.
7 7 #
8 8 # A full copy of the text of the CDDL should have accompanied this
9 9 # source. A copy of the CDDL is also available via the Internet at
10 10 # http://www.illumos.org/license/CDDL.
11 11 #
12 12
13 13 #
14 14 # Copyright (c) 2012, Joyent, Inc.
15 15 #
16 16
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 #
18 18 # This test validates that the -zassert-deflib option of ld(1) works correctly.
19 19 # It requires that some cc is in your path and that you have passed in the path
20 20 # to the proto area with the new version of libld.so.4. One thing that we have
21 21 # to do is be careful with using LD_LIBRARY_PATH. Setting LD_LIBRARY_PATH does
22 22 # not change the default search path so we want to make sure that we use a
23 23 # different ISA (e.g. 32-bit vs 64-bit) from the binary we're generating.
24 24 #
25 25 unalias -a
26 26
27 +if [[ -z $ELF_TESTS ]]; then
28 + print -u2 "Don't know where the test data is rooted";
29 + exit 1;
30 +fi
31 +
27 32 sh_path=
28 33 sh_lib="lib"
29 34 sh_lib64="$sh_lib/64"
30 35 sh_soname="libld.so.4"
31 -sh_cc="cc"
36 +sh_cc="gcc"
32 37 sh_cflags="-m32"
33 -sh_file="link.c"
38 +sh_file="${ELF_TESTS}/tests/assert-deflib/link.c"
34 39 sh_arg0=$(basename $0)
35 40
36 41 function fatal
37 42 {
38 43 local msg="$*"
39 44 [[ -z "$msg" ]] && msg="failed"
40 45 echo "$sh_arg0: $msg" >&2
41 46 exit 1
42 47 }
43 48
44 49
45 50 #
46 51 # Validate that everything we need is in our path. That includes having cc
47 52 # and the proto area libld.
48 53 #
49 54 function validate
50 55 {
51 56 [[ -f $sh_path/$sh_lib/$sh_soname ]] || fatal "missing 32-bit $sh_soname"
52 57 [[ -f $sh_path/$sh_lib64/$sh_soname ]] ||
53 58 fatal "missing 64-bit $sh_soname"
54 59 which $sh_cc >/dev/null || fatal "cc not in path"
55 60 }
56 61
57 62 #
58 63 # $1 is a series of flags to append
59 64 # $2 is expected exit status
60 65 # $3 is pre-test message
61 66 # $4 is the failure message
62 67 #
63 68 function run
64 69 {
65 70 local ret
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
66 71
67 72 echo $3
68 73 LD_LIBRARY_PATH_64="$sh_path/$sh_lib64" $sh_cc $sh_cflags $sh_file $1
69 74 if [[ $? -eq $2 ]]; then
70 75 printf "success\n\n"
71 76 else
72 77 fatal $4
73 78 fi
74 79 }
75 80
76 -sh_path=$1
77 -[[ -z "$1" ]] && fatal "<proto root>"
81 +sh_path=${1:-/}
78 82 validate
79 83
80 84 run "-Wl,-zassert-deflib" 0 \
81 85 "Testing basic compilation succeeds with warnings..." \
82 86 "failed to compile with warnings"
83 87
84 88 run "-Wl,-zassert-deflib -Wl,-zfatal-warnings" 1 \
85 89 "Testing basic compilation fails if warning are fatal..." \
86 90 "linking succeeeded, expected failure"
87 91
88 92 run "-Wl,-zassert-deflib=libc.so -Wl,-zfatal-warnings" 0 \
89 93 "Testing basic exception with fatal warnings..." \
90 94 "linking failed despite exception"
91 95
92 96 run "-Wl,-zassert-deflib=libc.so -Wl,-zfatal-warnings" 0 \
93 97 "Testing basic exception with fatal warnings..." \
94 98 "linking failed despite exception"
95 99
96 100
97 101 run "-Wl,-zassert-deflib=lib.so -Wl,-zfatal-warnings" 1 \
98 102 "Testing invalid library name..." \
99 103 "ld should not allow invalid library name"
100 104
101 105 run "-Wl,-zassert-deflib=libf -Wl,-zfatal-warnings" 1 \
102 106 "Testing invalid library name..." \
103 107 "ld should not allow invalid library name"
104 108
105 109 run "-Wl,-zassert-deflib=libf.s -Wl,-zfatal-warnings" 1 \
106 110 "Testing invalid library name..." \
107 111 "ld should not allow invalid library name"
108 112
109 113 run "-Wl,-zassert-deflib=libc.so -Wl,-zfatal-warnings -lelf" 1 \
110 114 "Errors even if one library is under exception path..." \
111 115 "one exception shouldn't stop another"
112 116
113 117 args="-Wl,-zassert-deflib=libc.so -Wl,-zassert-deflib=libelf.so"
114 118 args="$args -Wl,-zfatal-warnings -lelf"
115 119
116 120 run "$args" 0 \
117 121 "Multiple exceptions work..." \
118 122 "multiple exceptions don't work"
119 123
120 124 args="-Wl,-zassert-deflib=libc.so -Wl,-zassert-deflib=libelfe.so"
121 125 args="$args -Wl,-zfatal-warnings -lelf"
122 126
123 127 run "$args" 1 \
124 128 "Exceptions only catch the specific library" \
125 129 "exceptions caught the wrong library"
126 130
127 131 args="-Wl,-zassert-deflib=libc.so -Wl,-zassert-deflib=libel.so"
128 132 args="$args -Wl,-zfatal-warnings -lelf"
129 133
130 134 run "$args" 1 \
131 135 "Exceptions only catch the specific library" \
132 136 "exceptions caught the wrong library"
133 137
134 138 echo "Tests passed."
135 139 exit 0
↓ open down ↓ |
48 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX