[fpc-pascal] StackTop and StackBottom are bogus in a Win32/64 Dll

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Fri Jul 6 18:16:06 CEST 2012


OBones wrote:
> Hello all,
> 
> I'm writing Dlls here and am also doing low level analysis of the stack 
> and its content.
> To do that, I use the StackTop and StackBottom global variables which 
> used to work fine in an exe file.
> Problem is, when in a DLL, StackTop is always zero and StackBottom is 
> the exact opposite of StackLength.
> I thus looked as to where this might come from, and discovered that it 
> comes from the fact that StackTop is only ever calculated from within 
> Exe_entry which obviously is not called for a DLL.
> 
> Is anyone else seeing this?

I've not got into that level of detail, but I've noted that in Linux 
(and possibly Solaris) you have to turn off stack checking when 
generating a shared library (otherwise when the main program calls into 
the library it's unhappy) but not in the main program (i.e. the library 
can call into the main program and is always happy) which I think is 
consistent with what you're saying.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-pascal mailing list