Custom Flag Conditions #1575
-
I'm hacking on an AVR target and working on a pull request for one of the existing support plugins, but ran into a question about handling flag conditions that don't seem to be represented in LowLevelILFlagCondition. For lifting branches such as What IL should I generate for a conditional branch like |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
So there are basically 3 different ways flags can be used in lifters. In this case, you don't want flag conditions ( When you emit an expression to read the value of one of those flags with
Which lets us emit IL for the flag value that is useful to the dataflow system. So, in summary, just read the value of the flag directly just like how il register read expressions work, and allow the flag write IL generation callback to lazily emit IL that's sensible for whatever the semantics of your flag are. |
Beta Was this translation helpful? Give feedback.
So there are basically 3 different ways flags can be used in lifters. In this case, you don't want flag conditions (
LLFC_*
) or semantic flags (LLIL_FLAG_GROUP
), you're going to have to use custom flag write types withSpecialFlagRole
on the flags we don't have existing roles for.When you emit an expression to read the value of one of those flags with
il.Flag
,getFlagWriteLowLevelIL
in the custom architecture will be invoked with information from the instruction that set that flag, giving you the constant/registers used as arguments, which you then use to build up an LLIL expression reprenting the boolean value of that flag expressed in terms of inputs to the instruction that set the flag…