Mail Archives: djgpp/2001/11/20/19:18:58
> (1) I suppose that the sections are loaded. Now, for COFF executables,
> are EDS and ECS selectors for different segments, meaning that .data and
> .text are loaded into different segments?
No, same segment. Different selectors.
> (2) Is the stack segment of a program empty when it starts up?
crt0 might put a single word of zero at the top, but otherwise yes.
> Then what would a have? the reply was: relative to 0. Does this mean,
> relative to where you locate .text?
It has the actual offset of the procedure. "Offset" relative to the
segment, of course.
> Now, how does proc know a's address? Would this be relative to 0,
> meaning relative to where you place .data?
The linker knows where everything goes, because it knows where .data
goes (that's in the coff header). The DJGPP stub puts .data where the
linker says to put it (within the segment), so everything is in the
right place. There are no relocations done at run time.
> (4) Finally, how do I know where the main() code starts? Will EIP in
> the EXE file point to main() relative to .text base location?
No, CS:IP in the exe header point to the stub. The stub loads the EIP
of the 32-bit image from the COFF header and jumps to it.
- Raw text -