]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgcc/mkmap-symver.awk
tree-optimization/95495 - use SLP_TREE_REPRESENTATIVE in assertion
[thirdparty/gcc.git] / libgcc / mkmap-symver.awk
CommitLineData
83dad10c 1# Generate an ELF symbol version map a-la Solaris and GNU ld.
8d9254fc 2# Copyright (C) 2007-2020 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
RH
20
21BEGIN {
22 state = "nm";
5a5c00af 23 sawsymbol = 0;
7c834753
ZW
24 if (leading_underscore)
25 prefix = "_";
26 else
27 prefix = "";
83dad10c
RH
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
67914693 36# so that we cannot emit them into the final version script -- Solaris
83dad10c
RH
37# complains at us if we do.
38
39state == "nm" && /^%%/ {
40 state = "ver";
41 next;
42}
43
44state == "nm" && ($1 == "U" || $2 == "U") {
45 next;
46}
47
48state == "nm" && NF == 3 {
ff473280 49 split ($3, s, "@")
7a0d2bce
TP
50 if (skip_underscore && substr(s[1], 1, 1) == "_")
51 symname = substr(s[1], 2);
52 else
53 symname = s[1];
54 def[symname] = 1;
5a5c00af 55 sawsymbol = 1;
83dad10c
RH
56 next;
57}
58
59state == "nm" {
60 next;
61}
62
63# Now we process a simplified variant of the Solaris symbol version
64# script. We have one symbol per line, no semicolons, simple markers
65# for beginning and ending each section, and %inherit markers for
fa10beec 66# describing version inheritance. A symbol may appear in more than
83dad10c 67# one symbol version, and the last seen takes effect.
7c834753
ZW
68# The magic version name '%exclude' causes all the symbols given that
69# version to be dropped from the output (unless a later version overrides).
83dad10c
RH
70
71NF == 3 && $1 == "%inherit" {
72 inherit[$2] = $3;
73 next;
74}
75
76NF == 2 && $2 == "{" {
7c834753
ZW
77 if ($1 != "%exclude")
78 libs[$1] = 1;
83dad10c
RH
79 thislib = $1;
80 next;
81}
82
83$1 == "}" {
84 thislib = "";
85 next;
86}
87
88{
7c834753 89 sym = prefix $1;
ff473280 90 symbols[sym] = 1
7c834753 91 if (thislib != "%exclude")
ff473280
L
92 ver[sym, thislib] = 1;
93 else {
94 for (l in libs)
95 ver[sym, l] = 0;
96 }
83dad10c
RH
97 next;
98}
99
100END {
5a5c00af
RH
101 if (!sawsymbol)
102 {
103 print "No symbols seen -- broken or mis-installed nm?" | "cat 1>&2";
104 exit 1;
105 }
83dad10c
RH
106 for (l in libs)
107 output(l);
108}
109
110function output(lib) {
111 if (done[lib])
112 return;
113 done[lib] = 1;
114 if (inherit[lib])
115 output(inherit[lib]);
116
bc93e287 117 empty=1
ff473280
L
118 for (sym in symbols)
119 if ((ver[sym, lib] != 0) && (sym in def))
bac015e7 120 {
bc93e287 121 if (empty)
5a5c00af 122 {
bc93e287 123 printf("%s {\n", lib);
5a5c00af 124 printf(" global:\n");
bc93e287 125 empty = 0;
5a5c00af 126 }
bac015e7 127 printf("\t%s;\n", sym);
bac015e7 128 }
83dad10c 129
bc93e287
JJ
130 if (empty)
131 {
132 for (l in libs)
133 if (inherit[l] == lib)
134 inherit[l] = inherit[lib];
135 }
136 else if (inherit[lib])
83dad10c
RH
137 printf("} %s;\n", inherit[lib]);
138 else
139 printf ("\n local:\n\t*;\n};\n");
140}