[PATCH] D63739: [WebAssembly] Error out on archives without and index
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 25 10:56:11 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL364338: [WebAssembly] Error on archives without a symbol index (authored by sbc, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D63739?vs=206301&id=206485#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63739/new/
https://reviews.llvm.org/D63739
Files:
lld/trunk/test/wasm/archive-no-index.ll
lld/trunk/wasm/Driver.cpp
Index: lld/trunk/test/wasm/archive-no-index.ll
===================================================================
--- lld/trunk/test/wasm/archive-no-index.ll
+++ lld/trunk/test/wasm/archive-no-index.ll
@@ -0,0 +1,13 @@
+; Tests error on archive file without a symbol table
+; RUN: llvm-as -o %t.o %s
+; RUN: llvm-as -o %t.archive.o %S/Inputs/archive1.ll
+; RUN: rm -f %t.a
+; RUN: llvm-ar crS %t.a %t.archive.o
+
+; RUN: not wasm-ld -o out.wasm %t.o %t.a 2>&1 | FileCheck %s
+
+define i32 @_start() {
+ ret i32 0
+}
+
+; CHECK: archive has no index; run ranlib to add one
Index: lld/trunk/wasm/Driver.cpp
===================================================================
--- lld/trunk/wasm/Driver.cpp
+++ lld/trunk/wasm/Driver.cpp
@@ -225,6 +225,11 @@
switch (identify_magic(MBRef.getBuffer())) {
case file_magic::archive: {
+ SmallString<128> ImportFile = Path;
+ path::replace_extension(ImportFile, ".imports");
+ if (fs::exists(ImportFile))
+ readImportFile(ImportFile.str());
+
// Handle -whole-archive.
if (InWholeArchive) {
for (MemoryBufferRef &M : getArchiveMembers(MBRef))
@@ -232,10 +237,13 @@
return;
}
- SmallString<128> ImportFile = Path;
- path::replace_extension(ImportFile, ".imports");
- if (fs::exists(ImportFile))
- readImportFile(ImportFile.str());
+ std::unique_ptr<Archive> File =
+ CHECK(Archive::create(MBRef), Path + ": failed to parse archive");
+
+ if (!File->isEmpty() && !File->hasSymbolTable()) {
+ error(MBRef.getBufferIdentifier() +
+ ": archive has no index; run ranlib to add one");
+ }
Files.push_back(make<ArchiveFile>(MBRef));
return;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63739.206485.patch
Type: text/x-patch
Size: 1687 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190625/d1ffd887/attachment.bin>
More information about the llvm-commits
mailing list