delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/04/13/16:30:37

Message-Id: <m10X9m5-000S8aC@inti.gov.ar>
Comments: Authenticated sender is <salvador AT natacha DOT inti DOT gov DOT ar>
From: "Salvador Eduardo Tropea (SET)" <salvador AT inti DOT gov DOT ar>
Organization: INTI
To: djgpp-workers AT delorie DOT com
Date: Tue, 13 Apr 1999 17:31:39 +0000
MIME-Version: 1.0
Subject: Stack in djgpp
X-mailer: Pegasus Mail for Windows (v2.54)
Reply-To: djgpp-workers AT delorie DOT com

Hi:

  Today I tried to compile SDCC[1] (a Free ware , retargettable, optimizing 
ANSI-C compiler for MCUs) with djgpp. So I uncompressed with LFNs, started 
bash and played a bit (the package work with Linux and more or less with 
Cygwin). It compiled ok (with some warnings) but doesn't work very well.
  One of the things that I don't know if about a library it includes. This 
library is called gc[2] (A garbage collector for C and C++) and have djgpp as 
one of the targets, but I think they did some stuff wrong.
  The gc library needs some low level information about the stack pointer 
(looks like the allocations uses the stack, I hate garbage collectors and 
this looks very tricky). The test program passed but the compiler died with 
an error about the stack growing in the reverse direction ;-))
  Looking in the djgpp configuration I saw why, they compute it:

#       define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \ 
                                                 + _stklen))

Ugh! I think they really want to do it:

#       define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))

  What do you think?
  Anyways, after changing it both (test and compiler) passed. But my doubt is 
if that's safe, can the program play with this value?

  I also needed to patch a couple of things related to:

1) fork(), the author uses fork just because the command is there, he forks, 
one thread execs another program and the other waits! why? isn't that the 
same that spawn(P_WAIT,... ?
2) The author also does it:

    yyin = fopen(preOutName,"r");
    unlink (preOutName); 
    if (yyin == NULL) {

What's that?! he opens the file and unlinks it. Is that supposed to work in 
UNIX? I mean: what the program will get from a file that was unliked?

  Even after modifying (1) and (2) I can't get the program running :-(. The 
compiler generates the assembler output, but when spawns the assembler 
program I get: (I changed the name of the linker to ls, just for testing):

D:\DJ\BIN\LS.EXE: cannot open
Cannot exec Assembler: No such file or directory (ENOENT)

 I must investigate why. Any ideas? memory corruption?
 I was also forced to enlarge the stack, I guess that's because gc 
accumulates tons of grabage in the stack before starting to collect it.

Greetings, SET

[1] http://www.geocities.com/ResearchTriangle/Forum/1353
[2] http://reality.sgi.com/boehm/gc.html
------------------------------------ 0 --------------------------------
Visit my home page: http://welcome.to/SetSoft
or
http://www.geocities.com/SiliconValley/Vista/6552/
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Alternative e-mail: set-soft AT usa DOT net set AT computer DOT org
ICQ: 2951574
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA
TE: +(5411) 4759 0013

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019