Add testcase from PR43065.
[official-gcc/constexpr.git] / libstdc++-v3 / scripts / extract_symvers
blob5a0f3659c8da50b3562e36449b3578d277f71f9d
1 #!/bin/sh
3 # Copyright (C) 2002, 2003, 2009 Free Software Foundation, Inc.
5 # This file is part of the GNU ISO C++ Library. This library is free
6 # software; you can redistribute it and/or modify it under the
7 # terms of the GNU General Public License as published by the
8 # Free Software Foundation; either version 3, or (at your option)
9 # any later version.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with this library; see the file COPYING3. If not see
18 # <http://www.gnu.org/licenses/>.
21 if test ${#} -lt 2 || test $1 = '--help'; then
22 echo "Usage: extract_symvers shared_lib output_file" 1>&2
23 exit 1
26 lib=$1
27 output=$2
29 # GNU binutils, somewhere after version 2.11.2, requires -W/--wide to avoid
30 # default line truncation. -W is not supported and truncation did not occur
31 # by default before that point.
32 readelf="readelf --symbols"
33 if readelf --help | grep -- --wide > /dev/null; then
34 readelf="$readelf --wide"
37 # This avoids weird sorting problems later.
38 LC_ALL=C
39 export LC_ALL
40 LANG=C
41 export LANG
43 tmp=extract.$$
45 ${readelf} ${lib} |\
46 sed -e 's/ \[<other>: [A-Fa-f0-9]*\] //' -e '/\.dynsym/,/^$/p;d' |\
47 egrep -v ' (LOCAL|UND) ' |\
48 awk '{ if ($4 == "FUNC" || $4 == "NOTYPE")
49 printf "%s:%s\n", $4, $8;
50 else if ($4 == "OBJECT")
51 printf "%s:%s:%s\n", $4, $3, $8;
52 }' | sort | uniq > $tmp 2>&1
53 # else printf "Huh? What is %s?\n", $8;
56 # I think we'll be doing some more with this file, but for now, dump.
57 mv $tmp $output
59 exit 0