]>
Commit | Line | Data |
---|---|---|
0e9cab87 PE |
1 | #!/bin/sh |
2 | ||
a5544970 | 3 | # Copyright (C) 2002-2019 Free Software Foundation, Inc. |
0e9cab87 PE |
4 | # |
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 | |
748086b7 | 8 | # Free Software Foundation; either version 3, or (at your option) |
0e9cab87 PE |
9 | # any later version. |
10 | # | |
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. | |
15 | # | |
16 | # You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
17 | # with this library; see the file COPYING3. If not see |
18 | # <http://www.gnu.org/licenses/>. | |
0e9cab87 PE |
19 | |
20 | ||
21 | if test ${#} -lt 2 || test $1 = '--help'; then | |
22 | echo "Usage: extract_symvers shared_lib output_file" 1>&2 | |
23 | exit 1 | |
24 | fi | |
25 | ||
26 | lib=$1 | |
27 | output=$2 | |
28 | ||
0e9cab87 | 29 | # This avoids weird sorting problems later. |
58579a27 PE |
30 | LC_ALL=C |
31 | export LC_ALL | |
32 | LANG=C | |
33 | export LANG | |
0e9cab87 PE |
34 | |
35 | tmp=extract.$$ | |
36 | ||
db0d4b71 RO |
37 | case `uname -s` in |
38 | SunOS) | |
e1208a57 RO |
39 | # Ensure that output on Solaris 2 matches readelf below without requiring |
40 | # GNU binutils to be installed. This requires a combination of pvs and | |
41 | # elfdump, which is easier handled in a perl script. | |
42 | perl @glibcxx_srcdir@/scripts/extract_symvers.pl ${lib} > $tmp 2>&1 | |
db0d4b71 RO |
43 | ;; |
44 | *) | |
45 | # GNU binutils, somewhere after version 2.11.2, requires -W/--wide to | |
46 | # avoid default line truncation. -W is not supported and truncation did | |
47 | # not occur by default before that point. | |
48 | readelf="readelf --symbols" | |
49 | if readelf --help | grep -- --wide > /dev/null; then | |
50 | readelf="$readelf --wide" | |
51 | fi | |
9ac0b841 RO |
52 | # Omit _DYNAMIC etc. for consistency with extract_symvers.pl, only |
53 | # present on Solaris. | |
db0d4b71 RO |
54 | ${readelf} ${lib} |\ |
55 | sed -e 's/ \[<other>: [A-Fa-f0-9]*\] //' -e '/\.dynsym/,/^$/p;d' |\ | |
b54214fe | 56 | sed -e 's/ \[<localentry>: [0-9]*\] //' |\ |
db0d4b71 | 57 | egrep -v ' (LOCAL|UND) ' |\ |
9ac0b841 | 58 | egrep -v ' (_DYNAMIC|_GLOBAL_OFFSET_TABLE_|_PROCEDURE_LINKAGE_TABLE_|_edata|_end|_etext)$' |\ |
dd27d2fa SB |
59 | sed -e 's/ <processor specific>: / <processor_specific>:_/g' |\ |
60 | sed -e 's/ <OS specific>: / <OS_specific>:_/g' |\ | |
61 | sed -e 's/ <unknown>: / <unknown>:_/g' |\ | |
db0d4b71 RO |
62 | awk '{ if ($4 == "FUNC" || $4 == "NOTYPE") |
63 | printf "%s:%s\n", $4, $8; | |
64 | else if ($4 == "OBJECT" || $4 == "TLS") | |
65 | printf "%s:%s:%s\n", $4, $3, $8; | |
66 | }' | sort | uniq > $tmp 2>&1 | |
67 | # else printf "Huh? What is %s?\n", $8; | |
68 | ;; | |
69 | esac | |
0e9cab87 PE |
70 | |
71 | # I think we'll be doing some more with this file, but for now, dump. | |
72 | mv $tmp $output | |
73 | ||
74 | exit 0 |