]> granicus.if.org Git - llvm/commitdiff
Object: pad BSD ar string table to 4-bytes
authorSaleem Abdulrasool <compnerd@compnerd.org>
Thu, 9 Feb 2017 04:26:21 +0000 (04:26 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Thu, 9 Feb 2017 04:26:21 +0000 (04:26 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294557 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Object/ArchiveWriter.cpp

index f8e3c5a0a03f7f04ba14fe65ea291212776d0c82..ed4ef6a8df4a64854d917791842cc130f32291e8 100644 (file)
@@ -316,6 +316,10 @@ writeSymbolTable(raw_fd_ostream &Out, object::Archive::Kind Kind,
   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