@@ -227,9 +227,6 @@ class Writer {
227227 void markSymbolsForRVATable (ObjFile *file,
228228 ArrayRef<SectionChunk *> symIdxChunks,
229229 SymbolRVASet &tableSymbols);
230- void getSymbolsFromSections (ObjFile *file,
231- ArrayRef<SectionChunk *> symIdxChunks,
232- std::vector<Symbol *> &symbols);
233230 void maybeAddRVATable (SymbolRVASet tableSymbols, StringRef tableSym,
234231 StringRef countSym);
235232 void setSectionPermissions ();
@@ -608,9 +605,8 @@ void Writer::run() {
608605
609606 createImportTables ();
610607 createSections ();
611- appendImportThunks ();
612- // Import thunks must be added before the Control Flow Guard tables are added.
613608 createMiscChunks ();
609+ appendImportThunks ();
614610 createExportTable ();
615611 mergeSections ();
616612 removeUnusedSections ();
@@ -1622,8 +1618,6 @@ static void markSymbolsWithRelocations(ObjFile *file,
16221618// table.
16231619void Writer::createGuardCFTables () {
16241620 SymbolRVASet addressTakenSyms;
1625- SymbolRVASet giatsRVASet;
1626- std::vector<Symbol *> giatsSymbols;
16271621 SymbolRVASet longJmpTargets;
16281622 for (ObjFile *file : ObjFile::instances) {
16291623 // If the object was compiled with /guard:cf, the address taken symbols
@@ -1633,8 +1627,6 @@ void Writer::createGuardCFTables() {
16331627 // possibly address-taken.
16341628 if (file->hasGuardCF ()) {
16351629 markSymbolsForRVATable (file, file->getGuardFidChunks (), addressTakenSyms);
1636- markSymbolsForRVATable (file, file->getGuardIATChunks (), giatsRVASet);
1637- getSymbolsFromSections (file, file->getGuardIATChunks (), giatsSymbols);
16381630 markSymbolsForRVATable (file, file->getGuardLJmpChunks (), longJmpTargets);
16391631 } else {
16401632 markSymbolsWithRelocations (file, addressTakenSyms);
@@ -1649,16 +1641,6 @@ void Writer::createGuardCFTables() {
16491641 for (Export &e : config->exports )
16501642 maybeAddAddressTakenFunction (addressTakenSyms, e.sym );
16511643
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-
16621644 // Ensure sections referenced in the gfid table are 16-byte aligned.
16631645 for (const ChunkAndOffset &c : addressTakenSyms)
16641646 if (c.inputChunk ->getAlignment () < 16 )
@@ -1667,10 +1649,6 @@ void Writer::createGuardCFTables() {
16671649 maybeAddRVATable (std::move (addressTakenSyms), " __guard_fids_table" ,
16681650 " __guard_fids_count" );
16691651
1670- // Add the Guard Address Taken IAT Entry Table (.giats).
1671- maybeAddRVATable (std::move (giatsRVASet), " __guard_iat_table" ,
1672- " __guard_iat_count" );
1673-
16741652 // Add the longjmp target table unless the user told us not to.
16751653 if (config->guardCF == GuardCFLevel::Full)
16761654 maybeAddRVATable (std::move (longJmpTargets), " __guard_longjmp_table" ,
@@ -1687,11 +1665,11 @@ void Writer::createGuardCFTables() {
16871665}
16881666
16891667// 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
16911669// 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,
16931671 ArrayRef<SectionChunk *> symIdxChunks,
1694- std::vector<Symbol *> &symbols ) {
1672+ SymbolRVASet &tableSymbols ) {
16951673 for (SectionChunk *c : symIdxChunks) {
16961674 // Skip sections discarded by linker GC. This comes up when a .gfids section
16971675 // is associated with something like a vtable and the vtable is discarded.
@@ -1709,7 +1687,7 @@ void Writer::getSymbolsFromSections(ObjFile *file,
17091687 }
17101688
17111689 // 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 .
17131691 ArrayRef<ulittle32_t > symIndices (
17141692 reinterpret_cast <const ulittle32_t *>(data.data ()), data.size () / 4 );
17151693 ArrayRef<Symbol *> objSymbols = file->getSymbols ();
@@ -1721,24 +1699,12 @@ void Writer::getSymbolsFromSections(ObjFile *file,
17211699 }
17221700 if (Symbol *s = objSymbols[symIndex]) {
17231701 if (s->isLive ())
1724- symbols. push_back ( cast<Symbol >(s));
1702+ addSymbolToRVASet (tableSymbols, cast<Defined >(s));
17251703 }
17261704 }
17271705 }
17281706}
17291707
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-
17421708// Replace the absolute table symbol with a synthetic symbol pointing to
17431709// tableChunk so that we can emit base relocations for it and resolve section
17441710// relative relocations.
0 commit comments