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