]>
Commit | Line | Data |
---|---|---|
83dad10c RH |
1 | # Generate an ELF symbol version map a-la Solaris and GNU ld. |
2 | # Contributed by Richard Henderson <rth@cygnus.com> | |
3 | # | |
1322177d | 4 | # This file is part of GCC. |
83dad10c | 5 | # |
1322177d LB |
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. | |
83dad10c | 10 | # |
1322177d LB |
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. | |
83dad10c RH |
15 | # |
16 | # You should have received a copy of the GNU General Public License | |
1322177d LB |
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. | |
83dad10c RH |
20 | |
21 | BEGIN { | |
22 | state = "nm"; | |
5a5c00af | 23 | sawsymbol = 0; |
83dad10c RH |
24 | } |
25 | ||
26 | # Remove comment and blank lines. | |
27 | /^ *#/ || /^ *$/ { | |
28 | next; | |
29 | } | |
30 | ||
31 | # We begin with nm input. Collect the set of symbols that are present | |
32 | # so that we can not emit them into the final version script -- Solaris | |
33 | # complains at us if we do. | |
34 | ||
35 | state == "nm" && /^%%/ { | |
36 | state = "ver"; | |
37 | next; | |
38 | } | |
39 | ||
40 | state == "nm" && ($1 == "U" || $2 == "U") { | |
41 | next; | |
42 | } | |
43 | ||
44 | state == "nm" && NF == 3 { | |
45 | def[$3] = 1; | |
5a5c00af | 46 | sawsymbol = 1; |
83dad10c RH |
47 | next; |
48 | } | |
49 | ||
50 | state == "nm" { | |
51 | next; | |
52 | } | |
53 | ||
54 | # Now we process a simplified variant of the Solaris symbol version | |
55 | # script. We have one symbol per line, no semicolons, simple markers | |
56 | # for beginning and ending each section, and %inherit markers for | |
57 | # describing version inheritence. A symbol may appear in more than | |
58 | # one symbol version, and the last seen takes effect. | |
59 | ||
60 | NF == 3 && $1 == "%inherit" { | |
61 | inherit[$2] = $3; | |
62 | next; | |
63 | } | |
64 | ||
65 | NF == 2 && $2 == "{" { | |
66 | libs[$1] = 1; | |
67 | thislib = $1; | |
68 | next; | |
69 | } | |
70 | ||
71 | $1 == "}" { | |
72 | thislib = ""; | |
73 | next; | |
74 | } | |
75 | ||
76 | { | |
77 | ver[$1] = thislib; | |
78 | next; | |
79 | } | |
80 | ||
81 | END { | |
5a5c00af RH |
82 | if (!sawsymbol) |
83 | { | |
84 | print "No symbols seen -- broken or mis-installed nm?" | "cat 1>&2"; | |
85 | exit 1; | |
86 | } | |
83dad10c RH |
87 | for (l in libs) |
88 | output(l); | |
89 | } | |
90 | ||
91 | function output(lib) { | |
92 | if (done[lib]) | |
93 | return; | |
94 | done[lib] = 1; | |
95 | if (inherit[lib]) | |
96 | output(inherit[lib]); | |
97 | ||
bc93e287 | 98 | empty=1 |
83dad10c RH |
99 | for (sym in ver) |
100 | if ((ver[sym] == lib) && (sym in def)) | |
bac015e7 | 101 | { |
bc93e287 | 102 | if (empty) |
5a5c00af | 103 | { |
bc93e287 | 104 | printf("%s {\n", lib); |
5a5c00af | 105 | printf(" global:\n"); |
bc93e287 | 106 | empty = 0; |
5a5c00af | 107 | } |
bac015e7 AM |
108 | printf("\t%s;\n", sym); |
109 | if (dotsyms) | |
110 | printf("\t.%s;\n", sym); | |
111 | } | |
83dad10c | 112 | |
bc93e287 JJ |
113 | if (empty) |
114 | { | |
115 | for (l in libs) | |
116 | if (inherit[l] == lib) | |
117 | inherit[l] = inherit[lib]; | |
118 | } | |
119 | else if (inherit[lib]) | |
83dad10c RH |
120 | printf("} %s;\n", inherit[lib]); |
121 | else | |
122 | printf ("\n local:\n\t*;\n};\n"); | |
123 | } |