@@ -2229,54 +2229,19 @@ bool ObjectLinker::scanRelocations(bool IsPartialLink) {
22292229
22302230 getTargetBackend ().provideSymbols ();
22312231
2232+ // Slots are allocated as relocations are scanned in input order.
22322233 std::vector<std::unique_ptr<Relocator::CopyRelocs>> AllCopyRelocs;
2233- if (ThisConfig.options ().numThreads () <= 1 ||
2234- !ThisConfig.isScanRelocationsMultiThreaded ()) {
2235- if (ThisModule->getPrinter ()->traceThreads ())
2236- ThisConfig.raise (Diag::threads_disabled) << " ScanRelocations" ;
2237- for (auto &Input : ThisModule->getObjectList ()) {
2238- auto CopyRelocs = std::make_unique<Relocator::CopyRelocs>();
2239- scanRelocationsHelper (Input, IsPartialLink, PluginVect, *CopyRelocs);
2240- AllCopyRelocs.push_back (std::move (CopyRelocs));
2241- }
2242- } else {
2243- if (ThisModule->getPrinter ()->traceThreads ())
2244- ThisConfig.raise (Diag::threads_enabled)
2245- << " ScanRelocations" << ThisConfig.options ().numThreads ();
2246- llvm::ThreadPoolInterface *Pool = ThisModule->getThreadPool ();
2247- for (auto &Input : ThisModule->getObjectList ()) {
2248- auto CopyRelocs = std::make_unique<Relocator::CopyRelocs>();
2249- auto &CopyRelocsRef = *CopyRelocs; // must dereference in the main thread
2250- Pool->async ([&] {
2251- scanRelocationsHelper (Input, IsPartialLink, PluginVect, CopyRelocsRef);
2252- });
2253- AllCopyRelocs.push_back (std::move (CopyRelocs));
2254- }
2255- Pool->wait ();
2234+ for (auto &Input : ThisModule->getObjectList ()) {
2235+ auto CopyRelocs = std::make_unique<Relocator::CopyRelocs>();
2236+ scanRelocationsHelper (Input, IsPartialLink, PluginVect, *CopyRelocs);
2237+ AllCopyRelocs.push_back (std::move (CopyRelocs));
22562238 }
22572239 // assume there is only one copy relocation type per target
22582240 Relocation::Type CopyRelocType = getTargetBackend ().getCopyRelType ();
22592241 for (const auto &RelocVec : AllCopyRelocs)
22602242 for (auto &Reloc : *RelocVec)
22612243 createCopyRelocation (*Reloc, CopyRelocType);
22622244
2263- // Merge per-file relocations
2264- if (!IsPartialLink) {
2265- ELFObjectFile *RelocInput =
2266- getTargetBackend ().getDynamicSectionHeadersInputFile ();
2267- auto MergeRelocs = [](ELFSection &To, ELFSection &From) {
2268- To.appendRelocations (From.getRelocations ());
2269- };
2270- for (auto &Input : ThisModule->getObjectList ())
2271- if (ELFObjectFile *Obj = llvm::dyn_cast<ELFObjectFile>(Input))
2272- if (Obj != RelocInput) {
2273- if (const auto &S = Obj->getRelaDyn ())
2274- MergeRelocs (*RelocInput->getRelaDyn (), *S);
2275- if (const auto &S = Obj->getRelaPLT ())
2276- MergeRelocs (*RelocInput->getRelaPLT (), *S);
2277- }
2278- }
2279-
22802245 // If there is a undefined symbol, fail the link. No point fixing the
22812246 // relocations. This is overridden by --noinhibit-exec.
22822247 if (!ThisConfig.getDiagEngine ()->diagnose ()) {
0 commit comments