[PATCH] archives require a symbol table on Solaris, even if empty
Danek Duvall via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 8 16:50:16 PST 2017
Rafael Avila de Espindola wrote:
> Danek Duvall via llvm-commits <llvm-commits at lists.llvm.org> writes:
>
> > 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);
>
> I am OK with this. As far as I know no tool complains about an empty
> table, so this should make us strictly more portable.
>
> Please include a testcase and port the patch to svn. Please also make
> the description a bit more meaningful for outsiders by replacing 25243781
> with which solaris tools are impacted.
I've attached a new patch with an updated comment, a testcase, and an
archive, with a git-style patch. Let me know if there's a better way to do
this.
Thanks!
Danek
-------------- next part --------------
Index: lib/Object/ArchiveWriter.cpp
===================================================================
diff --git a/llvm/trunk/lib/Object/ArchiveWriter.cpp b/llvm/trunk/lib/Object/ArchiveWriter.cpp
--- a/llvm/trunk/lib/Object/ArchiveWriter.cpp (revision 297234)
+++ b/llvm/trunk/lib/Object/ArchiveWriter.cpp (working copy)
@@ -341,6 +341,11 @@
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.
Index: test/Object/Inputs/solaris-nosymbols.a
===================================================================
diff --git a/llvm/trunk/test/Object/Inputs/solaris-nosymbols.a b/llvm/trunk/test/Object/Inputs/solaris-nosymbols.a
new file mode 10644
GIT binary patch
literal 940
zc$`zTNi0gvu;bEKKm`UEYy%W=6S!;w7XuJvmF8vZ<?EyA!PIYN0?}z<U;)=(@9N{m
z#K_111B?uI3<w?qXdnqXKuHb;Rt5%lXJ;z~4R^m#O$Adu6FmbgdXWLh7#4<)|FOw2
zW3?G1&V)mp8HYFvrXV<wk{KBEiYs$V5|e;*NfCt3fU!zaD at qvjQW8rN8T68hiy8Ei
z^K)}k^GXPKi6|h=0P#B;nz#cF_2?m?2o*#3F|qp9ftZ5={W?%F^!SD87s8<*Mhimi
tRzOqt0ZN+^uph+7mI at -E^aLo)&HxEx4k%v&N^|0{{{@uhKodu|9{}|HHA?^h
literal 0
Hc$@<O00001
Index: test/Object/Inputs/solaris-nosymbols.a
===================================================================
diff --git a/llvm/trunk/test/Object/Inputs/solaris-nosymbols.a b/llvm/trunk/test/Object/Inputs/solaris-nosymbols.a
--- a/llvm/trunk/test/Object/Inputs/solaris-nosymbols.a (nonexistent)
+++ b/llvm/trunk/test/Object/Inputs/solaris-nosymbols.a (working copy)
Property changes on: llvm/trunk/test/Object/Inputs/solaris-nosymbols.a
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: test/Object/solaris-nosymbols.test
===================================================================
diff --git a/llvm/trunk/test/Object/solaris-nosymbols.test b/llvm/trunk/test/Object/solaris-nosymbols.test
new file mode 10644
--- /dev/null (nonexistent)
+++ b/llvm/trunk/test/Object/solaris-nosymbols.test (working copy)
@@ -0,0 +1,10 @@
+If an archive has no symbol table, the linker and some other tools on some
+versions of Solaris will abort operations. solaris-nosymbols.a is such an
+archive, and has no symbols, either. Make sure that llvm-ar, when
+rewriting it, includes an empty symbol table (by ensuring that the archive
+isn't identical).
+
+RUN: rm -f %t.a
+RUN: cp %S/Inputs/solaris-nosymbols.a %t.a
+RUN: llvm-ar rs %t.a
+RUN: not cmp %S/Inputs/solaris-nosymbols.a %t.a
More information about the llvm-commits
mailing list