This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] sh-linux: Backport 3.4 shared libgcc stuff to 3.3


Hi,

In SH-3/4, some functions in libgcc.a should not be called via PLT
but in gcc-3.3 they are exported without any visibility attributes.
This is cleary a bug which is known from 2.9x era, though I don't
have a handy testcase because it appears only in fairly complex
programs using shared libraries.
An easy solution is to make libgcc.a functions .hidden like as almost
other linux targets do in 3.3, as the result of creating shared
libgcc.  sh-linux does it in 3.4, so it would be not so invasive to
backport 3.4 shared libgcc stuff to 3.3 branch as a bug fix.
The attatched patch is tested with bootstrap and regtested with no
new failures.
Is it OK for 3.3.3, though it's not a pure regression fix?

Regards,
	kaz
--
2003-12-01  Kaz Kojima  <kkojima@gcc.gnu.org>

	* config.gcc (sh*-*-linux*): Add t-slibgcc-elf-ver and t-linux.
        to tmake_file.	* config/sh/libgcc-glibc.ver: New file.
	* config/sh/t-linux (SHLIB_LINK): Override to use a linker script
	libgcc_s.so.
	(SHLIB_INSTALL): Likewise.

diff -u3prN ORIG/gcc-3.3/gcc/config/sh/libgcc-glibc.ver LOCAL/gcc-3.3/gcc/config/sh/libgcc-glibc.ver
--- ORIG/gcc-3.3/gcc/config/sh/libgcc-glibc.ver	Thu Jan  1 09:00:00 1970
+++ LOCAL/gcc-3.3/gcc/config/sh/libgcc-glibc.ver	Tue Dec  2 10:22:41 2003
@@ -0,0 +1,21 @@
+# 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.
+
+# Note that we cannot use the default libgcc-glibc.ver file on sh,
+# because GLIBC_2.0 does not exist on this architecture, as the first 
+# ever glibc release on the platform was GLIBC_2.2.
+
+%inherit GCC_3.0 GLIBC_2.2
+GLIBC_2.2 {
+  __register_frame
+  __register_frame_table
+  __deregister_frame
+  __register_frame_info
+  __deregister_frame_info
+  __frame_state_for
+  __register_frame_info_table
+}
+
diff -u3prN ORIG/gcc-3.3/gcc/config/sh/t-linux LOCAL/gcc-3.3/gcc/config/sh/t-linux
--- ORIG/gcc-3.3/gcc/config/sh/t-linux	Fri Jun  6 11:07:14 2003
+++ LOCAL/gcc-3.3/gcc/config/sh/t-linux	Tue Dec  2 10:22:41 2003
@@ -12,3 +12,27 @@ MULTILIB_MATCHES = 
 MULTILIB_EXCEPTIONS=
 
 EXTRA_MULTILIB_PARTS= crtbegin.o crtend.o crtbeginS.o crtendS.o
+
+# Override t-slibgcc-elf-ver to export some libgcc symbols with
+# the symbol versions that glibc used.
+SHLIB_MAPFILES =  $(srcdir)/libgcc-std.ver $(srcdir)/config/sh/libgcc-glibc.ver
+
+# Override SHLIB_LINK and SHLIB_INSTALL to use linker script
+# libgcc_s.so.
+SHLIB_LINK = $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
+	-Wl,--soname=$(SHLIB_SONAME) \
+	-Wl,--version-script=$(SHLIB_MAP) \
+	-o $(SHLIB_NAME) @multilib_flags@ $(SHLIB_OBJS) $(SHLIB_LC) && \
+	rm -f $(SHLIB_SOLINK) && \
+	(echo "/* GNU ld script"; \
+	 echo "   Use the shared library, but some functions are only in"; \
+	 echo "   the static library.  */"; \
+	 echo "GROUP ( $(SHLIB_SONAME) libgcc.a )" \
+	) > $(SHLIB_SOLINK)
+SHLIB_INSTALL = \
+	$$(SHELL) $$(srcdir)/mkinstalldirs $$(slibdir)$(SHLIB_SLIBDIR_QUAL); \
+	$(INSTALL_DATA) $(SHLIB_NAME) \
+	  $$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SONAME); \
+	rm -f $$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK); \
+	$(INSTALL_DATA) $(SHLIB_SOLINK) \
+	  $$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK)
diff -u3prN ORIG/gcc-3.3/gcc/config.gcc LOCAL/gcc-3.3/gcc/config.gcc
--- ORIG/gcc-3.3/gcc/config.gcc	Sat Nov 15 09:49:51 2003
+++ LOCAL/gcc-3.3/gcc/config.gcc	Tue Dec  2 10:24:34 2003
@@ -2305,7 +2305,7 @@ sh-*-rtems*)
 	fi
 	;;
 sh-*-linux* | sh[2346lbe]*-*-linux*)
-	tmake_file="sh/t-sh sh/t-elf"
+	tmake_file="sh/t-sh sh/t-elf t-slibgcc-elf-ver t-linux"
 	case $machine in
 	sh*be-*-* | sh*eb-*-*) ;;
 	*)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]