Mail Archives: djgpp-workers/1996/09/02/09:00:43
> My guess is that this is the known bug in the crt0 code which malloc's
> the stubinfo structure. In rare instances with exactly the right code
> size, it ends up at least partially in a different memory zone. We either
> need to not malloc the structure, or in the final cleanup code save the
> values on the stack before freeing the memory.
This self-adjusting program demonstrates the crash:
#include <stdio.h>
#include <stubinfo.h>
#define FILLER 0x12f74
char filler2[FILLER];
extern int etext, edata, end;
extern int djgpp_first_ctor asm("djgpp_first_ctor");
int
main(void)
{
printf("text %08x %08x\n", 0x10a8, &etext);
printf("data %08x %08x\n", &djgpp_first_ctor, &edata);
printf("bss %08x %08x\n", &edata, &end);
printf("stubinfo at %x\n", _stubinfo);
if ((int)_stubinfo != 0x20000)
printf("set FILLER to 0x%x\n", FILLER + (0x20000 - (int)_stubinfo));
return 0;
}
- Raw text -