OSDN Git Service

2005-05-12 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / scripts / extract_symvers
1 #!/bin/sh
2
3 # Copyright (C) 2002, 2003 Free Software Foundation, Inc.
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
8 # Free Software Foundation; either version 2, or (at your option)
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
17 # with this library; see the file COPYING.  If not, write to the Free
18 # Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 # USA.
20 #
21 # As a special exception, you may use this file as part of a free software
22 # library without restriction.  Specifically, if other files instantiate
23 # templates or use macros or inline functions from this file, or you compile
24 # this file and link it with other files to produce an executable, this
25 # file does not by itself cause the resulting executable to be covered by
26 # the GNU General Public License.  This exception does not however
27 # invalidate any other reasons why the executable file might be covered by
28 # the GNU General Public License.
29
30
31 if test ${#} -lt 2 || test $1 = '--help'; then
32   echo "Usage:  extract_symvers  shared_lib output_file" 1>&2
33   exit 1
34 fi
35
36 lib=$1
37 output=$2
38
39 # GNU binutils, somewhere after version 2.11.2, requires -W/--wide to avoid
40 # default line truncation.  -W is not supported and truncation did not occur
41 # by default before that point.
42 readelf="readelf --symbols"
43 if readelf --help | grep -- --wide > /dev/null; then
44     readelf="$readelf --wide"
45 fi
46
47 # This avoids weird sorting problems later.
48 LC_ALL=C
49 export LC_ALL
50 LANG=C
51 export LANG
52
53 tmp=extract.$$
54
55 ${readelf} ${lib} | sed '/\.dynsym/,/^$/p;d' | egrep -v ' (LOCAL|UND) ' |\
56 awk '{ if ($4 == "FUNC" || $4 == "NOTYPE")
57          printf "%s:%s\n", $4, $8;
58        else if ($4 == "OBJECT")
59          printf "%s:%s:%s\n", $4, $3, $8;
60      }' | sort | uniq > $tmp 2>&1
61 #       else printf "Huh?  What is %s?\n", $8;
62
63
64 # I think we'll be doing some more with this file, but for now, dump.
65 mv $tmp $output
66
67 exit 0