@@ -34,9 +34,6 @@ void InsertNegateRAState::runOnFunction(BinaryFunction &BF) {
3434 return ;
3535 }
3636
37- // Attach .cfi_negate_ra_state to the "trivial" cases first.
38- addNegateRAStateAfterPSignOrPAuth (BF);
39-
4037 inferUnknownStates (BF);
4138
4239 for (FunctionFragment &FF : BF.getLayout ().fragments ()) {
@@ -67,24 +64,6 @@ void InsertNegateRAState::runOnFunction(BinaryFunction &BF) {
6764 }
6865}
6966
70- bool InsertNegateRAState::addNegateRAStateAfterPSignOrPAuth (
71- BinaryFunction &BF) {
72- BinaryContext &BC = BF.getBinaryContext ();
73- bool FoundAny = false ;
74- for (BinaryBasicBlock &BB : BF) {
75- for (auto Iter = BB.begin (); Iter != BB.end (); ++Iter) {
76- MCInst &Inst = *Iter;
77- if (BC.MIB ->isPSignOnLR (Inst) ||
78- (BC.MIB ->isPAuthOnLR (Inst) && !BC.MIB ->isPAuthAndRet (Inst))) {
79- Iter = BF.addCFIInstruction (
80- &BB, Iter + 1 , MCCFIInstruction::createNegateRAState (nullptr ));
81- FoundAny = true ;
82- }
83- }
84- }
85- return FoundAny;
86- }
87-
8867void InsertNegateRAState::coverFunctionFragmentStart (BinaryFunction &BF,
8968 FunctionFragment &FF) {
9069 BinaryContext &BC = BF.getBinaryContext ();
@@ -102,8 +81,7 @@ void InsertNegateRAState::coverFunctionFragmentStart(BinaryFunction &BF,
10281 });
10382 // If a function is already split in the input, the first FF can also start
10483 // with Signed state. This covers that scenario as well.
105- if (BC.MIB ->isRASigned (*((*FirstNonEmpty)->begin ())) ||
106- BC.MIB ->isAuthenticating (*((*FirstNonEmpty)->begin ()))) {
84+ if (BC.MIB ->isRASigned (*((*FirstNonEmpty)->begin ()))) {
10785 BF.addCFIInstruction (*FirstNonEmpty, (*FirstNonEmpty)->begin (),
10886 MCCFIInstruction::createNegateRAState (nullptr ));
10987 }
@@ -121,10 +99,10 @@ void InsertNegateRAState::inferUnknownStates(BinaryFunction &BF) {
12199 continue ;
122100
123101 if (!FirstIter && BC.MIB ->isRAStateUnknown (Inst)) {
124- if (BC.MIB ->isRASigned (PrevInst) || BC.MIB ->isRASigning (PrevInst)) {
102+ if (BC.MIB ->isRASigned (PrevInst) || BC.MIB ->isPSignOnLR (PrevInst)) {
125103 BC.MIB ->setRASigned (Inst);
126104 } else if (BC.MIB ->isRAUnsigned (PrevInst) ||
127- BC.MIB ->isAuthenticating (PrevInst)) {
105+ BC.MIB ->isPAuthOnLR (PrevInst)) {
128106 BC.MIB ->setRAUnsigned (Inst);
129107 }
130108 } else {
0 commit comments