This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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] Handle Mach-O sorted archives


Hi,

by default, on Darwin archives symbol table (armap) is sorted by name.  This is marked by a special
member name.  In order to correctly read these archives it is necessary to handle this special member name.

This could have been a 2 lines change if only they didn't chose a name with a blank ;-)

Tested on Darwin using ar t.

Tristan.

bfd/
2010-01-08  Tristan Gingold  <gingold@adacore.com>

	* archive.c (bfd_slurp_armap): Also check for Mach-O sorted armap.

diff --git a/bfd/archive.c b/bfd/archive.c
index 4d67463..354c868 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -1054,6 +1054,24 @@ bfd_slurp_armap (bfd *abfd)
       return FALSE;
 #endif
     }
+  else if (CONST_STRNEQ (nextname, "#1/20           "))
+    {
+      /* Mach-O has a special name for armap when the map is sorted by name.
+         However because this name has a space it is slightly more difficult
+         to check it.  */
+      struct ar_hdr hdr;
+      char extname[21];
+
+      if (bfd_bread (&hdr, sizeof (hdr), abfd) != sizeof (hdr))
+        return FALSE;
+      /* Read the extended name.  We know its length.  */
+      if (bfd_bread (extname, 20, abfd) != 20)
+        return FALSE;
+      if (bfd_seek (abfd, (file_ptr) -(sizeof (hdr) + 20), SEEK_CUR) != 0)
+        return FALSE;
+      if (CONST_STRNEQ (extname, "__.SYMDEF SORTED"))
+        return do_slurp_bsd_armap (abfd);
+    }
 
   bfd_has_map (abfd) = FALSE;
   return TRUE;


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