Skip to content

Commit 0efaad0

Browse files
committed
Revert "[LLD][COFF] Support CF guards on ARM64X (#128440)"
This reverts commit 14bab65. It causes lld-link to crash, posted repro at #128440 (comment).
1 parent 4959025 commit 0efaad0

File tree

2 files changed

+10
-145
lines changed

2 files changed

+10
-145
lines changed

lld/COFF/Writer.cpp

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,17 +1986,10 @@ static void maybeAddAddressTakenFunction(SymbolRVASet &addressTakenSyms,
19861986
// Common is always data, so it is ignored.
19871987
break;
19881988
case Symbol::DefinedAbsoluteKind:
1989+
case Symbol::DefinedSyntheticKind:
19891990
// Absolute is never code, synthetic generally isn't and usually isn't
19901991
// determinable.
19911992
break;
1992-
case Symbol::DefinedSyntheticKind:
1993-
// For EC export thunks, mark both the thunk itself and its target.
1994-
if (auto expChunk = dyn_cast_or_null<ECExportThunkChunk>(
1995-
cast<Defined>(s)->getChunk())) {
1996-
addSymbolToRVASet(addressTakenSyms, cast<Defined>(s));
1997-
addSymbolToRVASet(addressTakenSyms, expChunk->target);
1998-
}
1999-
break;
20001993
case Symbol::LazyArchiveKind:
20011994
case Symbol::LazyObjectKind:
20021995
case Symbol::LazyDLLSymbolKind:
@@ -2061,11 +2054,9 @@ void Writer::createGuardCFTables() {
20612054
// with /guard:cf.
20622055
for (ObjFile *file : ctx.objFileInstances) {
20632056
if (file->hasGuardCF()) {
2064-
ctx.forEachSymtab([&](SymbolTable &symtab) {
2065-
Symbol *flagSym = symtab.findUnderscore("__guard_flags");
2066-
cast<DefinedAbsolute>(flagSym)->setVA(
2067-
uint32_t(GuardFlags::CF_INSTRUMENTED));
2068-
});
2057+
Symbol *flagSym = ctx.symtab.findUnderscore("__guard_flags");
2058+
cast<DefinedAbsolute>(flagSym)->setVA(
2059+
uint32_t(GuardFlags::CF_INSTRUMENTED));
20692060
break;
20702061
}
20712062
}
@@ -2147,10 +2138,8 @@ void Writer::createGuardCFTables() {
21472138
guardFlags |= uint32_t(GuardFlags::CF_LONGJUMP_TABLE_PRESENT);
21482139
if (config->guardCF & GuardCFLevel::EHCont)
21492140
guardFlags |= uint32_t(GuardFlags::EH_CONTINUATION_TABLE_PRESENT);
2150-
ctx.forEachSymtab([guardFlags](SymbolTable &symtab) {
2151-
Symbol *flagSym = symtab.findUnderscore("__guard_flags");
2152-
cast<DefinedAbsolute>(flagSym)->setVA(guardFlags);
2153-
});
2141+
Symbol *flagSym = ctx.symtab.findUnderscore("__guard_flags");
2142+
cast<DefinedAbsolute>(flagSym)->setVA(guardFlags);
21542143
}
21552144

21562145
// Take a list of input sections containing symbol table indices and add those
@@ -2221,12 +2210,10 @@ void Writer::maybeAddRVATable(SymbolRVASet tableSymbols, StringRef tableSym,
22212210
tableChunk = make<RVATableChunk>(std::move(tableSymbols));
22222211
rdataSec->addChunk(tableChunk);
22232212

2224-
ctx.forEachSymtab([&](SymbolTable &symtab) {
2225-
Symbol *t = symtab.findUnderscore(tableSym);
2226-
Symbol *c = symtab.findUnderscore(countSym);
2227-
replaceSymbol<DefinedSynthetic>(t, t->getName(), tableChunk);
2228-
cast<DefinedAbsolute>(c)->setVA(tableChunk->getSize() / (hasFlag ? 5 : 4));
2229-
});
2213+
Symbol *t = ctx.symtab.findUnderscore(tableSym);
2214+
Symbol *c = ctx.symtab.findUnderscore(countSym);
2215+
replaceSymbol<DefinedSynthetic>(t, t->getName(), tableChunk);
2216+
cast<DefinedAbsolute>(c)->setVA(tableChunk->getSize() / (hasFlag ? 5 : 4));
22302217
}
22312218

22322219
// Create CHPE metadata chunks.

lld/test/COFF/arm64x-guardcf.s

Lines changed: 0 additions & 122 deletions
This file was deleted.

0 commit comments

Comments
 (0)