OSDN Git Service

libparted: gpt: rewrite even a 9-partition-entry table properly
[android-x86/external-parted.git] / scripts / extract_symvers
1 #!/bin/sh
2
3 # Copyright (C) 2002-2003, 2007, 2009-2012 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 3, 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.  If not, see <http://www.gnu.org/licenses/>.
18 #
19 # As a special exception, you may use this file as part of a free software
20 # library without restriction.  Specifically, if other files instantiate
21 # templates or use macros or inline functions from this file, or you compile
22 # this file and link it with other files to produce an executable, this
23 # file does not by itself cause the resulting executable to be covered by
24 # the GNU General Public License.  This exception does not however
25 # invalidate any other reasons why the executable file might be covered by
26 # the GNU General Public License.
27
28
29 if test ${#} -lt 2 || test $1 = '--help'; then
30   echo "Usage:  extract_symvers  shared_lib output_file" 1>&2
31   exit 1
32 fi
33
34 lib=$1
35 output=$2
36
37 # GNU binutils, somewhere after version 2.11.2, requires -W/--wide to avoid
38 # default line truncation.  -W is not supported and truncation did not occur
39 # by default before that point.
40 readelf="readelf --symbols"
41 if readelf --help | grep -- --wide > /dev/null; then
42     readelf="$readelf --wide"
43 fi
44
45 # This avoids weird sorting problems later.
46 LC_ALL=C
47 export LC_ALL
48 LANG=C
49 export LANG
50
51 tmp=extract.$$
52
53 ${readelf} ${lib} | sed '/\.dynsym/,/^$/p;d' | egrep -v ' (LOCAL|UND) ' |\
54 awk '{ if ($4 == "FUNC" || $4 == "NOTYPE")
55          printf "%s:%s\n", $4, $8;
56        else if ($4 == "OBJECT")
57          printf "%s:%s:%s\n", $4, $3, $8;
58      }' | sort | uniq > $tmp 2>&1
59 #       else printf "Huh?  What is %s?\n", $8;
60
61
62 # I think we'll be doing some more with this file, but for now, dump.
63 mv $tmp $output
64
65 exit 0