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] Generalize stripping of shared library version in collect2


This is another patch that deals with constructor naming.  We need
to strip shared library version information when generating global
constructors for shared objects to main a consistent library interface
between library versions.

This patch adds the capability to define an arbitrary shared library
suffix.

Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.

Ok for trunk.  While this isn't a regression, it would be nice if
this change could be applied to 4.1 and 4.2.  It's really annoying
to have to relink all the applications linked against a shared
library when a minor library version change is made.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2007-12-29  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	* collect2.c (SHLIB_SUFFIX): Define if not defined.
	(write_c_file_stat): Use SHLIB_SUFFIX.
	* som.h (SHLIB_SUFFIX): Define.
	* doc/tm.texi (SHLIB_SUFFIX): Document.

Index: collect2.c
===================================================================
--- collect2.c	(revision 131213)
+++ collect2.c	(working copy)
@@ -129,6 +129,10 @@
 #define SCAN_LIBRARIES
 #endif
 
+#ifndef SHLIB_SUFFIX
+#define SHLIB_SUFFIX ".so"
+#endif
+
 #ifdef USE_COLLECT2
 int do_collecting = 1;
 #else
@@ -1868,9 +1872,9 @@
 	}
       else
 	{
-	  if (strncmp (q, ".so", 3) == 0)
+	  if (strncmp (q, SHLIB_SUFFIX, strlen (SHLIB_SUFFIX)) == 0)
 	    {
-	      q += 3;
+	      q += strlen (SHLIB_SUFFIX);
 	      break;
 	    }
 	  else
Index: config/pa/som.h
===================================================================
--- config/pa/som.h	(revision 131213)
+++ config/pa/som.h	(working copy)
@@ -335,3 +335,7 @@
 /* We can't handle weak aliases, and therefore can't support pragma weak.
    Suppress the use of pragma weak in gthr-dce.h and gthr-posix.h.  */
 #define GTHREAD_USE_WEAK 0
+
+/* Shared library suffix.  Collect2 strips the version string after
+   this suffix when generating constructor/destructor names.  */ 
+#define SHLIB_SUFFIX ".sl"
Index: doc/tm.texi
===================================================================
--- doc/tm.texi	(revision 131213)
+++ doc/tm.texi	(working copy)
@@ -7931,6 +7931,14 @@
 line.  Otherwise, it must set @var{ptr} to @code{NULL}.
 @end defmac
 
+@defmac SHLIB_SUFFIX
+Define this macro to a C string constant containing the default shared
+library extension of the target (e.g., @samp{".so"}).  @command{collect2}
+strips version information after this suffix when generating global
+constructor and destructor names.  This define is only needed on targets
+that use @command{collect2} to process constructors and destructors.
+@end defmac
+
 @node Instruction Output
 @subsection Output of Assembler Instructions
 


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