xref: /openbsd/gnu/usr.bin/gcc/gcc/mkmap-flat.awk (revision c87b03e5)
1*c87b03e5Sespie# Generate a flat list of symbols to export.
2*c87b03e5Sespie#	Contributed by Richard Henderson <rth@cygnus.com>
3*c87b03e5Sespie#
4*c87b03e5Sespie# This file is part of GCC.
5*c87b03e5Sespie#
6*c87b03e5Sespie# GCC is free software; you can redistribute it and/or modify it under
7*c87b03e5Sespie# the terms of the GNU General Public License as published by the Free
8*c87b03e5Sespie# Software Foundation; either version 2, or (at your option) any later
9*c87b03e5Sespie# version.
10*c87b03e5Sespie#
11*c87b03e5Sespie# GCC is distributed in the hope that it will be useful, but WITHOUT
12*c87b03e5Sespie# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13*c87b03e5Sespie# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
14*c87b03e5Sespie# License for more details.
15*c87b03e5Sespie#
16*c87b03e5Sespie# You should have received a copy of the GNU General Public License
17*c87b03e5Sespie# along with GCC; see the file COPYING.  If not, write to the Free
18*c87b03e5Sespie# Software Foundation, 59 Temple Place - Suite 330, Boston MA
19*c87b03e5Sespie# 02111-1307, USA.
20*c87b03e5Sespie
21*c87b03e5SespieBEGIN {
22*c87b03e5Sespie  state = "nm";
23*c87b03e5Sespie}
24*c87b03e5Sespie
25*c87b03e5Sespie# Remove comment and blank lines.
26*c87b03e5Sespie/^ *#/ || /^ *$/ {
27*c87b03e5Sespie  next;
28*c87b03e5Sespie}
29*c87b03e5Sespie
30*c87b03e5Sespie# We begin with nm input.  Collect the set of symbols that are present
31*c87b03e5Sespie# so that we can elide undefined symbols.
32*c87b03e5Sespie
33*c87b03e5Sespiestate == "nm" && /^%%/ {
34*c87b03e5Sespie  state = "ver";
35*c87b03e5Sespie  next;
36*c87b03e5Sespie}
37*c87b03e5Sespie
38*c87b03e5Sespiestate == "nm" && ($1 == "U" || $2 == "U") {
39*c87b03e5Sespie  next;
40*c87b03e5Sespie}
41*c87b03e5Sespie
42*c87b03e5Sespiestate == "nm" && NF == 3 {
43*c87b03e5Sespie  def[$3] = 1;
44*c87b03e5Sespie  next;
45*c87b03e5Sespie}
46*c87b03e5Sespie
47*c87b03e5Sespiestate == "nm" {
48*c87b03e5Sespie  next;
49*c87b03e5Sespie}
50*c87b03e5Sespie
51*c87b03e5Sespie# Now we process a simplified variant of the Solaris symbol version
52*c87b03e5Sespie# script.  We have one symbol per line, no semicolons, simple markers
53*c87b03e5Sespie# for beginning and ending each section, and %inherit markers for
54*c87b03e5Sespie# describing version inheritence.  A symbol may appear in more than
55*c87b03e5Sespie# one symbol version, and the last seen takes effect.
56*c87b03e5Sespie
57*c87b03e5SespieNF == 3 && $1 == "%inherit" {
58*c87b03e5Sespie  next;
59*c87b03e5Sespie}
60*c87b03e5Sespie
61*c87b03e5SespieNF == 2 && $2 == "{" {
62*c87b03e5Sespie  next;
63*c87b03e5Sespie}
64*c87b03e5Sespie
65*c87b03e5Sespie$1 == "}" {
66*c87b03e5Sespie  next;
67*c87b03e5Sespie}
68*c87b03e5Sespie
69*c87b03e5Sespie{
70*c87b03e5Sespie  export[$1] = 1;
71*c87b03e5Sespie  next;
72*c87b03e5Sespie}
73*c87b03e5Sespie
74*c87b03e5SespieEND {
75*c87b03e5Sespie  for (sym in export)
76*c87b03e5Sespie    if (def[sym])
77*c87b03e5Sespie      print sym;
78*c87b03e5Sespie}
79