OSDN Git Service

cp:
[pf3gnuchains/gcc-fork.git] / gcc / mkmap-symver.awk
1 # Generate an ELF symbol version map a-la Solaris and GNU ld.
2 #       Contributed by Richard Henderson <rth@cygnus.com>
3 #
4 # This file is part of GCC.
5 #
6 # GCC is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU General Public License as published by the Free
8 # Software Foundation; either version 2, or (at your option) any later
9 # version.
10 #
11 # GCC is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
14 # License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with GCC; see the file COPYING.  If not, write to the Free
18 # Software Foundation, 59 Temple Place - Suite 330, Boston MA
19 # 02111-1307, USA.
20
21 BEGIN {
22   state = "nm";
23 }
24
25 # Remove comment and blank lines.
26 /^ *#/ || /^ *$/ {
27   next;
28 }
29
30 # We begin with nm input.  Collect the set of symbols that are present
31 # so that we can not emit them into the final version script -- Solaris
32 # complains at us if we do.
33
34 state == "nm" && /^%%/ {
35   state = "ver";
36   next;
37 }
38
39 state == "nm" && ($1 == "U" || $2 == "U") {
40   next;
41 }
42
43 state == "nm" && NF == 3 {
44   def[$3] = 1;
45   next;
46 }
47
48 state == "nm" {
49   next;
50 }
51
52 # Now we process a simplified variant of the Solaris symbol version
53 # script.  We have one symbol per line, no semicolons, simple markers
54 # for beginning and ending each section, and %inherit markers for
55 # describing version inheritence.  A symbol may appear in more than
56 # one symbol version, and the last seen takes effect.
57
58 NF == 3 && $1 == "%inherit" {
59   inherit[$2] = $3;
60   next;
61 }
62
63 NF == 2 && $2 == "{" {
64   libs[$1] = 1;
65   thislib = $1;
66   next;
67 }
68
69 $1 == "}" {
70   thislib = "";
71   next;
72 }
73
74 {
75   ver[$1] = thislib;
76   next;
77 }
78
79 END {
80   for (l in libs)
81     output(l);
82 }
83
84 function output(lib) {
85   if (done[lib])
86     return;
87   done[lib] = 1;
88   if (inherit[lib])
89     output(inherit[lib]);
90
91   printf("%s {\n", lib);
92   printf("  global:\n");
93   for (sym in ver)
94     if ((ver[sym] == lib) && (sym in def))
95       printf("\t%s;\n", sym);
96
97   if (inherit[lib])
98     printf("} %s;\n", inherit[lib]);
99   else
100     printf ("\n  local:\n\t*;\n};\n");
101 }