49 const char* arg = av[i];
50 if (arg[0] == '-') {
51 if (!strcmp(arg, "-xml"))
52 xml ^= 1;
53 else if (!strcmp(arg, "-raw"))
54 raw ^= 1;
55 else if (!strncmp(arg, "-options=", 9))
56 options = arg+9;
57 else
58 { printf("Usage: %s [-xml] [name...]\n", av[0]); exit(2); }
59 continue;
60 }
61 greet(arg);
62 greeted = 1;
63 }
64 if (!greeted)
65 greet("world");
66 printf("...And now for something completely different:\n");
67 void *start = (void*) &main;
68 void *end = (void*) &end_of_file;
69 #if defined(__ia64) || defined(__powerpc__)
70 /* On IA64 and PPC function pointers are pointers to function descriptors */
71 start = *((void**)start);
72 end = *((void**)end);
73 #endif
74 disassemble(start, (end > start) ? end : start + 64);
75 printf("Cheers!\n");
76 }
77
78 void greet(const char* whom) {
79 printf("Hello, %s!\n", whom);
80 }
81
82 void end_of_file() { }
83
84 /* don't disassemble after this point... */
85
86 #include "dlfcn.h"
87
88 #define DECODE_INSTRUCTIONS_VIRTUAL_NAME "decode_instructions_virtual"
89 #define DECODE_INSTRUCTIONS_NAME "decode_instructions"
|
49 const char* arg = av[i];
50 if (arg[0] == '-') {
51 if (!strcmp(arg, "-xml"))
52 xml ^= 1;
53 else if (!strcmp(arg, "-raw"))
54 raw ^= 1;
55 else if (!strncmp(arg, "-options=", 9))
56 options = arg+9;
57 else
58 { printf("Usage: %s [-xml] [name...]\n", av[0]); exit(2); }
59 continue;
60 }
61 greet(arg);
62 greeted = 1;
63 }
64 if (!greeted)
65 greet("world");
66 printf("...And now for something completely different:\n");
67 void *start = (void*) &main;
68 void *end = (void*) &end_of_file;
69 #if defined(__ia64) || (defined(__powerpc__) && !defined(ABI_ELFv2))
70 /* On IA64 and PPC function pointers are pointers to function descriptors */
71 start = *((void**)start);
72 end = *((void**)end);
73 #endif
74 disassemble(start, (end > start) ? end : start + 64);
75 printf("Cheers!\n");
76 }
77
78 void greet(const char* whom) {
79 printf("Hello, %s!\n", whom);
80 }
81
82 void end_of_file() { }
83
84 /* don't disassemble after this point... */
85
86 #include "dlfcn.h"
87
88 #define DECODE_INSTRUCTIONS_VIRTUAL_NAME "decode_instructions_virtual"
89 #define DECODE_INSTRUCTIONS_NAME "decode_instructions"
|