This is the mail archive of the 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

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.

J. David Anglin                        
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2007-12-29  John David Anglin  <>

	* 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 SHLIB_SUFFIX ".so"
 #ifdef USE_COLLECT2
 int do_collecting = 1;
@@ -1868,9 +1872,9 @@
-	  if (strncmp (q, ".so", 3) == 0)
+	  if (strncmp (q, SHLIB_SUFFIX, strlen (SHLIB_SUFFIX)) == 0)
-	      q += 3;
+	      q += strlen (SHLIB_SUFFIX);
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.  */
+/* 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
+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]