[PATCH] D36065: [llvm-dlltool] Write correct weak externals

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 01:48:00 PDT 2017


ruiu added inline comments.


================
Comment at: lib/Object/COFFImportFile.cpp:548
   //__imp_ String Table
-  if (Imp) {
-    SymbolTable[3].Name.Offset.Offset = sizeof(uint32_t) + Sym.size() + 7;
-    writeStringTable(Buffer, {std::string("__imp_").append(Sym),
-                              std::string("__imp_").append(Weak)});
-  } else {
-    SymbolTable[3].Name.Offset.Offset = sizeof(uint32_t) + Sym.size() + 1;
-    writeStringTable(Buffer, {Sym, Weak});
-  }
+  StringRef Prefix = Imp ? "__imp_" : "";
+  SymbolTable[3].Name.Offset.Offset = sizeof(uint32_t) + Sym.size() + Prefix.size() + 1;
----------------
mstorsjo wrote:
> ruiu wrote:
> > Use std::string instead of StringRef to avoid use of `str()`.
> I thought about that, but then the `append()` below would mutably alter it - `str()` intentionally gives a new mutable temporary for each of the `append()`s here.
Then a more natural way of doing it is `(Prefix + Sym).str()` instead of `Prefix.str().append(Sym)`.


https://reviews.llvm.org/D36065





More information about the llvm-commits mailing list