OSDN Git Service

e7b6645900b1aec6c8fd1bef1b4bdc9a7e286e44
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / scripts / extract_symvers
1 #!/bin/sh
2
3 # Copyright (C) 2002 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 export LC_ALL=C
49
50 tmp=extract.$$
51
52 ${readelf} ${lib} | sed '/\.dynsym/,/^$/p;d' | egrep -v ' (LOCAL|UND) ' |\
53 awk '{ if ($4 == "FUNC" || $4 == "NOTYPE")
54          printf "%s:%s\n", $4, $8;
55        else if ($4 == "OBJECT")
56          printf "%s:%s:%s\n", $4, $3, $8;
57      }' | sort | uniq > $tmp 2>&1
58 #       else printf "Huh?  What is %s?\n", $8;
59
60
61 # I think we'll be doing some more with this file, but for now, dump.
62 mv $tmp $output
63
64 exit 0