[llvm] r183091 - [Object/COFF] Fix Windows .lib name handling.

Rui Ueyama ruiu at google.com
Sun Jun 2 17:27:04 PDT 2013


Author: ruiu
Date: Sun Jun  2 19:27:03 2013
New Revision: 183091

URL: http://llvm.org/viewvc/llvm-project?rev=183091&view=rev
Log:
[Object/COFF] Fix Windows .lib name handling.

Added:
    llvm/trunk/test/Object/Inputs/coff_archive_short.lib
    llvm/trunk/test/Object/coff-archive-short.test
Modified:
    llvm/trunk/lib/Object/Archive.cpp
    llvm/trunk/test/Object/Inputs/coff_archive.lib   (contents, props changed)

Modified: llvm/trunk/lib/Object/Archive.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Archive.cpp?rev=183091&r1=183090&r2=183091&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Archive.cpp (original)
+++ llvm/trunk/lib/Object/Archive.cpp Sun Jun  2 19:27:03 2013
@@ -132,8 +132,11 @@ Archive::Archive(MemoryBuffer *source, e
   // COFF archive format
   //  First member : /
   //  Second member : / (provides a directory of symbols)
-  //  Third member : // contains the string table, this is present even if the
-  //                    string table is empty
+  //  Third member : // (may exist, if it exists, contains the string table)
+  //  Note: Microsoft PE/COFF Spec 8.3 says that the third member is present
+  //  even if the string table is empty. However, lib.exe does not in fact
+  //  seem to create the third member if there's no member whose filename
+  //  exceeds 15 characters. So the third member is optional.
   if (name == "/") {
     SymbolTable = i;
     StringTable = e;
@@ -150,14 +153,17 @@ Archive::Archive(MemoryBuffer *source, e
       Format = K_GNU;
       StringTable = i;
       ++i;
-    } else  { 
+    } else {
       Format = K_COFF;
       if (i != e) {
         SymbolTable = i;
         ++i;
       }
       if (i != e) {
-        StringTable = i;
+        if ((ec = i->getName(name)))
+          return;
+        if (name == "//")
+          StringTable = i;
       }
     }
   } else if (name == "__.SYMDEF") {

Modified: llvm/trunk/test/Object/Inputs/coff_archive.lib
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/coff_archive.lib?rev=183091&r1=183090&r2=183091&view=diff
==============================================================================
Binary files - no diff available.

Propchange: llvm/trunk/test/Object/Inputs/coff_archive.lib
------------------------------------------------------------------------------
--- svn:executable (original)
+++ svn:executable (removed)
@@ -1 +0,0 @@
-*

Added: llvm/trunk/test/Object/Inputs/coff_archive_short.lib
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/coff_archive_short.lib?rev=183091&view=auto
==============================================================================
Binary files llvm/trunk/test/Object/Inputs/coff_archive_short.lib (added) and llvm/trunk/test/Object/Inputs/coff_archive_short.lib Sun Jun  2 19:27:03 2013 differ

Added: llvm/trunk/test/Object/coff-archive-short.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/coff-archive-short.test?rev=183091&view=auto
==============================================================================
--- llvm/trunk/test/Object/coff-archive-short.test (added)
+++ llvm/trunk/test/Object/coff-archive-short.test Sun Jun  2 19:27:03 2013
@@ -0,0 +1,26 @@
+#
+# Check if the index is appearing properly in the output file
+#
+# coff_archive_short.lib does not have member whose name is longer
+# than 15 characters, thus, unlike coff_archive.lib, it has no string
+# table as the third member.
+#
+RUN: llvm-nm --numeric-sort -s %p/Inputs/coff_archive_short.lib | FileCheck -check-prefix=CHECKIDX %s
+
+CHECKIDX: Archive map
+CHECKIDX: _shortfn1 in short1.obj
+CHECKIDX: _shortfn2 in short2.obj
+CHECKIDX: short1.obj:
+CHECKIDX: 00000000 N .debug$S
+CHECKIDX: 00000000 i .drectve
+CHECKIDX: 00000000 t .text
+CHECKIDX: 00000000 T _shortfn1
+CHECKIDX: 00000001 a @feat.00
+CHECKIDX: 00aa9d1b a @comp.id
+CHECKIDX: short2.obj:
+CHECKIDX: 00000000 N .debug$S
+CHECKIDX: 00000000 i .drectve
+CHECKIDX: 00000000 t .text
+CHECKIDX: 00000000 T _shortfn2
+CHECKIDX: 00000001 a @feat.00
+CHECKIDX: 00aa9d1b a @comp.id





More information about the llvm-commits mailing list