2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libstdc++-v3 / scripts / extract_symvers
blobc7798b7e50603ddb3a402fad2ab384c856a27d85
1 #!/bin/sh
3 # Copyright (C) 2002, 2003 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 2, 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 COPYING. If not, write to the Free
18 # Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 # USA.
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.
31 if test ${#} -lt 2 || test $1 = '--help'; then
32 echo "Usage: extract_symvers shared_lib output_file" 1>&2
33 exit 1
36 lib=$1
37 output=$2
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"
47 # This avoids weird sorting problems later.
48 LC_ALL=C
49 export LC_ALL
50 LANG=C
51 export LANG
53 tmp=extract.$$
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;
64 # I think we'll be doing some more with this file, but for now, dump.
65 mv $tmp $output
67 exit 0