[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#99307: libgcj/3419: unresolved symbols when gcj -static is used



On Wed, Jan 09, 2002 at 11:20:43PM +0100, Matthias Klose wrote:
> bryce@gcc.gnu.org writes:
> > Synopsis: unresolved symbols when gcj -static is used
> > 
> > State-Changed-From-To: open->closed
> > State-Changed-By: bryce
> > State-Changed-When: Sat Sep 29 22:50:20 2001
> > State-Changed-Why:
> >     Could not reproduce with 3.0.2 branch or current mainline.
> >     I suspect this was a mis-installed libgcj or a transient bug.
> > 
> > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3419&database=gcc
> 
> FYI, this is a binutils bug, see http://bugs.debian.org/107812 for
> more information, introduced by calling strip on libgcj.a

Fixed like this.  I'm committing this to mainline, and also to the
2.12 branch if/when Daniel likes the idea.

binutils/ChangeLog
	* objcopy.c (MKDIR): Define.
	(copy_archive): Make name_list.name const.  Use MKDIR.
	Handle duplicate files in archives by making more temp dirs.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

Index: binutils/objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.36
diff -u -p -r1.36 objcopy.c
--- objcopy.c	2002/01/25 15:37:02	1.36
+++ objcopy.c	2002/02/11 02:13:07
@@ -1268,6 +1268,13 @@ copy_object (ibfd, obfd)
     }
 }
 
+#undef MKDIR
+#if defined (_WIN32) && !defined (__CYGWIN32__)
+#define MKDIR(DIR, MODE) mkdir (DIR)
+#else
+#define MKDIR(DIR, MODE) mkdir (DIR, MODE)
+#endif
+
 /* Read each archive element in turn from IBFD, copy the
    contents to temp file, and keep the temp file handle.  */
 
@@ -1280,7 +1287,7 @@ copy_archive (ibfd, obfd, output_target)
   struct name_list
     {
       struct name_list *next;
-      char *name;
+      const char *name;
       bfd *obfd;
     } *list, *l;
   bfd **ptr = &obfd->archive_head;
@@ -1288,11 +1295,7 @@ copy_archive (ibfd, obfd, output_target)
   char *dir = make_tempname (bfd_get_filename (obfd));
 
   /* Make a temp directory to hold the contents.  */
-#if defined (_WIN32) && !defined (__CYGWIN32__)
-  if (mkdir (dir) != 0)
-#else
-  if (mkdir (dir, 0700) != 0)
-#endif
+  if (MKDIR (dir, 0700) != 0)
     {
       fatal (_("cannot mkdir %s for archive copying (error: %s)"),
 	     dir, strerror (errno));
@@ -1308,14 +1311,35 @@ copy_archive (ibfd, obfd, output_target)
 
   while (!status && this_element != (bfd *) NULL)
     {
-      /* Create an output file for this member.  */
-      char *output_name = concat (dir, "/", bfd_get_filename (this_element),
-				  (char *) NULL);
-      bfd *output_bfd = bfd_openw (output_name, output_target);
+      char *output_name;
+      bfd *output_bfd;
       bfd *last_element;
       struct stat buf;
       int stat_status = 0;
 
+      /* Create an output file for this member.  */
+      output_name = concat (dir, "/",
+			    bfd_get_filename (this_element), (char *) 0);
+
+      /* If the file already exists, make another temp dir.  */
+      if (stat (output_name, &buf) >= 0)
+	{
+	  output_name = make_tempname (output_name);
+	  if (MKDIR (output_name, 0700) != 0)
+	    {
+	      fatal (_("cannot mkdir %s for archive copying (error: %s)"),
+		     output_name, strerror (errno));
+	    }
+	  l = (struct name_list *) xmalloc (sizeof (struct name_list));
+	  l->name = output_name;
+	  l->next = list;
+	  l->obfd = NULL;
+	  list = l;
+	  output_name = concat (output_name, "/",
+				bfd_get_filename (this_element), (char *) 0);
+	}
+
+      output_bfd = bfd_openw (output_name, output_target);
       if (preserve_dates)
 	{
 	  stat_status = bfd_stat_arch_elt (this_element, &buf);
@@ -1371,8 +1395,13 @@ copy_archive (ibfd, obfd, output_target)
   /* Delete all the files that we opened.  */
   for (l = list; l != NULL; l = l->next)
     {
-      bfd_close (l->obfd);
-      unlink (l->name);
+      if (l->obfd == NULL)
+	rmdir (l->name);
+      else
+	{
+	  bfd_close (l->obfd);
+	  unlink (l->name);
+	}
     }
   rmdir (dir);
 }



Reply to: