@@ -1537,7 +1537,7 @@ void PDBLinker::addImportFilesToPDB() {
1537
1537
if (!file->thunkSym )
1538
1538
continue ;
1539
1539
1540
- if (!file->thunkSym ->isLive ())
1540
+ if (!file->thunkSym ->isLive () && !file-> impchkThunk )
1541
1541
continue ;
1542
1542
1543
1543
std::string dll = StringRef (file->dllName ).lower ();
@@ -1562,53 +1562,61 @@ void PDBLinker::addImportFilesToPDB() {
1562
1562
mod->setObjFileName (libPath);
1563
1563
}
1564
1564
1565
- DefinedImportThunk *thunk = cast<DefinedImportThunk>(file->thunkSym );
1566
- Chunk *thunkChunk = thunk->getChunk ();
1567
- OutputSection *thunkOS = ctx.getOutputSection (thunkChunk);
1568
-
1569
1565
ObjNameSym ons (SymbolRecordKind::ObjNameSym);
1570
1566
Compile3Sym cs (SymbolRecordKind::Compile3Sym);
1571
- Thunk32Sym ts (SymbolRecordKind::Thunk32Sym);
1572
- ScopeEndSym es (SymbolRecordKind::ScopeEndSym);
1573
1567
1574
1568
ons.Name = file->dllName ;
1575
1569
ons.Signature = 0 ;
1576
1570
1577
1571
fillLinkerVerRecord (cs, ctx.config .machine );
1578
1572
1579
- ts.Name = thunk->getName ();
1580
- ts.Parent = 0 ;
1581
- ts.End = 0 ;
1582
- ts.Next = 0 ;
1583
- ts.Thunk = ThunkOrdinal::Standard;
1584
- ts.Length = thunkChunk->getSize ();
1585
- ts.Segment = thunkOS->sectionIndex ;
1586
- ts.Offset = thunkChunk->getRVA () - thunkOS->getRVA ();
1587
-
1588
1573
llvm::BumpPtrAllocator &bAlloc = lld::bAlloc ();
1589
1574
mod->addSymbol (codeview::SymbolSerializer::writeOneSymbol (
1590
1575
ons, bAlloc, CodeViewContainer::Pdb));
1591
1576
mod->addSymbol (codeview::SymbolSerializer::writeOneSymbol (
1592
1577
cs, bAlloc, CodeViewContainer::Pdb));
1593
1578
1594
- CVSymbol newSym = codeview::SymbolSerializer::writeOneSymbol (
1595
- ts, bAlloc, CodeViewContainer::Pdb);
1579
+ auto addThunk = [&](Symbol *sym, Chunk *chunk) {
1580
+ OutputSection *thunkOS = ctx.getOutputSection (chunk);
1581
+
1582
+ Thunk32Sym ts (SymbolRecordKind::Thunk32Sym);
1583
+ ScopeEndSym es (SymbolRecordKind::ScopeEndSym);
1584
+
1585
+ ts.Name = sym->getName ();
1586
+ ts.Parent = 0 ;
1587
+ ts.End = 0 ;
1588
+ ts.Next = 0 ;
1589
+ ts.Thunk = ThunkOrdinal::Standard;
1590
+ ts.Length = chunk->getSize ();
1591
+ ts.Segment = thunkOS->sectionIndex ;
1592
+ ts.Offset = chunk->getRVA () - thunkOS->getRVA ();
1596
1593
1597
- // Write ptrEnd for the S_THUNK32.
1598
- ScopeRecord *thunkSymScope =
1599
- getSymbolScopeFields (const_cast <uint8_t *>(newSym.data ().data ()));
1594
+ CVSymbol newSym = codeview::SymbolSerializer::writeOneSymbol (
1595
+ ts, bAlloc, CodeViewContainer::Pdb);
1600
1596
1601
- mod->addSymbol (newSym);
1597
+ // Write ptrEnd for the S_THUNK32.
1598
+ ScopeRecord *thunkSymScope =
1599
+ getSymbolScopeFields (const_cast <uint8_t *>(newSym.data ().data ()));
1602
1600
1603
- newSym = codeview::SymbolSerializer::writeOneSymbol (es, bAlloc,
1604
- CodeViewContainer::Pdb);
1605
- thunkSymScope->ptrEnd = mod->getNextSymbolOffset ();
1601
+ mod->addSymbol (newSym);
1606
1602
1607
- mod->addSymbol (newSym);
1603
+ newSym = codeview::SymbolSerializer::writeOneSymbol (
1604
+ es, bAlloc, CodeViewContainer::Pdb);
1605
+ thunkSymScope->ptrEnd = mod->getNextSymbolOffset ();
1606
+
1607
+ mod->addSymbol (newSym);
1608
+
1609
+ pdb::SectionContrib sc =
1610
+ createSectionContrib (ctx, chunk, mod->getModuleIndex ());
1611
+ mod->setFirstSectionContrib (sc);
1612
+ };
1608
1613
1609
- pdb::SectionContrib sc =
1610
- createSectionContrib (ctx, thunk->getChunk (), mod->getModuleIndex ());
1611
- mod->setFirstSectionContrib (sc);
1614
+ if (file->auxThunkSym && file->auxThunkSym ->isLive ())
1615
+ addThunk (file->thunkSym , file->auxThunkSym ->getChunk ());
1616
+ if (file->impchkThunk )
1617
+ addThunk (file->impchkThunk ->sym , file->impchkThunk );
1618
+ if (file->thunkSym ->isLive ())
1619
+ addThunk (file->thunkSym , file->thunkSym ->getChunk ());
1612
1620
}
1613
1621
}
1614
1622
0 commit comments