mkmap-flat.awk revision 90075
12490Sjkh# Generate a flat list of symbols to export.
251862Sdcs#	Contributed by Richard Henderson <rth@cygnus.com>
32490Sjkh#
418464Sbde# This file is part of GCC.
52490Sjkh#
62490Sjkh# GCC is free software; you can redistribute it and/or modify it under
72490Sjkh# the terms of the GNU General Public License as published by the Free
852571Sjkh# Software Foundation; either version 2, or (at your option) any later
952571Sjkh# version.
1052571Sjkh#
1152571Sjkh# GCC is distributed in the hope that it will be useful, but WITHOUT
1252571Sjkh# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1340478Sbde# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
1440478Sbde# License for more details.
152490Sjkh#
1640478Sbde# You should have received a copy of the GNU General Public License
1718464Sbde# along with GCC; see the file COPYING.  If not, write to the Free
182490Sjkh# Software Foundation, 59 Temple Place - Suite 330, Boston MA
192490Sjkh# 02111-1307, USA.
202490Sjkh
2140478SbdeBEGIN {
222490Sjkh  state = "nm";
232490Sjkh}
242490Sjkh
252490Sjkh# Remove comment and blank lines.
2640478Sbde/^ *#/ || /^ *$/ {
2715930Sache  next;
2840478Sbde}
2922449Swosch
3040478Sbde# We begin with nm input.  Collect the set of symbols that are present
3122449Swosch# so that we can elide undefined symbols.
3222449Swosch
332490Sjkhstate == "nm" && /^%%/ {
3440478Sbde  state = "ver";
3540478Sbde  next;
3652888Sjoerg}
3752586Sdcs
3840478Sbdestate == "nm" && ($1 == "U" || $2 == "U") {
392490Sjkh  next;
4039479Sphk}
4151909Sdcs
4252586Sdcsstate == "nm" && NF == 3 {
432490Sjkh  def[$3] = 1;
4439479Sphk  next;
4555059Smarcel}
462490Sjkh
472490Sjkhstate == "nm" {
48  next;
49}
50
51# Now we process a simplified variant of the Solaris symbol version
52# script.  We have one symbol per line, no semicolons, simple markers
53# for beginning and ending each section, and %inherit markers for
54# describing version inheritence.  A symbol may appear in more than
55# one symbol version, and the last seen takes effect.
56
57NF == 3 && $1 == "%inherit" {
58  next;
59}
60
61NF == 2 && $2 == "{" {
62  next;
63}
64
65$1 == "}" {
66  next;
67}
68
69{
70  export[$1] = 1;
71  next;
72}
73
74END {
75  for (sym in export)
76    if (def[sym])
77      print sym;
78}
79