Skip to content

Commit c7d776b

Browse files
authored
Revert "[BOLT][AArch64] Handle OpNegateRAState to enable optimizing binaries with pac-ret hardening" (#162353)
Reverts #120064. @gulfemsavrun reported that the patch broke toolchain builders.
1 parent 605e2d1 commit c7d776b

25 files changed

+27
-1241
lines changed

bolt/docs/PacRetDesign.md

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

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,6 @@ class BinaryFunction {
148148
PF_MEMEVENT = 4, /// Profile has mem events.
149149
};
150150

151-
void setContainedNegateRAState() { HadNegateRAState = true; }
152-
bool containedNegateRAState() const { return HadNegateRAState; }
153-
void setInitialRAState(bool State) { InitialRAState = State; }
154-
bool getInitialRAState() { return InitialRAState; }
155-
156151
/// Struct for tracking exception handling ranges.
157152
struct CallSite {
158153
const MCSymbol *Start;
@@ -223,12 +218,6 @@ class BinaryFunction {
223218
/// Current state of the function.
224219
State CurrentState{State::Empty};
225220

226-
/// Indicates if the Function contained .cfi-negate-ra-state. These are not
227-
/// read from the binary. This boolean is used when deciding to run the
228-
/// .cfi-negate-ra-state rewriting passes on a function or not.
229-
bool HadNegateRAState{false};
230-
bool InitialRAState{false};
231-
232221
/// A list of symbols associated with the function entry point.
233222
///
234223
/// Multiple symbols would typically result from identical code-folding
@@ -1651,51 +1640,6 @@ class BinaryFunction {
16511640

16521641
void setHasInferredProfile(bool Inferred) { HasInferredProfile = Inferred; }
16531642

1654-
/// Find corrected offset the same way addCFIInstruction does it to skip NOPs.
1655-
std::optional<uint64_t> getCorrectedCFIOffset(uint64_t Offset) {
1656-
assert(!Instructions.empty());
1657-
auto I = Instructions.lower_bound(Offset);
1658-
if (Offset == getSize()) {
1659-
assert(I == Instructions.end() && "unexpected iterator value");
1660-
// Sometimes compiler issues restore_state after all instructions
1661-
// in the function (even after nop).
1662-
--I;
1663-
Offset = I->first;
1664-
}
1665-
assert(I->first == Offset && "CFI pointing to unknown instruction");
1666-
if (I == Instructions.begin())
1667-
return {};
1668-
1669-
--I;
1670-
while (I != Instructions.begin() && BC.MIB->isNoop(I->second)) {
1671-
Offset = I->first;
1672-
--I;
1673-
}
1674-
return Offset;
1675-
}
1676-
1677-
void setInstModifiesRAState(uint8_t CFIOpcode, uint64_t Offset) {
1678-
std::optional<uint64_t> CorrectedOffset = getCorrectedCFIOffset(Offset);
1679-
if (CorrectedOffset) {
1680-
auto I = Instructions.lower_bound(*CorrectedOffset);
1681-
I--;
1682-
1683-
switch (CFIOpcode) {
1684-
case dwarf::DW_CFA_AARCH64_negate_ra_state:
1685-
BC.MIB->setNegateRAState(I->second);
1686-
break;
1687-
case dwarf::DW_CFA_remember_state:
1688-
BC.MIB->setRememberState(I->second);
1689-
break;
1690-
case dwarf::DW_CFA_restore_state:
1691-
BC.MIB->setRestoreState(I->second);
1692-
break;
1693-
default:
1694-
assert(0 && "CFI Opcode not covered by function");
1695-
}
1696-
}
1697-
}
1698-
16991643
void addCFIInstruction(uint64_t Offset, MCCFIInstruction &&Inst) {
17001644
assert(!Instructions.empty());
17011645

bolt/include/bolt/Core/MCPlus.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,7 @@ class MCAnnotation {
7272
kLabel, /// MCSymbol pointing to this instruction.
7373
kSize, /// Size of the instruction.
7474
kDynamicBranch, /// Jit instruction patched at runtime.
75-
kRASigned, /// Inst is in a range where RA is signed.
76-
kRAUnsigned, /// Inst is in a range where RA is unsigned.
77-
kRememberState, /// Inst has rememberState CFI.
78-
kRestoreState, /// Inst has restoreState CFI.
79-
kNegateState, /// Inst has OpNegateRAState CFI.
80-
kGeneric, /// First generic annotation.
75+
kGeneric /// First generic annotation.
8176
};
8277

8378
virtual void print(raw_ostream &OS) const = 0;

0 commit comments

Comments
 (0)