OSDN Git Service

PR c++/16276
[pf3gnuchains/gcc-fork.git] / gcc / mkmap-symver.awk
index 5ea6769..7953afc 100644 (file)
@@ -1,25 +1,26 @@
 # Generate an ELF symbol version map a-la Solaris and GNU ld.
 #      Contributed by Richard Henderson <rth@cygnus.com>
 #
-# This file is part of GNU CC.
+# This file is part of GCC.
 #
-# GNU CC is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
+# GCC is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any later
+# version.
 #
-# GNU CC is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
+# GCC is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+# License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with GNU CC; see the file COPYING.  If not, write to
-# the Free Software Foundation, 59 Temple Place - Suite 330,
-# Boston MA 02111-1307, USA.
+# along with GCC; see the file COPYING.  If not, write to the Free
+# Software Foundation, 59 Temple Place - Suite 330, Boston MA
+# 02111-1307, USA.
 
 BEGIN {
   state = "nm";
+  sawsymbol = 0;
 }
 
 # Remove comment and blank lines.
@@ -42,6 +43,7 @@ state == "nm" && ($1 == "U" || $2 == "U") {
 
 state == "nm" && NF == 3 {
   def[$3] = 1;
+  sawsymbol = 1;
   next;
 }
 
@@ -77,6 +79,11 @@ $1 == "}" {
 }
 
 END {
+  if (!sawsymbol)
+    {
+      print "No symbols seen -- broken or mis-installed nm?" | "cat 1>&2";
+      exit 1;
+    }
   for (l in libs)
     output(l);
 }
@@ -88,13 +95,28 @@ function output(lib) {
   if (inherit[lib])
     output(inherit[lib]);
 
-  printf("%s {\n", lib);
-  printf("  global:\n");
+  empty=1
   for (sym in ver)
     if ((ver[sym] == lib) && (sym in def))
-      printf("\t%s;\n", sym);
-
-  if (inherit[lib])
+      {
+       if (empty)
+         {
+           printf("%s {\n", lib);
+           printf("  global:\n");
+           empty = 0;
+         }
+       printf("\t%s;\n", sym);
+       if (dotsyms)
+         printf("\t.%s;\n", sym);
+      }
+
+  if (empty)
+    {
+      for (l in libs)
+       if (inherit[l] == lib)
+         inherit[l] = inherit[lib];
+    }
+  else if (inherit[lib])
     printf("} %s;\n", inherit[lib]);
   else
     printf ("\n  local:\n\t*;\n};\n");