]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gold/testsuite/weak_as_needed.sh
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / gold / testsuite / weak_as_needed.sh
1 #!/bin/sh
2
3 # weak_as_needed.sh -- a test case for version handling with weak symbols
4 # and --as-needed libraries.
5
6 # Copyright (C) 2018-2022 Free Software Foundation, Inc.
7 # Written by Cary Coutant <ccoutant@gmail.com>.
8
9 # This file is part of gold.
10
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 3 of the License, or
14 # (at your option) any later version.
15
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
24 # MA 02110-1301, USA.
25
26 # This test verifies that a weak reference is properly bound to
27 # an as-needed library, when it is first resolved to a symbol in
28 # a library that ends up being not needed.
29
30 # Ref: https://stackoverflow.com/questions/50751421/undefined-behavior-in-shared-lib-using-libpthread-but-not-having-it-in-elf-as-d
31
32 check()
33 {
34 if ! grep -q "$2" "$1"
35 then
36 echo "Did not find expected output in $1:"
37 echo " $2"
38 echo ""
39 echo "Actual output below:"
40 cat "$1"
41 exit 1
42 fi
43 }
44
45 check_missing()
46 {
47 if grep -q "$2" "$1"
48 then
49 echo "Found unexpected output in $1:"
50 echo " $2"
51 echo ""
52 echo "Actual output below:"
53 cat "$1"
54 exit 1
55 fi
56 }
57
58 check weak_as_needed.stdout "WEAK .* UND *bar@v2"
59 check weak_as_needed.stdout "NEEDED.*weak_as_needed_c\.so"
60 check_missing weak_as_needed.stdout "NEEDED.*weak_as_needed_b\.so"
61
62 exit 0