[PATCH] archives require a symbol table on Solaris, even if empty

Danek Duvall via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 7 14:38:13 PST 2017


I ran into this bug with the Solaris linker where ld (and some other tools
that use the underlying utility libraries, such as elfdump) chokes on an
archive library that has no symbol table.  Our tools always create one,
even if it's empty.

That bug has been fixed in the latest development line, and can probably be
backported to a supported release, but it would be nice if LLVM's archiver
could emit the empty symbol table, too.

I've attached a patch that has been working for me in the context of the
copy of LLVM in the Rust project, though I've regenerated the patch against
SVN, just to be sure.

Let me know if there's any other process I need to follow to get this patch
landed.

Thanks,
Danek
-------------- next part --------------
Index: ArchiveWriter.cpp
===================================================================
--- ArchiveWriter.cpp	(revision 297234)
+++ ArchiveWriter.cpp	(working copy)
@@ -341,6 +341,10 @@
   if (isBSDLike(Kind))
     print32(Out, Kind, StringTable.size()); // byte count of the string table
   Out << StringTable;
+  // If there are no symbols, emit an empty symbol table, to satisfy Solaris
+  // tools prior to the fix for 25243781.
+  if (StringTable.size() == 0)
+    print32(Out, Kind, 0);
 
   // ld64 requires the next member header to start at an offset that is
   // 4 bytes aligned.


More information about the llvm-commits mailing list