From deb154001d805a2ba5563cad58e55305483b65bc Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 7 Jan 2016 17:20:07 +0000 Subject: [PATCH] ELF: Implement --wrap. In this patch, all symbols are resolved normally and then wrap options are applied. Renaming is implemented by mutating `Body` pointers of Symbols. (As a result, Symtab.find(SymbolName)->getName() may return a string that's different from SymbolName, but that is by design. I designed the symbol and the symbol table to allow this kind of operations.) http://reviews.llvm.org/D15896 llvm-svn: 257075 --- lld/ELF/Driver.cpp | 3 +++ lld/ELF/Options.td | 4 ++++ lld/ELF/SymbolTable.cpp | 14 ++++++++++++++ lld/ELF/SymbolTable.h | 1 + lld/ELF/Symbols.h | 1 + lld/test/ELF/Inputs/wrap.s | 4 ++++ lld/test/ELF/wrap.s | 19 +++++++++++++++++++ 7 files changed, 46 insertions(+) create mode 100644 lld/test/ELF/Inputs/wrap.s create mode 100644 lld/test/ELF/wrap.s diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index da666cfb1107..12ad8ecac3ef 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -310,6 +310,9 @@ template void LinkerDriver::link(opt::InputArgList &Args) { for (StringRef S : Config->Undefined) Symtab.addUndefinedOpt(S); + for (auto *Arg : Args.filtered(OPT_wrap)) + Symtab.wrap(Arg->getValue()); + if (Config->OutputFile.empty()) Config->OutputFile = "a.out"; diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td index 622cbb93bf11..1b02c5c8b795 100644 --- a/lld/ELF/Options.td +++ b/lld/ELF/Options.td @@ -109,6 +109,9 @@ def verbose : Flag<["--"], "verbose">; def whole_archive : Flag<["--", "-"], "whole-archive">, HelpText<"Force load of all members in a static library">; +def wrap : Separate<["--", "-"], "wrap">, MetaVarName<"">, + HelpText<"Use wrapper functions for symbol">; + def z : JoinedOrSeparate<["-"], "z">, MetaVarName<"