mkmap-flat.awk revision 259065
1130368Smlaier# Generate a flat list of symbols to export. 2130365Smlaier# Contributed by Richard Henderson <rth@cygnus.com> 3130365Smlaier# 4130365Smlaier# This file is part of GCC. 5130365Smlaier# 6130365Smlaier# GCC is free software; you can redistribute it and/or modify it under 7130365Smlaier# the terms of the GNU General Public License as published by the Free 8130365Smlaier# Software Foundation; either version 2, or (at your option) any later 9130365Smlaier# version. 10130365Smlaier# 11130365Smlaier# GCC is distributed in the hope that it will be useful, but WITHOUT 12130365Smlaier# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13130365Smlaier# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 14130365Smlaier# License for more details. 15130365Smlaier# 16130365Smlaier# You should have received a copy of the GNU General Public License 17130365Smlaier# along with GCC; see the file COPYING. If not, write to the Free 18130365Smlaier# Software Foundation, 51 Franklin Street, Fifth Floor, Boston MA 19130365Smlaier# 02110-1301, USA. 20130365Smlaier 21130365SmlaierBEGIN { 22130365Smlaier state = "nm"; 23130365Smlaier excluding = 0; 24130365Smlaier if (leading_underscore) 25130365Smlaier prefix = "_"; 26130365Smlaier else 27130365Smlaier prefix = ""; 28130365Smlaier} 29130365Smlaier 30130365Smlaier# Remove comment and blank lines. 31130365Smlaier/^ *#/ || /^ *$/ { 32130365Smlaier next; 33130365Smlaier} 34130365Smlaier 35130365Smlaier# We begin with nm input. Collect the set of symbols that are present 36130365Smlaier# so that we can elide undefined symbols. 37130365Smlaier 38130365Smlaierstate == "nm" && /^%%/ { 39130365Smlaier state = "ver"; 40130365Smlaier next; 41130365Smlaier} 42130365Smlaier 43130365Smlaierstate == "nm" && ($1 == "U" || $2 == "U") { 44130365Smlaier next; 45130365Smlaier} 46130365Smlaier 47130365Smlaierstate == "nm" && NF == 3 { 48130365Smlaier def[$3] = 1; 49130365Smlaier next; 50130365Smlaier} 51130365Smlaier 52130365Smlaierstate == "nm" { 53130365Smlaier next; 54130365Smlaier} 55130365Smlaier 56130365Smlaier# Now we process a simplified variant of the Solaris symbol version 57130365Smlaier# script. We have one symbol per line, no semicolons, simple markers 58130365Smlaier# for beginning and ending each section, and %inherit markers for 59130365Smlaier# describing version inheritence. A symbol may appear in more than 60130365Smlaier# one symbol version, and the last seen takes effect. 61130365Smlaier# The magic version name '%exclude' causes all the symbols given that 62130365Smlaier# version to be dropped from the output (unless a later version overrides). 63130365Smlaier 64130365SmlaierNF == 3 && $1 == "%inherit" { 65130365Smlaier next; 66130365Smlaier} 67130365Smlaier 68130365SmlaierNF == 2 && $2 == "{" { 69130365Smlaier if ($1 == "%exclude") 70130365Smlaier excluding = 1; 71130365Smlaier next; 72130365Smlaier} 73130365Smlaier 74130365Smlaier$1 == "}" { 75130365Smlaier excluding = 0; 76130365Smlaier next; 77130365Smlaier} 78130365Smlaier 79130365Smlaier{ 80130365Smlaier sym = prefix $1; 81130365Smlaier if (excluding) 82130365Smlaier delete export[sym]; 83130365Smlaier else 84130365Smlaier export[sym] = 1; 85130365Smlaier next; 86130365Smlaier} 87130365Smlaier 88130365SmlaierEND { 89130365Smlaier for (sym in export) 90130365Smlaier if (def[sym]) 91130365Smlaier print sym; 92130365Smlaier} 93130365Smlaier