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