1 # Generate an ELF symbol version map a-la Solaris and GNU ld.
2 # Copyright (C) 2007-2022 Free Software Foundation, Inc.
3 # Contributed by Richard Henderson <rth@cygnus.com>
5 # This file is part of GCC.
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
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.
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/>.
24 if (leading_underscore
)
30 # Remove comment and blank lines.
35 # We begin with nm input. Collect the set of symbols that are present
36 # so that we cannot emit them into the final version script -- Solaris
37 # complains at us if we do.
39 state ==
"nm" && /^
%%/ {
44 state ==
"nm" && ($
1 ==
"U" || $
2 ==
"U") {
48 state ==
"nm" && NF ==
3 {
50 if (skip_underscore
&& substr(s
[1], 1, 1) ==
"_")
51 symname =
substr(s
[1], 2);
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
66 # describing version inheritance. A symbol may appear in more than
67 # one symbol version, and the last seen takes effect.
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).
71 NF ==
3 && $
1 ==
"%inherit" {
76 NF ==
2 && $
2 ==
"{" {
91 if (thislib
!= "%exclude")
92 ver
[sym
, thislib
] =
1;
103 print "No symbols seen -- broken or mis-installed nm?" | "cat 1>&2";
110 function output
(lib
) {
115 output
(inherit
[lib
]);
119 if ((ver
[sym
, lib
] != 0) && (sym in def
))
123 printf("%s {\n", lib
);
124 printf(" global:\n");
127 printf("\t%s;\n", sym
);
133 if (inherit
[l
] == lib
)
134 inherit
[l
] = inherit
[lib
];
136 else if (inherit
[lib
])
137 printf("} %s;\n", inherit
[lib
]);
139 printf ("\n local:\n\t*;\n};\n");