3 # weak_as_needed.sh -- a test case for version handling with weak symbols
4 # and --as-needed libraries.
6 # Copyright (C) 2018-2019 Free Software Foundation, Inc.
7 # Written by Cary Coutant <ccoutant@gmail.com>.
9 # This file is part of gold.
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.
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.
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,
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.
30 # Ref: https://stackoverflow.com/questions/50751421/undefined-behavior-in-shared-lib-using-libpthread-but-not-having-it-in-elf-as-d
34 if ! grep -q "$2" "$1"
36 echo "Did not find expected output in $1:"
39 echo "Actual output below:"
49 echo "Found unexpected output in $1:"
52 echo "Actual output below:"
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"