]>
Commit | Line | Data |
---|---|---|
0e9cab87 PE |
1 | #!/bin/sh |
2 | ||
db0d4b71 | 3 | # Copyright (C) 2002, 2003, 2009, 2010 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) | |
39 | # Sun ld doesn't record symbol versions in .dynsym entries and they | |
40 | # cannot easily be extracted from readelf --versions output, so use pvs | |
41 | # instead. Linux may have a completely different pvs from LVM2, so only | |
42 | # do this on SunOS. | |
43 | # Need to use nawk on Solaris 2 since Solaris 8/9 awk (oawk) cannot handle | |
44 | # sub. | |
45 | pvs -dsvo ${lib} | \ | |
46 | nawk '# Remove colon separator from version field, trailing semicolon. | |
47 | { | |
48 | sub (/:$/, "", $3); | |
49 | sub (/;$/, ""); | |
50 | } | |
51 | # Record base version. The [BASE] field was only added in Solaris 11, | |
52 | # so simply use the first record instead. | |
53 | NR == 1 { | |
54 | basever = $3; | |
55 | next; | |
56 | } | |
57 | # Ignore version dependencies. | |
58 | $4 ~ /\{.*\}/ { | |
59 | next; | |
60 | } | |
61 | NF == 4 { | |
62 | if ($3 == $4 || $3 == basever) | |
63 | # Emit versions or symbols bound to base versions as objects. | |
64 | printf "OBJECT:0:%s\n", $4; | |
65 | else | |
66 | # Everything else without a size field is a function. | |
67 | printf "FUNC:%s@@%s\n", $4, $3; | |
68 | next; | |
69 | } | |
70 | # Emit objects. | |
71 | NF == 5 { | |
72 | # Strip parens from object size. | |
73 | sub (/^\(/, "", $5); | |
74 | sub (/\)$/, "", $5); | |
75 | printf "OBJECT:%s:%s@@%s\n", $5, $4, $3; | |
76 | next; | |
77 | }' | sort | uniq > $tmp 2>&1 | |
78 | ;; | |
79 | *) | |
80 | # GNU binutils, somewhere after version 2.11.2, requires -W/--wide to | |
81 | # avoid default line truncation. -W is not supported and truncation did | |
82 | # not occur by default before that point. | |
83 | readelf="readelf --symbols" | |
84 | if readelf --help | grep -- --wide > /dev/null; then | |
85 | readelf="$readelf --wide" | |
86 | fi | |
87 | ${readelf} ${lib} |\ | |
88 | sed -e 's/ \[<other>: [A-Fa-f0-9]*\] //' -e '/\.dynsym/,/^$/p;d' |\ | |
89 | egrep -v ' (LOCAL|UND) ' |\ | |
90 | awk '{ if ($4 == "FUNC" || $4 == "NOTYPE") | |
91 | printf "%s:%s\n", $4, $8; | |
92 | else if ($4 == "OBJECT" || $4 == "TLS") | |
93 | printf "%s:%s:%s\n", $4, $3, $8; | |
94 | }' | sort | uniq > $tmp 2>&1 | |
95 | # else printf "Huh? What is %s?\n", $8; | |
96 | ;; | |
97 | esac | |
0e9cab87 PE |
98 | |
99 | # I think we'll be doing some more with this file, but for now, dump. | |
100 | mv $tmp $output | |
101 | ||
102 | exit 0 |