[llvm] r294557 - Object: pad BSD ar string table to 4-bytes

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 8 20:26:22 PST 2017


Author: compnerd
Date: Wed Feb  8 22:26:21 2017
New Revision: 294557

URL: http://llvm.org/viewvc/llvm-project?rev=294557&view=rev
Log:
Object: pad BSD ar string table to 4-bytes

cctools would pad the string table to a sizeof(int32_t) (explicitly
printed out by cctools rather than 4).  This adjusts the string table to
make it more compatible with cctools, but is insufficient to make ld64
happy.

Modified:
    llvm/trunk/lib/Object/ArchiveWriter.cpp

Modified: llvm/trunk/lib/Object/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ArchiveWriter.cpp?rev=294557&r1=294556&r2=294557&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ArchiveWriter.cpp (original)
+++ llvm/trunk/lib/Object/ArchiveWriter.cpp Wed Feb  8 22:26:21 2017
@@ -316,6 +316,10 @@ writeSymbolTable(raw_fd_ostream &Out, ob
   if (HeaderStartOffset == 0)
     return 0;
 
+  if (Kind == object::Archive::K_BSD)
+    for (unsigned P = OffsetToAlignment(NameOS.tell(), sizeof(int32_t)); P--;)
+      NameOS << '\0';
+
   StringRef StringTable = NameOS.str();
   if (Kind == object::Archive::K_BSD)
     print32(Out, Kind, StringTable.size()); // byte count of the string table




More information about the llvm-commits mailing list