Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -17,6 +17,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" +#include "llvm/Support/StringSaver.h" using namespace llvm; using namespace llvm::ELF; @@ -225,6 +226,14 @@ if (Config->OutputFile.empty()) Config->OutputFile = "a.out"; + llvm::BumpPtrAllocator Alloc; + llvm::StringSaver Saver(Alloc); + + for (auto *Arg : Args.filtered(OPT_wrap)) { + StringRef Sym = Arg->getValue(); + Symtab.wrap(Sym, Saver.save("__wrap_" + Sym), Saver.save("__real_" + Sym)); + } + // Write the result. const ELFFileBase *FirstObj = Symtab.getFirstELF(); switch (FirstObj->getELFKind()) { Index: ELF/Options.td =================================================================== --- ELF/Options.td +++ ELF/Options.td @@ -85,6 +85,9 @@ def z : JoinedOrSeparate<["-"], "z">, MetaVarName<"