@@ -1377,18 +1377,19 @@ void LinkerDriver::pullArm64ECIcallHelper() {
1377
1377
// explicitly specified. The automatic behavior can be disabled using the
1378
1378
// -exclude-all-symbols option, so that lld-link behaves like link.exe rather
1379
1379
// than MinGW in the case that nothing is explicitly exported.
1380
- void LinkerDriver::maybeExportMinGWSymbols (const opt::InputArgList &args) {
1380
+ void LinkerDriver::maybeExportMinGWSymbols (SymbolTable &symtab,
1381
+ const opt::InputArgList &args) {
1381
1382
if (!args.hasArg (OPT_export_all_symbols)) {
1382
1383
if (!ctx.config .dll )
1383
1384
return ;
1384
1385
1385
- if (!ctx. symtab .exports .empty ())
1386
+ if (!symtab.exports .empty ())
1386
1387
return ;
1387
1388
if (args.hasArg (OPT_exclude_all_symbols))
1388
1389
return ;
1389
1390
}
1390
1391
1391
- AutoExporter exporter (ctx , excludedSymbols);
1392
+ AutoExporter exporter (symtab , excludedSymbols);
1392
1393
1393
1394
for (auto *arg : args.filtered (OPT_wholearchive_file))
1394
1395
if (std::optional<StringRef> path = findFile (arg->getValue ()))
@@ -1398,10 +1399,10 @@ void LinkerDriver::maybeExportMinGWSymbols(const opt::InputArgList &args) {
1398
1399
SmallVector<StringRef, 2 > vec;
1399
1400
StringRef (arg->getValue ()).split (vec, ' ,' );
1400
1401
for (StringRef sym : vec)
1401
- exporter.addExcludedSymbol (ctx. symtab .mangle (sym));
1402
+ exporter.addExcludedSymbol (symtab.mangle (sym));
1402
1403
}
1403
1404
1404
- ctx. symtab .forEachSymbol ([&](Symbol *s) {
1405
+ symtab.forEachSymbol ([&](Symbol *s) {
1405
1406
auto *def = dyn_cast<Defined>(s);
1406
1407
if (!exporter.shouldExport (def))
1407
1408
return ;
@@ -1418,7 +1419,7 @@ void LinkerDriver::maybeExportMinGWSymbols(const opt::InputArgList &args) {
1418
1419
if (!(c->getOutputCharacteristics () & IMAGE_SCN_MEM_EXECUTE))
1419
1420
e.data = true ;
1420
1421
s->isUsedInRegularObj = true ;
1421
- ctx. symtab .exports .push_back (e);
1422
+ symtab.exports .push_back (e);
1422
1423
});
1423
1424
}
1424
1425
@@ -2613,14 +2614,14 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
2613
2614
if (errorCount ())
2614
2615
return ;
2615
2616
2616
- ctx.forEachSymtab ([](SymbolTable &symtab) {
2617
+ ctx.forEachSymtab ([& ](SymbolTable &symtab) {
2617
2618
symtab.hadExplicitExports = !symtab.exports .empty ();
2619
+ if (config->mingw ) {
2620
+ // In MinGW, all symbols are automatically exported if no symbols
2621
+ // are chosen to be exported.
2622
+ maybeExportMinGWSymbols (symtab, args);
2623
+ }
2618
2624
});
2619
- if (config->mingw ) {
2620
- // In MinGW, all symbols are automatically exported if no symbols
2621
- // are chosen to be exported.
2622
- maybeExportMinGWSymbols (args);
2623
- }
2624
2625
2625
2626
// Do LTO by compiling bitcode input files to a set of native COFF files then
2626
2627
// link those files (unless -thinlto-index-only was given, in which case we
0 commit comments