@@ -227,9 +227,6 @@ class Writer {
227
227
void markSymbolsForRVATable (ObjFile *file,
228
228
ArrayRef<SectionChunk *> symIdxChunks,
229
229
SymbolRVASet &tableSymbols);
230
- void getSymbolsFromSections (ObjFile *file,
231
- ArrayRef<SectionChunk *> symIdxChunks,
232
- std::vector<Symbol *> &symbols);
233
230
void maybeAddRVATable (SymbolRVASet tableSymbols, StringRef tableSym,
234
231
StringRef countSym);
235
232
void setSectionPermissions ();
@@ -608,9 +605,8 @@ void Writer::run() {
608
605
609
606
createImportTables ();
610
607
createSections ();
611
- appendImportThunks ();
612
- // Import thunks must be added before the Control Flow Guard tables are added.
613
608
createMiscChunks ();
609
+ appendImportThunks ();
614
610
createExportTable ();
615
611
mergeSections ();
616
612
removeUnusedSections ();
@@ -1622,8 +1618,6 @@ static void markSymbolsWithRelocations(ObjFile *file,
1622
1618
// table.
1623
1619
void Writer::createGuardCFTables () {
1624
1620
SymbolRVASet addressTakenSyms;
1625
- SymbolRVASet giatsRVASet;
1626
- std::vector<Symbol *> giatsSymbols;
1627
1621
SymbolRVASet longJmpTargets;
1628
1622
for (ObjFile *file : ObjFile::instances) {
1629
1623
// If the object was compiled with /guard:cf, the address taken symbols
@@ -1633,8 +1627,6 @@ void Writer::createGuardCFTables() {
1633
1627
// possibly address-taken.
1634
1628
if (file->hasGuardCF ()) {
1635
1629
markSymbolsForRVATable (file, file->getGuardFidChunks (), addressTakenSyms);
1636
- markSymbolsForRVATable (file, file->getGuardIATChunks (), giatsRVASet);
1637
- getSymbolsFromSections (file, file->getGuardIATChunks (), giatsSymbols);
1638
1630
markSymbolsForRVATable (file, file->getGuardLJmpChunks (), longJmpTargets);
1639
1631
} else {
1640
1632
markSymbolsWithRelocations (file, addressTakenSyms);
@@ -1649,16 +1641,6 @@ void Writer::createGuardCFTables() {
1649
1641
for (Export &e : config->exports )
1650
1642
maybeAddAddressTakenFunction (addressTakenSyms, e.sym );
1651
1643
1652
- // For each entry in the .giats table, check if it has a corresponding load
1653
- // thunk (e.g. because the DLL that defines it will be delay-loaded) and, if
1654
- // so, add the load thunk to the address taken (.gfids) table.
1655
- for (Symbol *s : giatsSymbols) {
1656
- if (auto *di = dyn_cast<DefinedImportData>(s)) {
1657
- if (di->loadThunkSym )
1658
- addSymbolToRVASet (addressTakenSyms, di->loadThunkSym );
1659
- }
1660
- }
1661
-
1662
1644
// Ensure sections referenced in the gfid table are 16-byte aligned.
1663
1645
for (const ChunkAndOffset &c : addressTakenSyms)
1664
1646
if (c.inputChunk ->getAlignment () < 16 )
@@ -1667,10 +1649,6 @@ void Writer::createGuardCFTables() {
1667
1649
maybeAddRVATable (std::move (addressTakenSyms), " __guard_fids_table" ,
1668
1650
" __guard_fids_count" );
1669
1651
1670
- // Add the Guard Address Taken IAT Entry Table (.giats).
1671
- maybeAddRVATable (std::move (giatsRVASet), " __guard_iat_table" ,
1672
- " __guard_iat_count" );
1673
-
1674
1652
// Add the longjmp target table unless the user told us not to.
1675
1653
if (config->guardCF == GuardCFLevel::Full)
1676
1654
maybeAddRVATable (std::move (longJmpTargets), " __guard_longjmp_table" ,
@@ -1687,11 +1665,11 @@ void Writer::createGuardCFTables() {
1687
1665
}
1688
1666
1689
1667
// Take a list of input sections containing symbol table indices and add those
1690
- // symbols to a vector . The challenge is that symbol RVAs are not known and
1668
+ // symbols to an RVA table . The challenge is that symbol RVAs are not known and
1691
1669
// depend on the table size, so we can't directly build a set of integers.
1692
- void Writer::getSymbolsFromSections (ObjFile *file,
1670
+ void Writer::markSymbolsForRVATable (ObjFile *file,
1693
1671
ArrayRef<SectionChunk *> symIdxChunks,
1694
- std::vector<Symbol *> &symbols ) {
1672
+ SymbolRVASet &tableSymbols ) {
1695
1673
for (SectionChunk *c : symIdxChunks) {
1696
1674
// Skip sections discarded by linker GC. This comes up when a .gfids section
1697
1675
// is associated with something like a vtable and the vtable is discarded.
@@ -1709,7 +1687,7 @@ void Writer::getSymbolsFromSections(ObjFile *file,
1709
1687
}
1710
1688
1711
1689
// Read each symbol table index and check if that symbol was included in the
1712
- // final link. If so, add it to the vector of symbols .
1690
+ // final link. If so, add it to the table symbol set .
1713
1691
ArrayRef<ulittle32_t > symIndices (
1714
1692
reinterpret_cast <const ulittle32_t *>(data.data ()), data.size () / 4 );
1715
1693
ArrayRef<Symbol *> objSymbols = file->getSymbols ();
@@ -1721,24 +1699,12 @@ void Writer::getSymbolsFromSections(ObjFile *file,
1721
1699
}
1722
1700
if (Symbol *s = objSymbols[symIndex]) {
1723
1701
if (s->isLive ())
1724
- symbols. push_back ( cast<Symbol >(s));
1702
+ addSymbolToRVASet (tableSymbols, cast<Defined >(s));
1725
1703
}
1726
1704
}
1727
1705
}
1728
1706
}
1729
1707
1730
- // Take a list of input sections containing symbol table indices and add those
1731
- // symbols to an RVA table.
1732
- void Writer::markSymbolsForRVATable (ObjFile *file,
1733
- ArrayRef<SectionChunk *> symIdxChunks,
1734
- SymbolRVASet &tableSymbols) {
1735
- std::vector<Symbol *> syms;
1736
- getSymbolsFromSections (file, symIdxChunks, syms);
1737
-
1738
- for (Symbol *s : syms)
1739
- addSymbolToRVASet (tableSymbols, cast<Defined>(s));
1740
- }
1741
-
1742
1708
// Replace the absolute table symbol with a synthetic symbol pointing to
1743
1709
// tableChunk so that we can emit base relocations for it and resolve section
1744
1710
// relative relocations.
0 commit comments