[llvm] r186041 - Find the symbol table on archives created on OS X.

Rafael Espindola rafael.espindola at gmail.com
Wed Jul 10 15:08:00 PDT 2013


Author: rafael
Date: Wed Jul 10 17:07:59 2013
New Revision: 186041

URL: http://llvm.org/viewvc/llvm-project?rev=186041&view=rev
Log:
Find the symbol table on archives created on OS X.

Modified:
    llvm/trunk/lib/Object/Archive.cpp
    llvm/trunk/test/Object/nm-archive.test

Modified: llvm/trunk/lib/Object/Archive.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Archive.cpp?rev=186041&r1=186040&r2=186041&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Archive.cpp (original)
+++ llvm/trunk/lib/Object/Archive.cpp Wed Jul 10 17:07:59 2013
@@ -236,9 +236,9 @@ Archive::Archive(MemoryBuffer *source, e
   //  Second member : // (may exist, if it exists, points to the string table)
   //  Note : The string table is used if the filename exceeds 15 characters
   // BSD archive format
-  //  First member : __.SYMDEF (points to the symbol table)
-  //  There is no string table, if the filename exceeds 15 characters or has a 
-  //  embedded space, the filename has #1/<size>, The size represents the size 
+  //  First member : __.SYMDEF or "__.SYMDEF SORTED" (the symbol table)
+  //  There is no string table, if the filename exceeds 15 characters or has a
+  //  embedded space, the filename has #1/<size>, The size represents the size
   //  of the filename that needs to be read after the archive header
   // COFF archive format
   //  First member : /
@@ -256,6 +256,17 @@ Archive::Archive(MemoryBuffer *source, e
     return;
   }
 
+  if (Name.startswith("#1/")) {
+    Format = K_BSD;
+    // We know this is BSD, so getName will work since there is no string table.
+    ec = i->getName(Name);
+    if (ec)
+      return;
+    if (Name == StringRef("__.SYMDEF SORTED\0\0\0", 20))
+      SymbolTable = i;
+    return;
+  }
+
   if (Name == "/") {
     SymbolTable = i;
 

Modified: llvm/trunk/test/Object/nm-archive.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/nm-archive.test?rev=186041&r1=186040&r2=186041&view=diff
==============================================================================
--- llvm/trunk/test/Object/nm-archive.test (original)
+++ llvm/trunk/test/Object/nm-archive.test Wed Jul 10 17:07:59 2013
@@ -30,3 +30,10 @@ RUN: llvm-nm %p/Inputs/archive-test.a-gn
 
 And don't crash when asked to print a non existing symtab.
 RUN: llvm-nm -s %p/Inputs/archive-test.a-gnu-minimal
+
+
+Test that we at least find the symbol table on an OS X archive. Please update
+this when we are actually able to parse it.
+RUN: not llvm-nm -s %p/Inputs/MacOSX.a 2>&1 | FileCheck %s -check-prefix OSX
+
+OSX: BSD archive format is not supported





More information about the llvm-commits mailing list