@@ -2288,49 +2288,53 @@ void Writer::createECChunks() {
22882288// uses for fixing them up, and provide the synthetic symbols that the
22892289// runtime uses for finding the table.
22902290void Writer::createRuntimePseudoRelocs () {
2291- std::vector<RuntimePseudoReloc> rels;
2291+ ctx.forEachSymtab ([&](SymbolTable &symtab) {
2292+ std::vector<RuntimePseudoReloc> rels;
22922293
2293- for (Chunk *c : ctx.driver .getChunks ()) {
2294- auto *sc = dyn_cast<SectionChunk>(c);
2295- if (!sc || !sc->live )
2296- continue ;
2297- // Don't create pseudo relocations for sections that won't be
2298- // mapped at runtime.
2299- if (sc->header ->Characteristics & IMAGE_SCN_MEM_DISCARDABLE)
2300- continue ;
2301- sc->getRuntimePseudoRelocs (rels);
2302- }
2294+ for (Chunk *c : ctx.driver .getChunks ()) {
2295+ auto *sc = dyn_cast<SectionChunk>(c);
2296+ if (!sc || !sc->live || &sc-> file -> symtab != &symtab )
2297+ continue ;
2298+ // Don't create pseudo relocations for sections that won't be
2299+ // mapped at runtime.
2300+ if (sc->header ->Characteristics & IMAGE_SCN_MEM_DISCARDABLE)
2301+ continue ;
2302+ sc->getRuntimePseudoRelocs (rels);
2303+ }
23032304
2304- if (!ctx.config .pseudoRelocs ) {
2305- // Not writing any pseudo relocs; if some were needed, error out and
2306- // indicate what required them.
2307- for (const RuntimePseudoReloc &rpr : rels)
2308- Err (ctx) << " automatic dllimport of " << rpr.sym ->getName () << " in "
2309- << toString (rpr.target ->file ) << " requires pseudo relocations" ;
2310- return ;
2311- }
2305+ if (!ctx.config .pseudoRelocs ) {
2306+ // Not writing any pseudo relocs; if some were needed, error out and
2307+ // indicate what required them.
2308+ for (const RuntimePseudoReloc &rpr : rels)
2309+ Err (ctx) << " automatic dllimport of " << rpr.sym ->getName () << " in "
2310+ << toString (rpr.target ->file )
2311+ << " requires pseudo relocations" ;
2312+ return ;
2313+ }
23122314
2313- if (!rels.empty ()) {
2314- Log (ctx) << " Writing " << rels.size () << " runtime pseudo relocations" ;
2315- const char *symbolName = " _pei386_runtime_relocator" ;
2316- Symbol *relocator = ctx.symtab .findUnderscore (symbolName);
2317- if (!relocator)
2318- Err (ctx)
2319- << " output image has runtime pseudo relocations, but the function "
2320- << symbolName
2321- << " is missing; it is needed for fixing the relocations at runtime" ;
2322- }
2315+ if (!rels.empty ()) {
2316+ Log (ctx) << " Writing " << Twine (rels.size ())
2317+ << " runtime pseudo relocations" ;
2318+ const char *symbolName = " _pei386_runtime_relocator" ;
2319+ Symbol *relocator = symtab.findUnderscore (symbolName);
2320+ if (!relocator)
2321+ Err (ctx)
2322+ << " output image has runtime pseudo relocations, but the function "
2323+ << symbolName
2324+ << " is missing; it is needed for fixing the relocations at "
2325+ " runtime" ;
2326+ }
23232327
2324- PseudoRelocTableChunk *table = make<PseudoRelocTableChunk>(rels);
2325- rdataSec->addChunk (table);
2326- EmptyChunk *endOfList = make<EmptyChunk>();
2327- rdataSec->addChunk (endOfList);
2328+ PseudoRelocTableChunk *table = make<PseudoRelocTableChunk>(rels);
2329+ rdataSec->addChunk (table);
2330+ EmptyChunk *endOfList = make<EmptyChunk>();
2331+ rdataSec->addChunk (endOfList);
23282332
2329- Symbol *headSym = ctx. symtab .findUnderscore (" __RUNTIME_PSEUDO_RELOC_LIST__" );
2330- Symbol *endSym =
2331- ctx. symtab . findUnderscore ( " __RUNTIME_PSEUDO_RELOC_LIST_END__ " );
2332- replaceSymbol<DefinedSynthetic>(headSym, headSym ->getName (), table );
2333- replaceSymbol<DefinedSynthetic>(endSym, endSym-> getName (), endOfList );
2333+ Symbol *headSym = symtab.findUnderscore (" __RUNTIME_PSEUDO_RELOC_LIST__" );
2334+ Symbol *endSym = symtab. findUnderscore ( " __RUNTIME_PSEUDO_RELOC_LIST_END__ " );
2335+ replaceSymbol<DefinedSynthetic>(headSym, headSym-> getName (), table );
2336+ replaceSymbol<DefinedSynthetic>(endSym, endSym ->getName (), endOfList );
2337+ } );
23342338}
23352339
23362340// MinGW specific.
0 commit comments