This is the mail archive of the gcc-bugs@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]

[Bug target/13391] AIX: collect2 emits bad code with duplicated symbols


------- Additional Comments From ajd at gentrack dot com  2004-03-04 01:56 -------
(In reply to comment #17)
> > 	Can you try the appended patch that disables exporting _GLOBAL_*
> > symbols in AIX shared libraries?
> > Thanks, David

I still have not managed a full bootstrap with your patch (ETA 12hours -- but 
that is a separate issue).

However I applied the following patch (in all it's glory) to collect2 and used 
this version with a previously complied gcc.
I did not relink libstdc++.a.

After relinking my libraries with this new collect, my exceptions are working 
perfectly.

Thanks,
Andrew

*** gcc-3.3.2/gcc/collect2.c    Thu Oct  2 02:08:34 2003
--- ../gcc-3.3.2/gcc/collect2.c Fri Mar  5 04:20:56 2004
***************
*** 1435,1444 ****
--- 1435,1446 ----
        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);
***************
*** 2733,2743 ****
--- 2735,2755 ----
  #ifdef COLLECT_EXPORT_LIST
              /* Is current archive member a shared object?  */
              is_shared = HEADER (ldptr).f_flags & F_SHROBJ;
+               /* On aix we get a second object in libstdc++.a which is 
+                  in the shared library, but not marked with F_SHROBJ.
+ 
+                  Should we only set is_shared the first time through 
+                  this loop?
+                 */
+               if (!is_shared && strstr(prog_name, "libstdc++")) {
+                       is_shared = 1;
+               }
  #endif
  
              while (sym_index < sym_count)
                {
                  GCC_SYMENT symbol;
+               int t;
  
                  if (ldtbread (ldptr, sym_index, &symbol) <= 0)
                    break;
***************
*** 2757,2769 ****
                        ++name;
  #endif
  
!                     switch (is_ctor_dtor (name))
                        {
                        case 1:
                          if (! is_shared)
                            add_to_list (&constructors, name);
  #ifdef COLLECT_EXPORT_LIST
!                         if (which_pass == PASS_OBJ)
                            add_to_list (&exports, name);
  #endif
                          break;
--- 2769,2784 ----
                        ++name;
  #endif
  
!                     t = (is_ctor_dtor (name));
!               if (debug)      printf("symbol:%s type:%i is_shared:%i 
prog_name:%s\n", name, t, is_shared, prog_name);
! 
!                     switch (t)
                        {
                        case 1:
                          if (! is_shared)
                            add_to_list (&constructors, name);
  #ifdef COLLECT_EXPORT_LIST
!                         if ((!is_shared) && which_pass == PASS_OBJ)
                            add_to_list (&exports, name);
  #endif
                          break;
***************
*** 2772,2778 ****
                          if (! is_shared)
                            add_to_list (&destructors, name);
  #ifdef COLLECT_EXPORT_LIST
!                         if (which_pass == PASS_OBJ)
                            add_to_list (&exports, name);
  #endif
                          break;
--- 2787,2793 ----
                          if (! is_shared)
                            add_to_list (&destructors, name);
  #ifdef COLLECT_EXPORT_LIST
!                         if ((!is_shared) && which_pass == PASS_OBJ)
                            add_to_list (&exports, name);
  #endif
                          break;
***************
*** 2797,2803 ****
                          if (! is_shared)
                            add_to_list (&frame_tables, name);
  #ifdef COLLECT_EXPORT_LIST
!                         if (which_pass == PASS_OBJ)
                            add_to_list (&exports, name);
  #endif
                          break;
--- 2812,2818 ----
                          if (! is_shared)
                            add_to_list (&frame_tables, name);
  #ifdef COLLECT_EXPORT_LIST
!                         if ((!is_shared) && which_pass == PASS_OBJ)
                            add_to_list (&exports, name);
  #endif
                          break;
***************
*** 2806,2812 ****
  #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);
--- 2821,2827 ----
  #ifdef COLLECT_EXPORT_LIST
                          /* If we are building a shared object on AIX we need
                             to explicitly export all global symbols.  */
!                         if (shared_obj && !is_shared) 
                            {
                              if (which_pass == PASS_OBJ && (! export_flag))
                                add_to_list (&exports, name);

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13391


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