// To reverse engineer the executable we will use // the objdump command as follows. // objdump -M intel -d Bug >Bug.dsm // objdump -M intel -s -j.rodata Bug >Bug.rod // readelf -a Bug >Bug.elf // // To compile this program type // gcc -o Bug Bug.c -lXm -lXt -lX11 -lXext // ????????????? Possible bug in objdump ?????????????? // Consider the following lines in Bug.dsm // // 998: 48 89 05 91 52 20 00 mov QWORD PTR [rip+0x205291],rax # 205c30 // 99f: 48 8b 05 8a 52 20 00 mov rax,QWORD PTR [rip+0x20528a] # 205c30 // // The instructions access XtStrings+0x48f0. However, if you look at Bug.elf you see // // 11: 0000000000201340 2649 OBJECT GLOBAL DEFAULT 21 XtStrings // // The size of XtStrings is 2649 decimal. But XtStrings+0x48f0 is beyond the region occupied by XtStrings. // I tried to "reverse engineer" this code based on Bug.dsm and Bug.elf but get the error // Segmentation fault (core dumped) // when the first of these two instructions is executed. #include #include // Comment out the following include and the bug goes away. // However, this include is needed for the original program. #include "terre.xbm" typedef struct { int speed; XtIntervalId timeoutID; Pixel foreground ; Pixel background ; Boolean persue; } ApplicationData; #define XmNspeed "speed" #define XmCSpeed "Speed" #define XmNpersue "persue" #define XmCPersue "Persue" static XtResource resources[] = { { XmNspeed, XmCSpeed, XmRInt, sizeof(int), XtOffsetOf (ApplicationData, speed), XmRImmediate, (caddr_t) 50 }, { XmNforeground, XmCForeground, XmRPixel, sizeof (Pixel), XtOffsetOf (ApplicationData, foreground), XmRString, "brown"}, { XmNbackground, XmCBackground, XmRPixel, sizeof (Pixel), XtOffsetOf (ApplicationData, background), XmRString, "turquoise"}, { XmNpersue, XmCPersue, XmRBoolean, sizeof (Boolean), XtOffsetOf (ApplicationData, persue), XmRImmediate, (caddr_t) 0} }; int main(int argc, char** argv) { Arg args[10] ; resources[0].resource_type = "Int"; printf("resources[0].resource_type=%s\n",resources[0].resource_type); XtSetArg(args[0], XmNwidth, 64); return 0; }