diff options
Diffstat (limited to 'lld/ELF/Driver.cpp')
| -rw-r--r-- | lld/ELF/Driver.cpp | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 23e4116151b..c4d3bf223fc 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -946,21 +946,6 @@ static Optional<uint64_t> getImageBase(opt::InputArgList &Args) { return V; } -// Parses --defsym=alias option. -static std::vector<std::pair<StringRef, StringRef>> -getDefsym(opt::InputArgList &Args) { - std::vector<std::pair<StringRef, StringRef>> Ret; - for (auto *Arg : Args.filtered(OPT_defsym)) { - StringRef From; - StringRef To; - std::tie(From, To) = StringRef(Arg->getValue()).split('='); - if (!isValidCIdentifier(To)) - error("--defsym: symbol name expected, but got " + To); - Ret.push_back({From, To}); - } - return Ret; -} - // Parses `--exclude-libs=lib,lib,...`. // The library names may be delimited by commas or colons. static DenseSet<StringRef> getExcludeLibs(opt::InputArgList &Args) { @@ -1054,6 +1039,14 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) { for (InputFile *F : Files) Symtab->addFile<ELFT>(F); + // Process -defsym option. + for (auto *Arg : Args.filtered(OPT_defsym)) { + StringRef From; + StringRef To; + std::tie(From, To) = StringRef(Arg->getValue()).split('='); + readDefsym(From, MemoryBufferRef(To, "-defsym")); + } + // Now that we have every file, we can decide if we will need a // dynamic symbol table. // We need one if we were asked to export dynamic symbols or if we are @@ -1095,10 +1088,6 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) { for (auto *Arg : Args.filtered(OPT_wrap)) Symtab->addSymbolWrap<ELFT>(Arg->getValue()); - // Create alias symbols for -defsym option. - for (std::pair<StringRef, StringRef> &Def : getDefsym(Args)) - Symtab->addSymbolAlias<ELFT>(Def.first, Def.second); - Symtab->addCombinedLTOObject<ELFT>(); if (errorCount()) return; |

