patches/gcc/3.3.2/sh-libgcc-hidden.patch
changeset 1 eeea35fbf182
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/gcc/3.3.2/sh-libgcc-hidden.patch	Sat Feb 24 11:00:05 2007 +0000
     1.3 @@ -0,0 +1,122 @@
     1.4 +[adjusted very slightly to apply to gcc-3.3.2 - dank]
     1.5 +
     1.6 +From: kaz Kojima <kkojima@rr.iij4u.or.jp>
     1.7 +
     1.8 +I've noticed one more problem about this issue.  In the testcase given
     1.9 +by ZhouChang, libdemo.so exports __movstr_i4_even which is a function
    1.10 +in libgcc.a. This itself is not a problem but it means that some functions
    1.11 +in libgcc.a which should not be exported from shared objects might be
    1.12 +exported from shared libs
    1.13 +
    1.14 +Date: Wed, 19 Nov 2003 09:04:12 +0900 (JST)
    1.15 +From: kaz Kojima <kkojima@rr.iij4u.or.jp>
    1.16 +Subject: [linux-sh:03096] Re: [linux]  Re: About tool chain in
    1.17 + http://kegel.com/crosstool/
    1.18 +To: dank@kegel.com
    1.19 +Cc: zjuzhou@yahoo.com.cn, linux-sh@m17n.org, zhan_sh@yahoo.com.cn,
    1.20 +	crossgcc@sources.redhat.com
    1.21 +Message-Id: <20031119.090412.85413542.kkojima@rr.iij4u.or.jp>
    1.22 +
    1.23 +Hi,
    1.24 +
    1.25 +Dan Kegel <dank@kegel.com> wrote:
    1.26 +> I'll try that, thanks.  I notice that the '.hidden' isn't in cvs yet.
    1.27 +> I also notice you've been trying to get that into CVS for two years
    1.28 +> now (http://gcc.gnu.org/ml/gcc-patches/2001-10/msg00053.html).
    1.29 +> Time for another try?  It'd be nice if gcc-3.4 (and maybe even gcc-3.3.3)
    1.30 +> didn't need a patch for this.
    1.31 +
    1.32 +The situation is a bit complicated. sh-linux target doesn't make
    1.33 +shared libgcc in gcc-3.3.x.
    1.34 +OTOH, I withdrew that .hidden patch because gcc-3.3 has a general
    1.35 +mechanism to make all libgcc functions .hidden. But I missed that
    1.36 +that mechanism was conditionalized later so that it's done only
    1.37 +when the target creates the shared libgcc.
    1.38 +In 3.4, sh-linux target becomes to use the shared libgcc like as
    1.39 +all other linux targets, so there is no problem.
    1.40 +
    1.41 +I inclined to backport 3.4 shared libgcc stuff to 3.3.3 rather
    1.42 +than the old .hidden patch. How do you think about it?
    1.43 +I'm happy if you or ZhouChang create a PR on gcc bugzilla about
    1.44 +this issue.
    1.45 +
    1.46 +Regards,
    1.47 +	kaz
    1.48 +--
    1.49 +	This is a backport of 3.4 shared libgcc stuff to 3.3 branch.
    1.50 +	* config.gcc (sh*-*-linux*): Add t-slibgcc-elf-ver and t-linux.
    1.51 +        to tmake_file.	* config/sh/libgcc-glibc.ver: New file.
    1.52 +	* config/sh/t-linux (SHLIB_LINK): Override to use a linker script
    1.53 +	libgcc_s.so.
    1.54 +	(SHLIB_INSTALL): Likewise.
    1.55 +
    1.56 +diff -u3prN ORIG/gcc-3.3/gcc/config/sh/libgcc-glibc.ver gcc-3.3/gcc/config/sh/libgcc-glibc.ver
    1.57 +--- ORIG/gcc-3.3/gcc/config/sh/libgcc-glibc.ver	Thu Jan  1 09:00:00 1970
    1.58 ++++ gcc-3.3/gcc/config/sh/libgcc-glibc.ver	Wed Nov 19 08:15:16 2003
    1.59 +@@ -0,0 +1,21 @@
    1.60 ++# In order to work around the very problems that force us to now generally
    1.61 ++# create a libgcc.so, glibc reexported a number of routines from libgcc.a.
    1.62 ++# By now choosing the same version tags for these specific routines, we
    1.63 ++# maintain enough binary compatibility to allow future versions of glibc
    1.64 ++# to defer implementation of these routines to libgcc.so via DT_AUXILIARY.
    1.65 ++
    1.66 ++# Note that we cannot use the default libgcc-glibc.ver file on sh,
    1.67 ++# because GLIBC_2.0 does not exist on this architecture, as the first 
    1.68 ++# ever glibc release on the platform was GLIBC_2.2.
    1.69 ++
    1.70 ++%inherit GCC_3.0 GLIBC_2.2
    1.71 ++GLIBC_2.2 {
    1.72 ++  __register_frame
    1.73 ++  __register_frame_table
    1.74 ++  __deregister_frame
    1.75 ++  __register_frame_info
    1.76 ++  __deregister_frame_info
    1.77 ++  __frame_state_for
    1.78 ++  __register_frame_info_table
    1.79 ++}
    1.80 ++
    1.81 +diff -u3prN ORIG/gcc-3.3/gcc/config/sh/t-linux gcc-3.3/gcc/config/sh/t-linux
    1.82 +--- ORIG/gcc-3.3/gcc/config/sh/t-linux	Fri Jun  6 11:07:14 2003
    1.83 ++++ gcc-3.3/gcc/config/sh/t-linux	Wed Nov 19 08:09:26 2003
    1.84 +@@ -12,3 +12,27 @@ MULTILIB_MATCHES = 
    1.85 + MULTILIB_EXCEPTIONS=
    1.86 + 
    1.87 + EXTRA_MULTILIB_PARTS= crtbegin.o crtend.o crtbeginS.o crtendS.o
    1.88 ++
    1.89 ++# Override t-slibgcc-elf-ver to export some libgcc symbols with
    1.90 ++# the symbol versions that glibc used.
    1.91 ++SHLIB_MAPFILES =  $(srcdir)/libgcc-std.ver $(srcdir)/config/sh/libgcc-glibc.ver
    1.92 ++
    1.93 ++# Override SHLIB_LINK and SHLIB_INSTALL to use linker script
    1.94 ++# libgcc_s.so.
    1.95 ++SHLIB_LINK = $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
    1.96 ++	-Wl,--soname=$(SHLIB_SONAME) \
    1.97 ++	-Wl,--version-script=$(SHLIB_MAP) \
    1.98 ++	-o $(SHLIB_NAME) @multilib_flags@ $(SHLIB_OBJS) $(SHLIB_LC) && \
    1.99 ++	rm -f $(SHLIB_SOLINK) && \
   1.100 ++	(echo "/* GNU ld script"; \
   1.101 ++	 echo "   Use the shared library, but some functions are only in"; \
   1.102 ++	 echo "   the static library.  */"; \
   1.103 ++	 echo "GROUP ( $(SHLIB_SONAME) libgcc.a )" \
   1.104 ++	) > $(SHLIB_SOLINK)
   1.105 ++SHLIB_INSTALL = \
   1.106 ++	$$(SHELL) $$(srcdir)/mkinstalldirs $$(slibdir)$(SHLIB_SLIBDIR_QUAL); \
   1.107 ++	$(INSTALL_DATA) $(SHLIB_NAME) \
   1.108 ++	  $$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SONAME); \
   1.109 ++	rm -f $$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK); \
   1.110 ++	$(INSTALL_DATA) $(SHLIB_SOLINK) \
   1.111 ++	  $$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK)
   1.112 +diff -u3prN ORIG/gcc-3.3/gcc/config.gcc gcc-3.3/gcc/config.gcc
   1.113 +--- ORIG/gcc-3.3/gcc/config.gcc	Sat Aug  9 07:19:07 2003
   1.114 ++++ gcc-3.3/gcc/config.gcc	Wed Nov 19 08:07:53 2003
   1.115 +@@ -2308,7 +2308,7 @@ sh-*-rtems*)
   1.116 + 	fi
   1.117 + 	;;
   1.118 + sh-*-linux* | sh[2346lbe]*-*-linux*)
   1.119 +-	tmake_file="sh/t-sh sh/t-elf"
   1.120 ++	tmake_file="sh/t-sh sh/t-elf t-slibgcc-elf-ver t-linux"
   1.121 + 	case $machine in
   1.122 + 	sh*be-*-* | sh*eb-*-*) ;;
   1.123 + 	*)
   1.124 +
   1.125 +