2 Grovel a compiled object file for an integer constant.
7 uint64_t values[]={0x0123456789abcdefLL, FPE_INTDIV, 0xfedcba9876543210LL};
8 int dummy[]={5, 6, 7, 8};
9 void test() { char *s = (char *)values; s = (char *)dummy; }
15 // search for a known pattern in the file
16 int match(char *buf
, FILE *f
)
20 while(fread(&c
, 1, 1, f
))
36 int main(int argc
, char **argv
)
38 if(argc
!=3 || !(argv
[1][0]=='0' || argv
[1][0]=='1'))
40 printf("argc: %d\n", argc
);
41 printf("argv[2]: %s\n", argv
[2]);
44 printf("Usage: %s {0,1} <input-file>\n", argv
[0]);
48 FILE *f
=fopen(argv
[2], "r");
51 printf("Error: could not open '%s'", argv
[1]);
55 // constants can be up to 64 bits = 8 bytes long
56 // format: 0x01234567xxxxxxxx76543210
64 unsigned char prefix
[]={0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01};
65 unsigned char suffix
[]={0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe};
68 unsigned char buffer
[8];
69 if(fread(buffer
, 8, 1, f
)!=1)
85 unsigned char prefix
[]={0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
86 unsigned char suffix
[]={0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10};
89 unsigned char buffer
[8];
90 if(fread(buffer
, 8, 1, f
)!=1)
107 printf("%llu\n", value
);