Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check if the instruction reads/writes a part of the given register #458

Merged
merged 2 commits into from
Jan 11, 2017
Merged

Conversation

gyorokpeter
Copy link
Contributor

No description provided.

@JonathanSalwan
Copy link
Owner

JonathanSalwan commented Jan 10, 2017

What about that?:

-             if (pair.first.getId() == target.getConstRegister().getId())
-                return true;
+             if (pair.first.getParent().getId() == target.getConstRegister().getParent().getId())
+               return true;

(doing the check only on parent registers)

@gyorokpeter
Copy link
Contributor Author

If an instruction writes to AH, then we don't want to match if we are checking whether it writes AL. However we do want to match if we are checking whether it writes EAX.

@JonathanSalwan
Copy link
Owner

Mmmh okay. But in your case you are thinking about 32-bits. It's not true for 64-bits. E.g: if you provide EAX as target and pair.first.getId() points to AX. Then, you don't catch it, right?

@JonathanSalwan
Copy link
Owner

JonathanSalwan commented Jan 10, 2017

I think you should deal with subset and bitvector. Thus, it is going to be valid for multi-architectures.

@gyorokpeter
Copy link
Contributor Author

It could be done like this:

            if (pair.first.getParent().getId() == target.getConstRegister().getParent().getId()) {
              if (pair.first.getLow() <= target.getConstRegister().getLow() && target.getConstRegister().getLow() <= pair.first.getHigh()) return true;
              if (target.getConstRegister().getLow() <= pair.first.getLow() && pair.first.getLow() <= target.getConstRegister().getHigh()) return true;

@JonathanSalwan
Copy link
Owner

Something like that yep. And this just shown me that if (pair.first.getAddress() == target.getConstMemory().getAddress()) is false if there is an overlap of store/load.

@gyorokpeter
Copy link
Contributor Author

This works for memory access:

            auto &&m1 = pair.first;
            auto &&m2 = target.getConstMemory();
            if (m1.getAddress() <= m2.getAddress() && m2.getAddress() < m1.getAddress()+m1.getSize())
              return true;
            if (m2.getAddress() <= m1.getAddress() && m1.getAddress() < m2.getAddress()+m2.getSize())
              return true;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants