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