]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/mkmap-flat.awk
377731a4e7d7772ba4372e4a7af5122d46ff00af
[thirdparty/gcc.git] / gcc / mkmap-flat.awk
1 # Generate a flat list of symbols to export.
2 # Copyright (C) 2007, 2008 Free Software Foundation, Inc.
3 # Contributed by Richard Henderson <rth@cygnus.com>
4 #
5 # This file is part of GCC.
6 #
7 # GCC is free software; you can redistribute it and/or modify it under
8 # the terms of the GNU General Public License as published by the Free
9 # Software Foundation; either version 3, or (at your option) any later
10 # version.
11 #
12 # GCC is distributed in the hope that it will be useful, but WITHOUT
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 # License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with GCC; see the file COPYING3. If not see
19 # <http://www.gnu.org/licenses/>.
20
21 BEGIN {
22 state = "nm";
23 excluding = 0;
24 if (leading_underscore)
25 prefix = "_";
26 else
27 prefix = "";
28 }
29
30 # Remove comment and blank lines.
31 /^ *#/ || /^ *$/ {
32 next;
33 }
34
35 # We begin with nm input. Collect the set of symbols that are present
36 # so that we can elide undefined symbols.
37
38 state == "nm" && /^%%/ {
39 state = "ver";
40 next;
41 }
42
43 state == "nm" && ($1 == "U" || $2 == "U") {
44 next;
45 }
46
47 state == "nm" && NF == 3 {
48 def[$3] = 1;
49 next;
50 }
51
52 state == "nm" {
53 next;
54 }
55
56 # Now we process a simplified variant of the Solaris symbol version
57 # script. We have one symbol per line, no semicolons, simple markers
58 # for beginning and ending each section, and %inherit markers for
59 # describing version inheritance. A symbol may appear in more than
60 # one symbol version, and the last seen takes effect.
61 # The magic version name '%exclude' causes all the symbols given that
62 # version to be dropped from the output (unless a later version overrides).
63
64 NF == 3 && $1 == "%inherit" {
65 next;
66 }
67
68 NF == 2 && $2 == "{" {
69 if ($1 == "%exclude")
70 excluding = 1;
71 next;
72 }
73
74 $1 == "}" {
75 excluding = 0;
76 next;
77 }
78
79 {
80 sym = prefix $1;
81 if (excluding)
82 delete export[sym];
83 else
84 export[sym] = 1;
85 next;
86 }
87
88 END {
89 for (sym in export)
90 if (def[sym])
91 print sym;
92 }