Darwin libgcc/assert fix, uncontroversial piece (need sh-linux testing)

Zack Weinberg zack@codesourcery.com
Tue Nov 16 22:58:00 GMT 2004


This is part of the fix for the Darwin problems with libgcc and
<assert.h> that I raised yesterday.  Specifically, it contains all of
the pieces that I hope will be uncontroversial:

1) Add to mkmap-*.awk the ability to handle systems that prefix all
   symbols with an underscore.

2) Add to mkmap-*.awk input notation for removing symbols from the
   generated file:

   %exclude {
      sym1
      sym2
      ...
   }

3) Delete config/sh/libgcc-std.ver.  Create config/sh/libgcc-excl.ver,
   and change config/sh/t-linux to use it.  (Perhaps the exclusions
   should be in config/sh/libgcc-glibc.ver instead of creating a new
   file.  Thoughts?)

4) Change t-slibgcc-darwin to use mkmap-flat.awk instead of
   mkmap-symver.awk, to enable leading underscore mode, to use the
   standard .ver file, and to use the generated mapfile for something
   (-Wl,-exported_symbols_file).

5) Remove dot-symbol mode, which is no longer used, from
   mkmap-symver.awk.

This has been bootstrapped, with no regressions, on i686-linux and
powerpc-darwin.  I do not have the ability to test sh-linux; I would
appreciate help on that score.  I will not check this patch in without
hearing from SH maintainers first.

zw

        * mkmap-flat.awk, mkmap-symver.awk: If the last version
        assigned to a symbol was '%exclude', do not emit it anywhere.
        If leading_underscore is true, prefix all symbols from the
        version scripts with a leading underscore before comparing
        them with nm output or emitting them.  Remove support for dot
        symbols.
        * config/t-slibgcc-darwin (SHLIB_LINK): Use mkmap-flat.awk.
        (SHLIB_MAPFILES): Use libgcc-std.ver.
        (SHLIB_MKMAP_OPTS): Enable leading-underscore mode.
        (SHLIB_LINK): Add -Wl,-exported_symbols_list,$(SHLIB_MAP).
        * config/sh/t-linux: Use the normal libgcc-std.ver, plus
        libgcc-excl.ver and libgcc-glibc.ver.

        * config/sh/libgcc-excl.ver: New file.
        * config/sh/libgcc-std.ver, libgcc-darwin.ver: Delete.

===================================================================
Index: mkmap-flat.awk
--- mkmap-flat.awk	22 Aug 2001 14:35:30 -0000	1.2
+++ mkmap-flat.awk	16 Nov 2004 22:39:37 -0000
@@ -20,6 +20,11 @@
 
 BEGIN {
   state = "nm";
+  excluding = 0;
+  if (leading_underscore)
+    prefix = "_";
+  else
+    prefix = "";
 }
 
 # Remove comment and blank lines.
@@ -53,21 +58,30 @@ state == "nm" {
 # 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.
+# The magic version name '%exclude' causes all the symbols given that
+# version to be dropped from the output (unless a later version overrides).
 
 NF == 3 && $1 == "%inherit" {
   next;
 }
 
 NF == 2 && $2 == "{" {
+  if ($1 == "%exclude")
+    excluding = 1;
   next;
 }
 
 $1 == "}" {
+  excluding = 0;
   next;
 }
 
 {
-  export[$1] = 1;
+  sym = prefix $1;
+  if (excluding)
+    delete export[sym];
+  else
+    export[sym] = 1;
   next;
 }
 
===================================================================
Index: mkmap-symver.awk
--- mkmap-symver.awk	4 Sep 2003 10:47:45 -0000	1.5
+++ mkmap-symver.awk	16 Nov 2004 22:39:37 -0000
@@ -21,6 +21,10 @@
 BEGIN {
   state = "nm";
   sawsymbol = 0;
+  if (leading_underscore)
+    prefix = "_";
+  else
+    prefix = "";
 }
 
 # Remove comment and blank lines.
@@ -56,6 +60,8 @@ state == "nm" {
 # 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.
+# The magic version name '%exclude' causes all the symbols given that
+# version to be dropped from the output (unless a later version overrides).
 
 NF == 3 && $1 == "%inherit" {
   inherit[$2] = $3;
@@ -63,7 +69,8 @@ NF == 3 && $1 == "%inherit" {
 }
 
 NF == 2 && $2 == "{" {
-  libs[$1] = 1;
+  if ($1 != "%exclude")
+    libs[$1] = 1;
   thislib = $1;
   next;
 }
@@ -74,7 +81,11 @@ $1 == "}" {
 }
 
 {
-  ver[$1] = thislib;
+  sym = prefix $1;
+  if (thislib != "%exclude")
+    ver[sym] = thislib;
+  else
+    delete ver[sym];
   next;
 }
 
@@ -106,8 +117,6 @@ function output(lib) {
 	    empty = 0;
 	  }
 	printf("\t%s;\n", sym);
-	if (dotsyms)
-	  printf("\t.%s;\n", sym);
       }
 
   if (empty)
===================================================================
Index: config/t-slibgcc-darwin
--- config/t-slibgcc-darwin	18 Oct 2004 15:52:41 -0000	1.4
+++ config/t-slibgcc-darwin	16 Nov 2004 22:14:54 -0000
@@ -13,6 +13,7 @@ SHLIB_SLIBDIR_QUAL = @shlib_slibdir_qual
 SHLIB_LINK = $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -dynamiclib -nodefaultlibs \
 	-Wl,-install_name,$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SONAME) \
 	-Wl,-flat_namespace -o $(SHLIB_NAME).tmp \
+	-Wl,-exported_symbols_list,$(SHLIB_MAP) \
 	$(SHLIB_VERSTRING) \
 	@multilib_flags@ $(SHLIB_OBJS) -lc && \
 	rm -f $(SHLIB_SOLINK) && \
@@ -30,5 +31,6 @@ SHLIB_INSTALL = \
 	rm -f $$(DESTDIR)$$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK); \
 	$(LN_S) $(SHLIB_SONAME) \
 	  $$(DESTDIR)$$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK)
-SHLIB_MKMAP = $(srcdir)/mkmap-symver.awk
-SHLIB_MAPFILES = $(srcdir)/libgcc-darwin.ver
+SHLIB_MKMAP = $(srcdir)/mkmap-flat.awk
+SHLIB_MKMAP_OPTS = -v leading_underscore=1
+SHLIB_MAPFILES = $(srcdir)/libgcc-std.ver
===================================================================
Index: config/sh/t-linux
--- config/sh/t-linux	18 Oct 2004 15:52:51 -0000	1.14
+++ config/sh/t-linux	16 Nov 2004 22:14:59 -0000
@@ -10,10 +10,12 @@ MULTILIB_EXCEPTIONS=
 EXTRA_MULTILIB_PARTS= crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o
 
 # Override t-slibgcc-elf-ver to export some libgcc symbols with
-# the symbol versions that glibc used.  Also use an sh specific
-# libgcc-std.ver to avoid to export some lib1func routines which
-# should not be called via PLT.
-SHLIB_MAPFILES =  $(srcdir)/config/sh/libgcc-std.ver \
+# the symbol versions that glibc used, and hide some lib1func
+# routines which should not be called via PLT.  We have to create
+# the list from scratch.
+SHLIB_MAPFILES = \
+	$(srcdir)/libgcc-std.ver \
+	$(srcdir)/config/sh/libgcc-excl.ver \
 	$(srcdir)/config/sh/libgcc-glibc.ver
 
 # Override SHLIB_LINK and SHLIB_INSTALL to use linker script
===================================================================
Index: config/sh/libgcc-excl.ver
--- config/sh/libgcc-excl.ver	1 Jan 1970 00:00:00 -0000
+++ config/sh/libgcc-excl.ver	16 Nov 2004 22:14:54 -0000
@@ -0,0 +1,7 @@
+# Exclude various symbols which should not be visible in libgcc.so for SH.
+%exclude {
+  __ashlsi3
+  __ashrsi3
+  __lshrsi3
+  __udivsi3
+}
===================================================================
Index: config/sh/libgcc-std.ver
--- config/sh/libgcc-std.ver	13 Jun 2004 06:35:56 -0000	1.2
+++ config/sh/libgcc-std.ver	1 Jan 1970 00:00:00 -0000
@@ -1,218 +0,0 @@
-GCC_3.0 {
-  # libgcc1 integer symbols
-  __absvsi2
-  __addvsi3
-  # __ashlsi3
-  # __ashrsi3
-  __divsi3
-  # __lshrsi3
-  __modsi3
-  __mulsi3
-  __mulvsi3
-  __negvsi2
-  __subvsi3
-  # __udivsi3
-  __umodsi3
-
-  # libgcc1 floating point symbols
-  __addsf3
-  __adddf3
-  __addxf3
-  __addtf3
-  __divsf3
-  __divdf3
-  __divxf3
-  __divtf3
-  __eqsf2
-  __eqdf2
-  __eqxf2
-  __eqtf2
-  __extenddfxf2
-  __extenddftf2
-  __extendsfdf2
-  __extendsfxf2
-  __extendsftf2
-  __fixsfsi
-  __fixdfsi
-  __fixxfsi
-  __fixtfsi
-  __floatsisf
-  __floatsidf
-  __floatsixf
-  __floatsitf
-  __gesf2
-  __gedf2
-  __gexf2
-  __getf2
-  __gtsf2
-  __gtdf2
-  __gtxf2
-  __gttf2
-  __lesf2
-  __ledf2
-  __lexf2
-  __letf2
-  __ltsf2
-  __ltdf2
-  __ltxf2
-  __lttf2
-  __mulsf3
-  __muldf3
-  __mulxf3
-  __multf3
-  __negsf2
-  __negdf2
-  __negxf2
-  __negtf2
-  __nesf2
-  __nedf2
-  __nexf2
-  __netf2
-  __subsf3
-  __subdf3
-  __subxf3
-  __subtf3
-  __truncdfsf2
-  __truncxfsf2
-  __trunctfsf2
-  __truncxfdf2
-  __trunctfdf2
-
-  # libgcc2 DImode arithmetic (for 32-bit targets).
-  __absvdi2
-  __addvdi3
-  __ashldi3
-  __ashrdi3
-  __cmpdi2
-  __divdi3
-  __ffsdi2
-  __fixdfdi
-  __fixsfdi
-  __fixtfdi
-  __fixxfdi
-  __fixunsdfdi
-  __fixunsdfsi
-  __fixunssfsi
-  __fixunssfdi
-  __fixunstfdi
-  __fixunstfsi
-  __fixunsxfdi
-  __fixunsxfsi
-  __floatdidf
-  __floatdisf
-  __floatdixf
-  __floatditf
-  __lshrdi3
-  __moddi3
-  __muldi3
-  __mulvdi3
-  __negdi2
-  __negvdi2
-  __subvdi3
-  __ucmpdi2
-  __udivdi3
-  __udivmoddi4
-  __umoddi3
-
-  # libgcc2 TImode arithmetic (for 64-bit targets).
-  __ashlti3
-  __ashrti3
-  __cmpti2
-  __divti3
-  __ffsti2
-  __fixdfti
-  __fixsfti
-  __fixtfti
-  __fixxfti
-  __lshrti3
-  __modti3
-  __multi3
-  __negti2
-  __ucmpti2
-  __udivmodti4
-  __udivti3
-  __umodti3
-  __fixunsdfti
-  __fixunssfti
-  __fixunstfti
-  __fixunsxfti
-  __floattidf
-  __floattisf
-  __floattixf
-  __floattitf
-
-  # Used to deal with trampoline initialization on some platforms
-  __clear_cache
-
-  # EH symbols
-  _Unwind_DeleteException
-  _Unwind_Find_FDE
-  _Unwind_ForcedUnwind
-  _Unwind_GetGR
-  _Unwind_GetIP
-  _Unwind_GetLanguageSpecificData
-  _Unwind_GetRegionStart
-  _Unwind_GetTextRelBase
-  _Unwind_GetDataRelBase
-  _Unwind_RaiseException
-  _Unwind_Resume
-  _Unwind_SetGR
-  _Unwind_SetIP
-  __deregister_frame
-  __deregister_frame_info
-  __deregister_frame_info_bases
-  __register_frame
-  __register_frame_info
-  __register_frame_info_bases
-  __register_frame_info_table
-  __register_frame_info_table_bases
-  __register_frame_table
-
-  # SjLj EH symbols
-  _Unwind_SjLj_Register
-  _Unwind_SjLj_Unregister
-  _Unwind_SjLj_RaiseException
-  _Unwind_SjLj_ForcedUnwind
-  _Unwind_SjLj_Resume
-}
-
-%inherit GCC_3.3 GCC_3.0
-GCC_3.3 {
-  _Unwind_FindEnclosingFunction
-  _Unwind_GetCFA
-  _Unwind_Backtrace
-  _Unwind_Resume_or_Rethrow
-  _Unwind_SjLj_Resume_or_Rethrow
-}
-
-%inherit GCC_3.3.1 GCC_3.3
-GCC_3.3.1 {
-  __gcc_personality_sj0
-  __gcc_personality_v0
-}
-
-%inherit GCC_3.3.2 GCC_3.3.1
-GCC_3.3.2 {
-}
-%inherit GCC_3.3.4 GCC_3.3.2
-GCC_3.3.4 {
-  __unorddf2
-  __unordsf2
-}
-
-%inherit GCC_3.4 GCC_3.3.4
-GCC_3.4 {
-  # bit scanning and counting built-ins
-  __clzsi2
-  __clzdi2
-  __clzti2
-  __ctzsi2
-  __ctzdi2
-  __ctzti2
-  __popcountsi2
-  __popcountdi2
-  __popcountti2
-  __paritysi2
-  __paritydi2
-  __parityti2
-}
===================================================================
Index: libgcc-darwin.ver
--- libgcc-darwin.ver	12 Jun 2004 04:34:58 -0000	2.2
+++ libgcc-darwin.ver	1 Jan 1970 00:00:00 -0000
@@ -1,218 +0,0 @@
-GCC_3.0 {
-  # libgcc1 integer symbols
-  ___absvsi2
-  ___addvsi3
-  ___ashlsi3
-  ___ashrsi3
-  ___divsi3
-  ___lshrsi3
-  ___modsi3
-  ___mulsi3
-  ___mulvsi3
-  ___negvsi2
-  ___subvsi3
-  ___udivsi3
-  ___umodsi3
-
-  # libgcc1 floating point symbols
-  ___addsf3
-  ___adddf3
-  ___addxf3
-  ___addtf3
-  ___divsf3
-  ___divdf3
-  ___divxf3
-  ___divtf3
-  ___eqsf2
-  ___eqdf2
-  ___eqxf2
-  ___eqtf2
-  ___extenddfxf2
-  ___extenddftf2
-  ___extendsfdf2
-  ___extendsfxf2
-  ___extendsftf2
-  ___fixsfsi
-  ___fixdfsi
-  ___fixxfsi
-  ___fixtfsi
-  ___floatsisf
-  ___floatsidf
-  ___floatsixf
-  ___floatsitf
-  ___gesf2
-  ___gedf2
-  ___gexf2
-  ___getf2
-  ___gtsf2
-  ___gtdf2
-  ___gtxf2
-  ___gttf2
-  ___lesf2
-  ___ledf2
-  ___lexf2
-  ___letf2
-  ___ltsf2
-  ___ltdf2
-  ___ltxf2
-  ___lttf2
-  ___mulsf3
-  ___muldf3
-  ___mulxf3
-  ___multf3
-  ___negsf2
-  ___negdf2
-  ___negxf2
-  ___negtf2
-  ___nesf2
-  ___nedf2
-  ___nexf2
-  ___netf2
-  ___subsf3
-  ___subdf3
-  ___subxf3
-  ___subtf3
-  ___truncdfsf2
-  ___truncxfsf2
-  ___trunctfsf2
-  ___truncxfdf2
-  ___trunctfdf2
-
-  # libgcc2 DImode arithmetic (for 32-bit targets).
-  ___absvdi2
-  ___addvdi3
-  ___ashldi3
-  ___ashrdi3
-  ___cmpdi2
-  ___divdi3
-  ___ffsdi2
-  ___fixdfdi
-  ___fixsfdi
-  ___fixtfdi
-  ___fixxfdi
-  ___fixunsdfdi
-  ___fixunsdfsi
-  ___fixunssfsi
-  ___fixunssfdi
-  ___fixunstfdi
-  ___fixunstfsi
-  ___fixunsxfdi
-  ___fixunsxfsi
-  ___floatdidf
-  ___floatdisf
-  ___floatdixf
-  ___floatditf
-  ___lshrdi3
-  ___moddi3
-  ___muldi3
-  ___mulvdi3
-  ___negdi2
-  ___negvdi2
-  ___subvdi3
-  ___ucmpdi2
-  ___udivdi3
-  ___udivmoddi4
-  ___umoddi3
-
-  # libgcc2 TImode arithmetic (for 64-bit targets).
-  ___ashlti3
-  ___ashrti3
-  ___cmpti2
-  ___divti3
-  ___ffsti2
-  ___fixdfti
-  ___fixsfti
-  ___fixtfti
-  ___fixxfti
-  ___lshrti3
-  ___modti3
-  ___multi3
-  ___negti2
-  ___ucmpti2
-  ___udivmodti4
-  ___udivti3
-  ___umodti3
-  ___fixunsdfti
-  ___fixunssfti
-  ___fixunstfti
-  ___fixunsxfti
-  ___floattidf
-  ___floattisf
-  ___floattixf
-  ___floattitf
-
-  # Used to deal with trampoline initialization on some platforms
-  ___clear_cache
-
-  # EH symbols
-  __Unwind_DeleteException
-  __Unwind_Find_FDE
-  __Unwind_ForcedUnwind
-  __Unwind_GetGR
-  __Unwind_GetIP
-  __Unwind_GetLanguageSpecificData
-  __Unwind_GetRegionStart
-  __Unwind_GetTextRelBase
-  __Unwind_GetDataRelBase
-  __Unwind_RaiseException
-  __Unwind_Resume
-  __Unwind_SetGR
-  __Unwind_SetIP
-  ___deregister_frame
-  ___deregister_frame_info
-  ___deregister_frame_info_bases
-  ___register_frame
-  ___register_frame_info
-  ___register_frame_info_bases
-  ___register_frame_info_table
-  ___register_frame_info_table_bases
-  ___register_frame_table
-
-  # SjLj EH symbols
-  __Unwind_SjLj_Register
-  __Unwind_SjLj_Unregister
-  __Unwind_SjLj_RaiseException
-  __Unwind_SjLj_ForcedUnwind
-  __Unwind_SjLj_Resume
-}
-
-%inherit GCC_3.3 GCC_3.0
-GCC_3.3 {
-  __Unwind_FindEnclosingFunction
-  __Unwind_GetCFA
-  __Unwind_Backtrace
-  __Unwind_Resume_or_Rethrow
-  __Unwind_SjLj_Resume_or_Rethrow
-}
-
-%inherit GCC_3.3.1 GCC_3.3
-GCC_3.3.1 {
-  __gcc_personality_sj0
-  __gcc_personality_v0
-}
-
-%inherit GCC_3.3.2 GCC_3.3.1
-GCC_3.3.2 {
-}
-%inherit GCC_3.3.4 GCC_3.3.2
-GCC_3.3.4 {
-  __unorddf2
-  __unordsf2
-}
-
-%inherit GCC_3.4 GCC_3.3.4
-GCC_3.4 {
-  # bit scanning and counting built-ins
-  ___clzsi2
-  ___clzdi2
-  ___clzti2
-  ___ctzsi2
-  ___ctzdi2
-  ___ctzti2
-  ___popcountsi2
-  ___popcountdi2
-  ___popcountti2
-  ___paritysi2
-  ___paritydi2
-  ___parityti2
-}



More information about the Gcc-patches mailing list