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

incorrect EFLAGS value #463

Closed
gyorokpeter opened this issue Jan 14, 2017 · 6 comments
Closed

incorrect EFLAGS value #463

gyorokpeter opened this issue Jan 14, 2017 · 6 comments
Assignees
Milestone

Comments

@gyorokpeter
Copy link
Contributor

>>> from triton import *
>>> setArchitecture(ARCH.X86)
>>> inst1 = Instruction('\xb8\xff\xff\x00\x00')
>>> inst2 = Instruction('\xbb\x80\x80\x00\x00')
>>> inst3 = Instruction('\x21\xd8')
>>> processing(inst1)
True
>>> processing(inst2)
True
>>> processing(inst3)
True
>>> inst1
0: mov eax, 0xffff
>>> inst2
0: mov ebx, 0x8080
>>> inst3
0: and eax, ebx
>>> getConcreteRegisterValue(REG.EFLAGS)
0L

When I check the EFLAGS value in a debugger I get 0x202.

@JonathanSalwan
Copy link
Owner

JonathanSalwan commented Jan 14, 2017

Actually, EFLAGS is never used. We separated each flag as single isolated register of 1-bit. Why? To avoid huge expressions of concat and extract and thus, reduce expressions complexity.

@gyorokpeter
Copy link
Contributor Author

Could there be a specific function to fill the EFLAGS register with the concretized value of the concatenated flags?

@JonathanSalwan
Copy link
Owner

mmmh just checked right now and and 0xffff, 0x8080 defines no flags. Your 0x202 is probably defined by old flags.

>>> setArchitecture(ARCH.X86)
>>> inst1 = Instruction('\xb8\xff\xff\x00\x00')
>>> inst2 = Instruction('\xbb\xff\xff\x00\x00')
>>> inst3 = Instruction('\x21\xd8')
>>> processing(inst1)
True
>>> processing(inst2)
True
>>> processing(inst3)
True
>>> inst1
0: mov eax, 0xffff
>>> inst2
0: mov ebx, 0xffff
>>> inst3
0: and eax, ebx
>>> getConcreteRegisterValue(REG.EFLAGS)
4L

@JonathanSalwan
Copy link
Owner

Is it ok? Can we close?

@gyorokpeter
Copy link
Contributor Author

Yes.

@gyorokpeter
Copy link
Contributor Author

There are 2 bits that should always be set:
https://en.wikipedia.org/wiki/FLAGS_register
1 Reserved, always 1 in EFLAGS
9 IF Interrupt enable flag

These must always be 1. Theoretically bit 9 could be cleared with a CLI instruction but (at least in a user mode program) it results in a crash.

It's possible to manually set the correct value but maybe the default value in Triton should reflect this observation.

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

No branches or pull requests

2 participants