@@ -207,8 +207,8 @@ static StringRef mangle(Twine sym, MachineTypes machine) {
207207// This function instantiates wrapper symbols. At this point, they seem
208208// like they are not being used at all, so we explicitly set some flags so
209209// that LTO won't eliminate them.
210- std::vector<WrappedSymbol>
211- lld::coff::addWrappedSymbols (COFFLinkerContext &ctx, opt::InputArgList &args) {
210+ void lld::coff::addWrappedSymbols (SymbolTable &symtab,
211+ opt::InputArgList &args) {
212212 std::vector<WrappedSymbol> v;
213213 DenseSet<StringRef> seen;
214214
@@ -217,14 +217,14 @@ lld::coff::addWrappedSymbols(COFFLinkerContext &ctx, opt::InputArgList &args) {
217217 if (!seen.insert (name).second )
218218 continue ;
219219
220- Symbol *sym = ctx. symtab .findUnderscore (name);
220+ Symbol *sym = symtab.findUnderscore (name);
221221 if (!sym)
222222 continue ;
223223
224224 Symbol *real =
225- ctx. symtab .addUndefined (mangle (" __real_" + name, ctx. config .machine ));
225+ symtab.addUndefined (mangle (" __real_" + name, symtab .machine ));
226226 Symbol *wrap =
227- ctx. symtab .addUndefined (mangle (" __wrap_" + name, ctx. config .machine ));
227+ symtab.addUndefined (mangle (" __wrap_" + name, symtab .machine ));
228228 v.push_back ({sym, real, wrap});
229229
230230 // These symbols may seem undefined initially, but don't bail out
@@ -243,37 +243,36 @@ lld::coff::addWrappedSymbols(COFFLinkerContext &ctx, opt::InputArgList &args) {
243243 if (!isa<Undefined>(wrap))
244244 wrap->isUsedInRegularObj = true ;
245245 }
246- return v ;
246+ symtab. wrapped = std::move (v) ;
247247}
248248
249249// Do renaming for -wrap by updating pointers to symbols.
250250//
251251// When this function is executed, only InputFiles and symbol table
252252// contain pointers to symbol objects. We visit them to replace pointers,
253253// so that wrapped symbols are swapped as instructed by the command line.
254- void lld::coff::wrapSymbols (COFFLinkerContext &ctx,
255- ArrayRef<WrappedSymbol> wrapped) {
254+ void lld::coff::wrapSymbols (SymbolTable &symtab) {
256255 DenseMap<Symbol *, Symbol *> map;
257- for (const WrappedSymbol &w : wrapped) {
256+ for (const WrappedSymbol &w : symtab. wrapped ) {
258257 map[w.sym ] = w.wrap ;
259258 map[w.real ] = w.sym ;
260259 if (Defined *d = dyn_cast<Defined>(w.wrap )) {
261- Symbol *imp = ctx. symtab .find ((" __imp_" + w.sym ->getName ()).str ());
260+ Symbol *imp = symtab.find ((" __imp_" + w.sym ->getName ()).str ());
262261 // Create a new defined local import for the wrap symbol. If
263262 // no imp prefixed symbol existed, there's no need for it.
264263 // (We can't easily distinguish whether any object file actually
265264 // referenced it or not, though.)
266265 if (imp) {
267266 DefinedLocalImport *wrapimp = make<DefinedLocalImport>(
268- ctx, saver ().save (" __imp_" + w.wrap ->getName ()), d);
269- ctx. symtab .localImportChunks .push_back (wrapimp->getChunk ());
267+ symtab. ctx , saver ().save (" __imp_" + w.wrap ->getName ()), d);
268+ symtab.localImportChunks .push_back (wrapimp->getChunk ());
270269 map[imp] = wrapimp;
271270 }
272271 }
273272 }
274273
275274 // Update pointers in input files.
276- parallelForEach (ctx.objFileInstances , [&](ObjFile *file) {
275+ parallelForEach (symtab. ctx .objFileInstances , [&](ObjFile *file) {
277276 MutableArrayRef<Symbol *> syms = file->getMutableSymbols ();
278277 for (auto &sym : syms)
279278 if (Symbol *s = map.lookup (sym))
0 commit comments