[PATCH] D67676: [lld][WebAssembly] Fix use after free of archive path

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 17 13:02:06 PDT 2019


sbc100 created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff.
Herald added a project: LLVM.
sbc100 added a reviewer: ruiu.

This was fixed in the ELF backend in https://reviews.llvm.org/D34554.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67676

Files:
  lld/wasm/Driver.cpp
  lld/wasm/InputFiles.h


Index: lld/wasm/InputFiles.h
===================================================================
--- lld/wasm/InputFiles.h
+++ lld/wasm/InputFiles.h
@@ -54,7 +54,7 @@
   Kind kind() const { return fileKind; }
 
   // An archive file name if this file is created from an archive.
-  StringRef archiveName;
+  std::string archiveName;
 
   ArrayRef<Symbol *> getSymbols() const { return symbols; }
 
Index: lld/wasm/Driver.cpp
===================================================================
--- lld/wasm/Driver.cpp
+++ lld/wasm/Driver.cpp
@@ -229,6 +229,7 @@
     path::replace_extension(importFile, ".imports");
     if (fs::exists(importFile))
       readImportFile(importFile.str());
+    dbgs() << "new archive: " << mbref.getBufferIdentifier() << "\n";
 
     // Handle -whole-archive.
     if (inWholeArchive) {
@@ -245,7 +246,9 @@
             ": archive has no index; run ranlib to add one");
     }
 
-    files.push_back(make<ArchiveFile>(mbref));
+    auto* F = make<ArchiveFile>(mbref);
+    dbgs() << "new archive: " << F->getName() << "\n";
+    files.push_back(F);
     return;
   }
   case file_magic::bitcode:
@@ -259,6 +262,7 @@
 
 // Add a given library by searching it from input search paths.
 void LinkerDriver::addLibrary(StringRef name) {
+  dbgs()  << "XXX\n";
   for (StringRef dir : config->searchPaths) {
     if (Optional<std::string> s = findFile(dir, "lib" + name + ".a")) {
       addFile(*s);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67676.220560.patch
Type: text/x-patch
Size: 1428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190917/ac44f949/attachment.bin>


More information about the llvm-commits mailing list