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, committed] Export fewer symbols on AIX


	This patch addresses a couple of bug reports about problems
throwing exceptions on AIX.  On newer versions of AIX with linker support
for -binitfini commandline option, collect2 should not export the init and
fini functions.  Also, symbols found in other shared objects should not be
re-exported by the shared object or executable being linked.

David

	PR target/13391
	PR target/13878
	* collect2.c (main): Only export initfunc and finifunc if
	LD_INIT_SWITCH not defined.
	(scan_prog_file): Only export constructors and destructors if
	LD_INIT_SWITCH not defined.  Only export symbols not found in
	shared objects.

Index: collect2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/collect2.c,v
retrieving revision 1.160
diff -c -p -u -r1.160 collect2.c
--- collect2.c	21 Jan 2004 20:39:52 -0000	1.160
+++ collect2.c	4 Mar 2004 18:40:41 -0000
@@ -1398,10 +1398,12 @@ main (int argc, char **argv)
       if (! exports.first)
 	*ld2++ = concat ("-bE:", export_file, NULL);
 
+#ifndef LD_INIT_SWITCH
       add_to_list (&exports, initname);
       add_to_list (&exports, fininame);
       add_to_list (&exports, "_GLOBAL__DI");
       add_to_list (&exports, "_GLOBAL__DD");
+#endif
       exportf = fopen (export_file, "w");
       if (exportf == (FILE *) 0)
 	fatal_perror ("fopen %s", export_file);
@@ -2719,7 +2721,7 @@ scan_prog_file (const char *prog_name, e
 			case 1:
 			  if (! is_shared)
 			    add_to_list (&constructors, name);
-#ifdef COLLECT_EXPORT_LIST
+#if defined (COLLECT_EXPORT_LIST) && !defined (LD_INIT_SWITCH)
 			  if (which_pass == PASS_OBJ)
 			    add_to_list (&exports, name);
 #endif
@@ -2728,7 +2730,7 @@ scan_prog_file (const char *prog_name, e
 			case 2:
 			  if (! is_shared)
 			    add_to_list (&destructors, name);
-#ifdef COLLECT_EXPORT_LIST
+#if defined (COLLECT_EXPORT_LIST) && !defined (LD_INIT_SWITCH)
 			  if (which_pass == PASS_OBJ)
 			    add_to_list (&exports, name);
 #endif
@@ -2753,7 +2755,7 @@ scan_prog_file (const char *prog_name, e
 			case 5:
 			  if (! is_shared)
 			    add_to_list (&frame_tables, name);
-#ifdef COLLECT_EXPORT_LIST
+#if defined (COLLECT_EXPORT_LIST) && !defined (LD_INIT_SWITCH)
 			  if (which_pass == PASS_OBJ)
 			    add_to_list (&exports, name);
 #endif
@@ -2761,13 +2763,14 @@ scan_prog_file (const char *prog_name, e
 
 			default:	/* not a constructor or destructor */
 #ifdef COLLECT_EXPORT_LIST
-			  /* If we are building a shared object on AIX we need
-			     to explicitly export all global symbols.  */
-			  if (shared_obj)
-			    {
-			      if (which_pass == PASS_OBJ && (! export_flag))
-				add_to_list (&exports, name);
-			    }
+			  /* Explicitly export all global symbols when
+			     building a shared object on AIX, but do not
+			     re-export symbols from another shared object
+			     and do not export symbols if the user
+			     provides an explicit export list.  */
+			  if (shared_obj && !is_shared
+			      && which_pass == PASS_OBJ && !export_flag)
+			    add_to_list (&exports, name);
 #endif
 			  continue;
 			}


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