patches/gcc/3.3.2/sh-libgcc-hidden.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Jul 28 21:34:41 2007 +0000 (2007-07-28)
changeset 301 2be7232a73ac
permissions -rw-r--r--
Bump version to 0.2.2.
     1 [adjusted very slightly to apply to gcc-3.3.2 - dank]
     2 
     3 From: kaz Kojima <kkojima@rr.iij4u.or.jp>
     4 
     5 I've noticed one more problem about this issue.  In the testcase given
     6 by ZhouChang, libdemo.so exports __movstr_i4_even which is a function
     7 in libgcc.a. This itself is not a problem but it means that some functions
     8 in libgcc.a which should not be exported from shared objects might be
     9 exported from shared libs
    10 
    11 Date: Wed, 19 Nov 2003 09:04:12 +0900 (JST)
    12 From: kaz Kojima <kkojima@rr.iij4u.or.jp>
    13 Subject: [linux-sh:03096] Re: [linux]  Re: About tool chain in
    14  http://kegel.com/crosstool/
    15 To: dank@kegel.com
    16 Cc: zjuzhou@yahoo.com.cn, linux-sh@m17n.org, zhan_sh@yahoo.com.cn,
    17 	crossgcc@sources.redhat.com
    18 Message-Id: <20031119.090412.85413542.kkojima@rr.iij4u.or.jp>
    19 
    20 Hi,
    21 
    22 Dan Kegel <dank@kegel.com> wrote:
    23 > I'll try that, thanks.  I notice that the '.hidden' isn't in cvs yet.
    24 > I also notice you've been trying to get that into CVS for two years
    25 > now (http://gcc.gnu.org/ml/gcc-patches/2001-10/msg00053.html).
    26 > Time for another try?  It'd be nice if gcc-3.4 (and maybe even gcc-3.3.3)
    27 > didn't need a patch for this.
    28 
    29 The situation is a bit complicated. sh-linux target doesn't make
    30 shared libgcc in gcc-3.3.x.
    31 OTOH, I withdrew that .hidden patch because gcc-3.3 has a general
    32 mechanism to make all libgcc functions .hidden. But I missed that
    33 that mechanism was conditionalized later so that it's done only
    34 when the target creates the shared libgcc.
    35 In 3.4, sh-linux target becomes to use the shared libgcc like as
    36 all other linux targets, so there is no problem.
    37 
    38 I inclined to backport 3.4 shared libgcc stuff to 3.3.3 rather
    39 than the old .hidden patch. How do you think about it?
    40 I'm happy if you or ZhouChang create a PR on gcc bugzilla about
    41 this issue.
    42 
    43 Regards,
    44 	kaz
    45 --
    46 	This is a backport of 3.4 shared libgcc stuff to 3.3 branch.
    47 	* config.gcc (sh*-*-linux*): Add t-slibgcc-elf-ver and t-linux.
    48         to tmake_file.	* config/sh/libgcc-glibc.ver: New file.
    49 	* config/sh/t-linux (SHLIB_LINK): Override to use a linker script
    50 	libgcc_s.so.
    51 	(SHLIB_INSTALL): Likewise.
    52 
    53 diff -u3prN ORIG/gcc-3.3/gcc/config/sh/libgcc-glibc.ver gcc-3.3/gcc/config/sh/libgcc-glibc.ver
    54 --- ORIG/gcc-3.3/gcc/config/sh/libgcc-glibc.ver	Thu Jan  1 09:00:00 1970
    55 +++ gcc-3.3/gcc/config/sh/libgcc-glibc.ver	Wed Nov 19 08:15:16 2003
    56 @@ -0,0 +1,21 @@
    57 +# In order to work around the very problems that force us to now generally
    58 +# create a libgcc.so, glibc reexported a number of routines from libgcc.a.
    59 +# By now choosing the same version tags for these specific routines, we
    60 +# maintain enough binary compatibility to allow future versions of glibc
    61 +# to defer implementation of these routines to libgcc.so via DT_AUXILIARY.
    62 +
    63 +# Note that we cannot use the default libgcc-glibc.ver file on sh,
    64 +# because GLIBC_2.0 does not exist on this architecture, as the first 
    65 +# ever glibc release on the platform was GLIBC_2.2.
    66 +
    67 +%inherit GCC_3.0 GLIBC_2.2
    68 +GLIBC_2.2 {
    69 +  __register_frame
    70 +  __register_frame_table
    71 +  __deregister_frame
    72 +  __register_frame_info
    73 +  __deregister_frame_info
    74 +  __frame_state_for
    75 +  __register_frame_info_table
    76 +}
    77 +
    78 diff -u3prN ORIG/gcc-3.3/gcc/config/sh/t-linux gcc-3.3/gcc/config/sh/t-linux
    79 --- ORIG/gcc-3.3/gcc/config/sh/t-linux	Fri Jun  6 11:07:14 2003
    80 +++ gcc-3.3/gcc/config/sh/t-linux	Wed Nov 19 08:09:26 2003
    81 @@ -12,3 +12,27 @@ MULTILIB_MATCHES = 
    82  MULTILIB_EXCEPTIONS=
    83  
    84  EXTRA_MULTILIB_PARTS= crtbegin.o crtend.o crtbeginS.o crtendS.o
    85 +
    86 +# Override t-slibgcc-elf-ver to export some libgcc symbols with
    87 +# the symbol versions that glibc used.
    88 +SHLIB_MAPFILES =  $(srcdir)/libgcc-std.ver $(srcdir)/config/sh/libgcc-glibc.ver
    89 +
    90 +# Override SHLIB_LINK and SHLIB_INSTALL to use linker script
    91 +# libgcc_s.so.
    92 +SHLIB_LINK = $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
    93 +	-Wl,--soname=$(SHLIB_SONAME) \
    94 +	-Wl,--version-script=$(SHLIB_MAP) \
    95 +	-o $(SHLIB_NAME) @multilib_flags@ $(SHLIB_OBJS) $(SHLIB_LC) && \
    96 +	rm -f $(SHLIB_SOLINK) && \
    97 +	(echo "/* GNU ld script"; \
    98 +	 echo "   Use the shared library, but some functions are only in"; \
    99 +	 echo "   the static library.  */"; \
   100 +	 echo "GROUP ( $(SHLIB_SONAME) libgcc.a )" \
   101 +	) > $(SHLIB_SOLINK)
   102 +SHLIB_INSTALL = \
   103 +	$$(SHELL) $$(srcdir)/mkinstalldirs $$(slibdir)$(SHLIB_SLIBDIR_QUAL); \
   104 +	$(INSTALL_DATA) $(SHLIB_NAME) \
   105 +	  $$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SONAME); \
   106 +	rm -f $$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK); \
   107 +	$(INSTALL_DATA) $(SHLIB_SOLINK) \
   108 +	  $$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK)
   109 diff -u3prN ORIG/gcc-3.3/gcc/config.gcc gcc-3.3/gcc/config.gcc
   110 --- ORIG/gcc-3.3/gcc/config.gcc	Sat Aug  9 07:19:07 2003
   111 +++ gcc-3.3/gcc/config.gcc	Wed Nov 19 08:07:53 2003
   112 @@ -2308,7 +2308,7 @@ sh-*-rtems*)
   113  	fi
   114  	;;
   115  sh-*-linux* | sh[2346lbe]*-*-linux*)
   116 -	tmake_file="sh/t-sh sh/t-elf"
   117 +	tmake_file="sh/t-sh sh/t-elf t-slibgcc-elf-ver t-linux"
   118  	case $machine in
   119  	sh*be-*-* | sh*eb-*-*) ;;
   120  	*)
   121 
   122