@@ -491,8 +491,9 @@ void LinkerDriver::parseDirectives(InputFile *file) {
491491 case OPT_entry:
492492 if (!arg->getValue ()[0 ])
493493 Fatal (ctx) << " missing entry point symbol name" ;
494- ctx.config .entry =
495- file->symtab .addGCRoot (file->symtab .mangle (arg->getValue ()), true );
494+ ctx.forEachSymtab ([&](SymbolTable &symtab) {
495+ symtab.entry = symtab.addGCRoot (symtab.mangle (arg->getValue ()), true );
496+ });
496497 break ;
497498 case OPT_failifmismatch:
498499 checkFailIfMismatch (arg->getValue (), file);
@@ -1394,8 +1395,9 @@ void LinkerDriver::createECExportThunks() {
13941395 }
13951396 }
13961397
1397- if (ctx.config .entry )
1398- maybeCreateECExportThunk (ctx.config .entry ->getName (), ctx.config .entry );
1398+ if (ctx.symtabEC ->entry )
1399+ maybeCreateECExportThunk (ctx.symtabEC ->entry ->getName (),
1400+ ctx.symtabEC ->entry );
13991401 for (Export &e : ctx.config .exports ) {
14001402 if (!e.data )
14011403 maybeCreateECExportThunk (e.extName .empty () ? e.name : e.extName , e.sym );
@@ -2357,33 +2359,32 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
23572359 }
23582360
23592361 // Handle /entry and /dll
2360- {
2362+ ctx. forEachSymtab ([&](SymbolTable &symtab) {
23612363 llvm::TimeTraceScope timeScope (" Entry point" );
23622364 if (auto *arg = args.getLastArg (OPT_entry)) {
23632365 if (!arg->getValue ()[0 ])
23642366 Fatal (ctx) << " missing entry point symbol name" ;
2365- config->entry =
2366- ctx.symtab .addGCRoot (ctx.symtab .mangle (arg->getValue ()), true );
2367- } else if (!config->entry && !config->noEntry ) {
2367+ symtab.entry = symtab.addGCRoot (symtab.mangle (arg->getValue ()), true );
2368+ } else if (!symtab.entry && !config->noEntry ) {
23682369 if (args.hasArg (OPT_dll)) {
23692370 StringRef s = (config->machine == I386) ? " __DllMainCRTStartup@12"
23702371 : " _DllMainCRTStartup" ;
2371- config-> entry = ctx. symtab .addGCRoot (s, true );
2372+ symtab. entry = symtab.addGCRoot (s, true );
23722373 } else if (config->driverWdm ) {
23732374 // /driver:wdm implies /entry:_NtProcessStartup
2374- config-> entry =
2375- ctx. symtab .addGCRoot (ctx. symtab .mangle (" _NtProcessStartup" ), true );
2375+ symtab. entry =
2376+ symtab.addGCRoot (symtab.mangle (" _NtProcessStartup" ), true );
23762377 } else {
23772378 // Windows specific -- If entry point name is not given, we need to
23782379 // infer that from user-defined entry name.
2379- StringRef s = ctx. symtab .findDefaultEntry ();
2380+ StringRef s = symtab.findDefaultEntry ();
23802381 if (s.empty ())
23812382 Fatal (ctx) << " entry point must be defined" ;
2382- config-> entry = ctx. symtab .addGCRoot (s, true );
2383+ symtab. entry = symtab.addGCRoot (s, true );
23832384 Log (ctx) << " Entry name inferred: " << s;
23842385 }
23852386 }
2386- }
2387+ });
23872388
23882389 // Handle /delayload
23892390 {
@@ -2522,10 +2523,12 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
25222523 {
25232524 llvm::TimeTraceScope timeScope (" Add unresolved symbols" );
25242525 do {
2525- // Windows specific -- if entry point is not found,
2526- // search for its mangled names.
2527- if (config->entry )
2528- ctx.symtab .mangleMaybe (config->entry );
2526+ ctx.forEachSymtab ([&](SymbolTable &symtab) {
2527+ // Windows specific -- if entry point is not found,
2528+ // search for its mangled names.
2529+ if (symtab.entry )
2530+ symtab.mangleMaybe (symtab.entry );
2531+ });
25292532
25302533 // Windows specific -- Make sure we resolve all dllexported symbols.
25312534 for (Export &e : config->exports ) {
0 commit comments