Created
August 16, 2012 20:40
-
-
Save sw17ch/3373458 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
typedef struct {} a; | |
typedef struct { a a1; a a2; } b; | |
int main(int argc, char * argv[]) | |
{ | |
a as[999999]; | |
printf("%d\n", sizeof(b) == sizeof(a)); | |
printf("%zu\n", sizeof(as)); | |
int i; | |
for(i = 0; i < sizeof(as) / sizeof(as[0]); i++) | |
{ | |
puts("wat"); | |
} | |
return 0; | |
} | |
/* $ gcc wat.c -O0 -o wat_ | |
* $ ./wat_ | |
* 1 | |
* 0 | |
* wat | |
*/ |
0xdc(%rbp) is the loop counter, temporarily stashed in %rax / %eax
%ecx is the loop limit, set to zero at ..ebe
branch enters at ..ef7 and loop body at ..edf
cmpq at ..efd sets CF 0 and ZF 0, jb at ..f00 should NOT branch. does this particular compilation emit the "wat"?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sorry, forgot how to do github