Makefile.in (NM_FOR_TARGET): New.
authorRichard Henderson <rth@cygnus.com>
Fri, 6 Oct 2000 05:46:02 +0000 (22:46 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Fri, 6 Oct 2000 05:46:02 +0000 (22:46 -0700)
        * Makefile.in (NM_FOR_TARGET): New.
        (libgcc.mk): Pass SHLIB_MKMAP, SHLIB_MAPFILES.
        (libgcc.a, stmp-multilib): Pass NM_FOR_TARGET.
        * mklibgcc.in: If SHLIB_MKMAP, build libgcc.map.  Depend the
        shared library build on that and EXTRA_MULTILIB_PARTS.
        * mkmap-flat.awk: New file.
        * mkmap-symver.awk: New file.
        * libgcc-std.ver: New file.
        * config/libgcc-glibc.ver: New file.
        * config/ia64/libgcc-ia64.ver: New file.
        * config/t-linux (SHLIB_MKMAP, SHLIB_MAPFILES): New.
        (SHLIB_LINK): Add --version-script.
        * config/ia64/t-ia64 (SHLIB_MAPFILES): Add libgcc-ia64.ver.
        * config/mips/t-iris6 (SHLIB_MKMAP, SHLIB_MAPFILES): New.
        * config/sparc/t-sol2 (SHLIB_MKMAP, SHLIB_MAPFILES): New.
        (SHLIB_LINK): Add -M.

From-SVN: r36746

12 files changed:
gcc/ChangeLog
gcc/Makefile.in
gcc/config/ia64/libgcc-ia64.ver [new file with mode: 0644]
gcc/config/ia64/t-ia64
gcc/config/libgcc-glibc.ver [new file with mode: 0644]
gcc/config/mips/t-iris6
gcc/config/sparc/t-sol2
gcc/config/t-linux
gcc/libgcc-std.ver [new file with mode: 0644]
gcc/mklibgcc.in
gcc/mkmap-flat.awk [new file with mode: 0644]
gcc/mkmap-symver.awk [new file with mode: 0644]

index c1bb180..88c6120 100644 (file)
@@ -1,5 +1,24 @@
 2000-10-05  Richard Henderson  <rth@cygnus.com>
 
+       * Makefile.in (NM_FOR_TARGET): New.
+       (libgcc.mk): Pass SHLIB_MKMAP, SHLIB_MAPFILES.
+       (libgcc.a, stmp-multilib): Pass NM_FOR_TARGET.
+       * mklibgcc.in: If SHLIB_MKMAP, build libgcc.map.  Depend the
+       shared library build on that and EXTRA_MULTILIB_PARTS.
+       * mkmap-flat.awk: New file.
+       * mkmap-symver.awk: New file.
+       * libgcc-std.ver: New file.
+       * config/libgcc-glibc.ver: New file.
+       * config/ia64/libgcc-ia64.ver: New file.
+       * config/t-linux (SHLIB_MKMAP, SHLIB_MAPFILES): New.
+       (SHLIB_LINK): Add --version-script.
+       * config/ia64/t-ia64 (SHLIB_MAPFILES): Add libgcc-ia64.ver.
+       * config/mips/t-iris6 (SHLIB_MKMAP, SHLIB_MAPFILES): New.
+       * config/sparc/t-sol2 (SHLIB_MKMAP, SHLIB_MAPFILES): New.
+       (SHLIB_LINK): Add -M.
+
+2000-10-05  Richard Henderson  <rth@cygnus.com>
+
        * Makefile.in (LIB2FUNCS): Add _clz.
        * libgcc2.c (__ffsdi2): Use count_trailing_zeros.
        (__clz_tab): Put in its own unit, non-static.
index 669a8ff..4fa487c 100644 (file)
@@ -221,6 +221,16 @@ RANLIB_TEST_FOR_TARGET = \
   [ -f $(RANLIB_FOR_TARGET) ] \
   || ( [ "$(host_canonical)" = "$(target)" ] \
        && [ -f /usr/bin/ranlib -o -f /bin/ranlib ] )
+NM_FOR_TARGET = ` \
+  if [ -f $(objdir)/../binutils/nm ] ; then \
+    echo $(objdir)/../binutils/nm ; \
+  else \
+    if [ "$(host_canonical)" = "$(target)" ] ; then \
+      echo nm; \
+    else \
+       t='$(program_transform_cross_name)'; echo nm | sed -e $$t ; \
+    fi; \
+  fi`
 
 # Dir to search for system headers.  Overridden by cross-make.
 SYSTEM_HEADER_DIR = /usr/include
@@ -972,6 +982,8 @@ libgcc.mk: config.status Makefile mklibgcc $(LIB2ADD) xgcc$(exeext)
        SHLIB_LINK='$(SHLIB_LINK)' \
        SHLIB_LIBS='$(SHLIB_LIBS)' \
        SHLIB_MULTILIB='$(SHLIB_MULTILIB)' \
+       SHLIB_MKMAP='$(SHLIB_MKMAP)' \
+       SHLIB_MAPFILES='$(SHLIB_MAPFILES)' \
          $(SHELL) mklibgcc > tmp-libgcc.mk
        mv tmp-libgcc.mk libgcc.mk
 
@@ -991,6 +1003,7 @@ libgcc.a: $(LIBGCC_DEPS)
          CFLAGS="$(CFLAGS) $(WARN_CFLAGS)" \
          RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)" \
          RANLIB_TEST_FOR_TARGET="$(RANLIB_TEST_FOR_TARGET)" \
+         NM_FOR_TARGET="$(NM_FOR_TARGET)" AWK="$(AWK)" \
          LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)" \
          INCLUDES="$(INCLUDES)" MAYBE_USE_COLLECT2="$(MAYBE_USE_COLLECT2)" \
          CONFIG_H="$(CONFIG_H)" MACHMODE_H="$(MACHMODE_H)" \
@@ -1023,6 +1036,7 @@ stmp-multilib: $(LIBGCC_DEPS)
          CFLAGS="$(CFLAGS) $(WARN_CFLAGS)" \
          RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)" \
          RANLIB_TEST_FOR_TARGET="$(RANLIB_TEST_FOR_TARGET)" \
+         NM_FOR_TARGET="$(NM_FOR_TARGET)" AWK="$(AWK)" \
          LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)" \
          INCLUDES="$(INCLUDES)" MAYBE_USE_COLLECT2="$(MAYBE_USE_COLLECT2)" \
          CONFIG_H="$(CONFIG_H)" MACHMODE_H="$(MACHMODE_H)" \
diff --git a/gcc/config/ia64/libgcc-ia64.ver b/gcc/config/ia64/libgcc-ia64.ver
new file mode 100644 (file)
index 0000000..a03799f
--- /dev/null
@@ -0,0 +1,8 @@
+GCC_3.0 {
+  # IA-64 symbols
+  __ia64_nonlocal_goto
+  __ia64_personality_v1
+  __ia64_restore_stack_nonlocal
+  __ia64_save_stack_nonlocal
+  __ia64_trampoline
+}
index 1f1e61a..f27c729 100644 (file)
@@ -20,6 +20,8 @@ LIB1ASMFUNCS  = __divtf3 __divdf3 __divsf3 \
 # to support the Intel assembler.
 #LIBGCC2_DEBUG_CFLAGS = -g1 -P
 
+SHLIB_MAPFILES += $(srcdir)/config/ia64/libgcc-ia64.ver
+
 # For svr4 we build crtbegin.o and crtend.o which serve to add begin and
 # end labels to the .ctors and .dtors section when we link using gcc.
 
diff --git a/gcc/config/libgcc-glibc.ver b/gcc/config/libgcc-glibc.ver
new file mode 100644 (file)
index 0000000..837c1a7
--- /dev/null
@@ -0,0 +1,23 @@
+# In order to work around the very problems that force us to now generally
+# create a libgcc.so, glibc reexported a number of routines from libgcc.a.
+# By now choosing the same version tags for these specific routines, we
+# maintain enough binary compatibility to allow future versions of glibc
+# to defer implementation of these routines to libgcc.so via DT_AUXILIARY.
+
+%inherit GCC_3.0 GLIBC_2.0
+GLIBC_2.0 {
+  # Sampling of DImode arithmetic used by (at least) i386 and m68k.
+  __divdi3
+  __moddi3
+  __udivdi3
+  __umoddi3
+
+  # Exception handling support functions used by most everyone.
+  __register_frame
+  __register_frame_table
+  __deregister_frame
+  __register_frame_info
+  __deregister_frame_info
+  __frame_state_for
+  __register_frame_info_table
+}
index 7cc82da..24e385d 100644 (file)
@@ -22,4 +22,10 @@ CRTSTUFF_T_CFLAGS=-g1
 # Build a shared libgcc library.
 SHLIB_LINK = $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
         -Wl,-soname,@shlib_base_name@.so.0
+# ??? Irix 6.5 seems to eat the option fine (if we somehow remove the
+# -hidden_symbol option, which is documented to be ignored in conjunction
+# with -exports_file), but fails to actually hide any symbols.
+# -Wl,-exports_file,libgcc.map
 SHLIB_LIBS = -lc
+SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk
+SHLIB_MAPFILES = $(srcdir)/libgcc-std.ver 
index 6ac994e..7a44631 100644 (file)
@@ -31,5 +31,8 @@ TARGET_LIBGCC2_CFLAGS = -fPIC
 
 # Build a shared libgcc library.
 SHLIB_LINK = $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
-       -Wl,-h,@shlib_base_name@.so.0 -Wl,-z,text -Wl,-z,defs
+       -Wl,-h,@shlib_base_name@.so.0 -Wl,-z,text -Wl,-z,defs \
+       -Wl,-M,libgcc.map
 SHLIB_LIBS = -lc
+SHLIB_MKMAP = $(srcdir)/mkmap-symver.awk
+SHLIB_MAPFILES = $(srcdir)/libgcc-std.ver
index 966ae81..858faa9 100644 (file)
@@ -10,14 +10,14 @@ CRTSTUFF_T_CFLAGS_S = -fPIC
 TARGET_LIBGCC2_CFLAGS = -fPIC
 # Build a shared libgcc library.
 SHLIB_LINK = $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
-       -Wl,--soname=@shlib_base_name@.so.0
-# ??? Do versioning later -- need to figure out how to post-process
-# the script and allow for target-specific additions.
-# -Wl,--version-script=$(srcdir)/config/ver-glibc.map
+       -Wl,--soname=@shlib_base_name@.so.0 \
+       -Wl,--version-script=libgcc.map
 SHLIB_LIBS = -lc
+SHLIB_MKMAP = $(srcdir)/mkmap-symver.awk
+SHLIB_MAPFILES = $(srcdir)/libgcc-std.ver $(srcdir)/config/libgcc-glibc.ver
 
 # Do not build libgcc1. Let gcc generate those functions. The GNU/Linux
 # C library can handle them.
-LIBGCC1 = 
+LIBGCC1 =
 CROSS_LIBGCC1 =
 LIBGCC1_TEST =
diff --git a/gcc/libgcc-std.ver b/gcc/libgcc-std.ver
new file mode 100644 (file)
index 0000000..b3bf25f
--- /dev/null
@@ -0,0 +1,129 @@
+GCC_3.0 {
+  # libgcc1 symbols
+  __adddf3
+  __addsf3
+  __ashlsi3
+  __ashrsi3
+  __divdf3
+  __divsf3
+  __divsi3
+  __divtf3
+  __eqdf2
+  __eqsf2
+  __extendsfdf2
+  __fixdfsi
+  __fixsfsi
+  __floatsidf
+  __floatsisf
+  __gedf2
+  __gesf2
+  __gtdf2
+  __gtsf2
+  __ledf2
+  __lesf2
+  __lshrsi3
+  __ltdf2
+  __ltsf2
+  __modsi3
+  __muldf3
+  __mulsf3
+  __mulsi3
+  __nedf2
+  __negdf2
+  __negsf2
+  __nesf2
+  __subdf3
+  __subsf3
+  __truncdfsf2
+  __udivsi3
+  __umodsi3
+
+  # libgcc2 DImode arithmetic (for 32-bit targets).
+  __ashldi3
+  __ashrdi3
+  __cmpdi2
+  __divdi3
+  __ffsdi2
+  __fixdfdi
+  __fixsfdi
+  __fixunsdfdi
+  __fixunssfdi
+  __floatdidf
+  __floatdisf
+  __lshrdi3
+  __moddi3
+  __muldi3
+  __negdi2
+  __ucmpdi2
+  __udivdi3
+  __udivmoddi4
+  __umoddi3
+
+  # libgcc2 TImode arithmetic (for 64-bit targets).
+  __ashlti3
+  __ashrti3
+  __cmpti2
+  __divti3
+  __ffsti2
+  __fixdfti
+  __fixsfti
+  __lshrti3
+  __modti3
+  __multi3
+  __negti2
+  __ucmpti2
+  __udivmodti4
+  __udivti3
+  __umodti3
+  __fixunsdfti
+  __fixunssfti
+  __floattidf
+  __floattisf
+  __fixtfti
+  __fixunstfti
+  __floattitf
+
+  # Basic block profile symbols.
+  # ??? Some of these are for `-a', which ought to die.
+  __bb
+  __bb_exit_func
+  __bb_fork_func
+  __bb_init_func
+  __bb_init_trace_func
+  __bb_trace_func
+  __bb_trace_ret
+
+  # ??? Symbols that perhaps unused should be nuked.
+  __builtin_saveregs
+  __clear_cache
+  __dummy
+  __empty
+  __eprintf
+  __gcc_bcmp
+  __shtab
+
+  # EH symbols
+  __default_terminate
+  __deregister_frame
+  __deregister_frame_info
+  __eh_alloc
+  __eh_free
+  __eh_rtime_match
+  __frame_state_for
+  __get_dynamic_handler_chain
+  __get_eh_context
+  __get_eh_info
+  __get_eh_table_language
+  __get_eh_table_version
+  __register_frame
+  __register_frame_info
+  __register_frame_info_table
+  __register_frame_table
+  __rethrow
+  __sjpopnthrow
+  __sjthrow
+  __terminate
+  __throw
+  __throw_type_match
+  __unwinding_cleanup
+}
index 54dcf2b..43dac4f 100644 (file)
@@ -26,6 +26,8 @@
 # SHLIB_LINK
 # SHLIB_LIBS
 # SHLIB_MULTILIB
+# SHLIB_MKMAP
+# SHLIB_MAPFILES
 
 # Make needs VPATH to be literal.
 echo 'srcdir = @srcdir@'
@@ -263,6 +265,8 @@ for file in $LIB2ADD; do
   fi
 done
 
+# SHLIB_MKMAP
+# SHLIB_MAPFILES
 for ml in $MULTILIBS; do
   dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
   flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
@@ -278,6 +282,22 @@ for ml in $MULTILIBS; do
   for o in $libgcc2_objs; do
     libgcc_objs="$libgcc_objs libgcc/${dir}/$o"
   done
+  shlib_deps="$libgcc_objs"
+
+  if [ "$SHLIB_LINK" -a "$SHLIB_MKMAP" -a -z "$mapfile" ]; then
+    mapfile="libgcc.map"
+    shlib_deps="$shlib_deps $mapfile"
+    echo ""
+    echo "${mapfile}: $SHLIB_MKMAP $SHLIB_MAPFILES $libgcc_objs"
+    echo '     { $(NM_FOR_TARGET) -pg'" $libgcc_objs; echo %%; cat $SHLIB_MAPFILES; } | "'$(AWK)'" -f $SHLIB_MKMAP > "'tmp-$@'
+    echo '     mv tmp-$@ $@'
+  fi
+
+  # Depend on EXTRA_MULTILIB_PARTS, since that's where crtbegin/end
+  # usually are put in a true multilib situation.
+  for f in $EXTRA_MULTILIB_PARTS; do
+    shlib_deps="$shlib_deps $dir/$f"
+  done
 
   echo ""
   echo "${dir}/libgcc.a: $libgcc_objs"
@@ -295,12 +315,12 @@ for ml in $MULTILIBS; do
        shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
       fi
       echo ""
-      echo "${dir}/${shlib_base_name}.so: $libgcc_objs"
+      echo "${dir}/${shlib_base_name}.so: $shlib_deps"
       echo "   $SHLIB_LINK $flags -o ${shlib_base_name}.so $libgcc_objs $SHLIB_LIBS" | sed "s/@shlib_base_name@/$shlib_base_name/g"
     elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
       shlib_base_name="libgcc_s";
       echo ""
-      echo "${shlib_base_name}.so: $libgcc_objs"
+      echo "${shlib_base_name}.so: $shlib_deps"
       echo "   $SHLIB_LINK $flags -o ${shlib_base_name}.so $libgcc_objs $SHLIB_LIBS" | sed "s/@shlib_base_name@/$shlib_base_name/g"
     fi
   fi
diff --git a/gcc/mkmap-flat.awk b/gcc/mkmap-flat.awk
new file mode 100644 (file)
index 0000000..de22d7c
--- /dev/null
@@ -0,0 +1,78 @@
+# Generate a flat list of symbols to export.
+#      Contributed by Richard Henderson <rth@cygnus.com>
+#
+# This file is part of GNU CC.
+#
+# 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.
+#
+# 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.
+#
+# 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.
+
+BEGIN {
+  state = "nm";
+}
+
+# Remove comment and blank lines.
+/^ *#/ || /^ *$/ {
+  next;
+}
+
+# We begin with nm input.  Collect the set of symbols that are present
+# so that we can elide undefined symbols.
+
+state == "nm" && /^%%/ {
+  state = "ver";
+  next;
+}
+
+state == "nm" && ($1 == "U" || $2 == "U") {
+  next;
+}
+
+state == "nm" && NF == 3 {
+  def[$3] = 1;
+  next;
+}
+
+state == "nm" {
+  next;
+}
+
+# Now we process a simplified variant of the Solaris symbol version
+# script.  We have one symbol per line, no semicolons, simple markers
+# for beginning and ending each section, and %inherit markers for
+# describing version inheritence.  A symbol may appear in more than
+# one symbol version, and the last seen takes effect.
+
+NF == 3 && $1 == "%inherit" {
+  next;
+}
+
+NF == 2 && $2 == "{" {
+  next;
+}
+
+$1 == "}" {
+  next;
+}
+
+{
+  export[$1] = 1;
+  next;
+}
+
+END {
+  for (sym in export)
+    if (def[sym])
+      print sym;
+}
diff --git a/gcc/mkmap-symver.awk b/gcc/mkmap-symver.awk
new file mode 100644 (file)
index 0000000..5ea6769
--- /dev/null
@@ -0,0 +1,101 @@
+# 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.
+#
+# 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.
+#
+# 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.
+#
+# 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.
+
+BEGIN {
+  state = "nm";
+}
+
+# Remove comment and blank lines.
+/^ *#/ || /^ *$/ {
+  next;
+}
+
+# We begin with nm input.  Collect the set of symbols that are present
+# so that we can not emit them into the final version script -- Solaris
+# complains at us if we do.
+
+state == "nm" && /^%%/ {
+  state = "ver";
+  next;
+}
+
+state == "nm" && ($1 == "U" || $2 == "U") {
+  next;
+}
+
+state == "nm" && NF == 3 {
+  def[$3] = 1;
+  next;
+}
+
+state == "nm" {
+  next;
+}
+
+# Now we process a simplified variant of the Solaris symbol version
+# script.  We have one symbol per line, no semicolons, simple markers
+# for beginning and ending each section, and %inherit markers for
+# describing version inheritence.  A symbol may appear in more than
+# one symbol version, and the last seen takes effect.
+
+NF == 3 && $1 == "%inherit" {
+  inherit[$2] = $3;
+  next;
+}
+
+NF == 2 && $2 == "{" {
+  libs[$1] = 1;
+  thislib = $1;
+  next;
+}
+
+$1 == "}" {
+  thislib = "";
+  next;
+}
+
+{
+  ver[$1] = thislib;
+  next;
+}
+
+END {
+  for (l in libs)
+    output(l);
+}
+
+function output(lib) {
+  if (done[lib])
+    return;
+  done[lib] = 1;
+  if (inherit[lib])
+    output(inherit[lib]);
+
+  printf("%s {\n", lib);
+  printf("  global:\n");
+  for (sym in ver)
+    if ((ver[sym] == lib) && (sym in def))
+      printf("\t%s;\n", sym);
+
+  if (inherit[lib])
+    printf("} %s;\n", inherit[lib]);
+  else
+    printf ("\n  local:\n\t*;\n};\n");
+}