So I have the following code segment in x86 assembly:
mov $0x0, %eax
callq 400ac8 <__isoc99_sscanf@plt>
cmp $0x5,%eax
jg 40152d <this_function+0x3d> -----> jumps to add two lines down
callq 4014b a <error_program>
add $0x18,%rsp
retq
Now in the first line, it sets %eax as a zero. It then calls sscanf and then checks whether %eax is 5. If it is larger than 5, it will continue otherwise terminate. So a simple C code which I made:
eax = 0;
sscanf();
if (eax < 5) error_program();
return;
This is an object dump of a binary file so I am sure that it is correct. However, eax will always be zero and the error will fire up. Am I right on that? Or is it possible that sscanf would manipulate eax?
Thanks
It is common for functions to pass the return value back in eax; at the very least, it is not guaranteed to be preserved. So perhaps this code is checking to make sure that sscanf is finding at least 5 items?