]>
Commit | Line | Data |
---|---|---|
83dad10c | 1 | # Generate a flat list of symbols to export. |
7adcbafe | 2 | # Copyright (C) 2007-2022 Free Software Foundation, Inc. |
83dad10c RH |
3 | # Contributed by Richard Henderson <rth@cygnus.com> |
4 | # | |
1322177d | 5 | # This file is part of GCC. |
83dad10c | 6 | # |
1322177d LB |
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 | |
9dcd6f09 | 9 | # Software Foundation; either version 3, or (at your option) any later |
1322177d | 10 | # version. |
83dad10c | 11 | # |
1322177d LB |
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. | |
83dad10c RH |
16 | # |
17 | # You should have received a copy of the GNU General Public License | |
9dcd6f09 NC |
18 | # along with GCC; see the file COPYING3. If not see |
19 | # <http://www.gnu.org/licenses/>. | |
83dad10c | 20 | |
d89f0ad6 AL |
21 | # Options: |
22 | # "-v leading_underscore=1" : Symbols in map need leading underscore. | |
23 | # "-v pe_dll=1" : Create .DEF file for Windows PECOFF | |
24 | # DLL link instead of map file. | |
25 | ||
83dad10c RH |
26 | BEGIN { |
27 | state = "nm"; | |
7c834753 ZW |
28 | excluding = 0; |
29 | if (leading_underscore) | |
30 | prefix = "_"; | |
31 | else | |
32 | prefix = ""; | |
83dad10c RH |
33 | } |
34 | ||
35 | # Remove comment and blank lines. | |
36 | /^ *#/ || /^ *$/ { | |
37 | next; | |
38 | } | |
39 | ||
40 | # We begin with nm input. Collect the set of symbols that are present | |
41 | # so that we can elide undefined symbols. | |
42 | ||
43 | state == "nm" && /^%%/ { | |
44 | state = "ver"; | |
45 | next; | |
46 | } | |
47 | ||
48 | state == "nm" && ($1 == "U" || $2 == "U") { | |
49 | next; | |
50 | } | |
51 | ||
52 | state == "nm" && NF == 3 { | |
53 | def[$3] = 1; | |
54 | next; | |
55 | } | |
56 | ||
57 | state == "nm" { | |
58 | next; | |
59 | } | |
60 | ||
61 | # Now we process a simplified variant of the Solaris symbol version | |
62 | # script. We have one symbol per line, no semicolons, simple markers | |
63 | # for beginning and ending each section, and %inherit markers for | |
fa10beec | 64 | # describing version inheritance. A symbol may appear in more than |
83dad10c | 65 | # one symbol version, and the last seen takes effect. |
7c834753 ZW |
66 | # The magic version name '%exclude' causes all the symbols given that |
67 | # version to be dropped from the output (unless a later version overrides). | |
83dad10c RH |
68 | |
69 | NF == 3 && $1 == "%inherit" { | |
70 | next; | |
71 | } | |
72 | ||
73 | NF == 2 && $2 == "{" { | |
7c834753 ZW |
74 | if ($1 == "%exclude") |
75 | excluding = 1; | |
83dad10c RH |
76 | next; |
77 | } | |
78 | ||
79 | $1 == "}" { | |
7c834753 | 80 | excluding = 0; |
83dad10c RH |
81 | next; |
82 | } | |
83 | ||
84 | { | |
7c834753 ZW |
85 | sym = prefix $1; |
86 | if (excluding) | |
87 | delete export[sym]; | |
88 | else | |
89 | export[sym] = 1; | |
83dad10c RH |
90 | next; |
91 | } | |
92 | ||
93 | END { | |
d89f0ad6 AL |
94 | |
95 | if (pe_dll) { | |
3cbfaf98 | 96 | print "LIBRARY " pe_dll; |
d89f0ad6 AL |
97 | print "EXPORTS"; |
98 | } | |
99 | ||
83dad10c | 100 | for (sym in export) |
5c30094f RO |
101 | if (def[sym] || (pe_dll && def["_" sym])) |
102 | print sym; | |
83dad10c | 103 | } |