summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/ArchiveWriter.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2017-03-14 19:57:13 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2017-03-14 19:57:13 +0000
commit8f2dd7c042bd6776cffee9bc9c916ab1151a9cdc (patch)
tree4cbe1458f21f8ff22b2f0aa6743f7ffa76a743a2 /llvm/lib/Object/ArchiveWriter.cpp
parentc32a1bdd5f0cf76200a980540ef5688a4ab3e332 (diff)
downloadbcm5719-llvm-8f2dd7c042bd6776cffee9bc9c916ab1151a9cdc.tar.gz
bcm5719-llvm-8f2dd7c042bd6776cffee9bc9c916ab1151a9cdc.zip
Archives require a symbol table on Solaris, even if empty.
On Solaris ld (and some other tools that use the underlying utility libraries, such as elfdump) chokes on an archive library that has no symbol table. The Solaris 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. Patch by Danek Duvall! llvm-svn: 297773
Diffstat (limited to 'llvm/lib/Object/ArchiveWriter.cpp')
-rw-r--r--llvm/lib/Object/ArchiveWriter.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Object/ArchiveWriter.cpp b/llvm/lib/Object/ArchiveWriter.cpp
index 83fbf2f5854..d5ff2dbf7be 100644
--- a/llvm/lib/Object/ArchiveWriter.cpp
+++ b/llvm/lib/Object/ArchiveWriter.cpp
@@ -341,6 +341,11 @@ writeSymbolTable(raw_fd_ostream &Out, object::Archive::Kind Kind,
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, older versions of which expect a symbol table in a non-empty
+ // archive, regardless of whether there are any symbols in it.
+ if (StringTable.size() == 0)
+ print32(Out, Kind, 0);
// ld64 requires the next member header to start at an offset that is
// 4 bytes aligned.
OpenPOWER on IntegriCloud