[fpc-devel] elf load order
pascaldragon at googlemail.com
Fri Mar 16 20:27:05 CET 2012
On 16.03.2012 19:16, Andrew Haines wrote:
> I'm trying to figure out the order of events when an elf file is executed.
> I think that the _start symbol just points to the start of the .text
> section and crt1 is first followed by crti followed by crtbegin. After
> that I'm not sure.
> I am porting fpc to the xenon platform and it uses the elf file format
> for executables.
> I know that code in System.pp the begin end block at the end is being
> executed but when that procedure (PASCALMAIN?) exits, where is the next
> code begin executed?
> in my test program.pas the begin end block is not called afaict.
> I only have a putline method I wrote to debug. I can't currently follow
> the code with a debugger.
Take a look at e.g. $fpcdir/rtl/linux/i386/prt0.as. This contains the
startup (and shutdown) code for Free Pascal executables on linux-i386
that don't use libc. You'll see the call to PASCALMAIN there as well as
the halt code after it (which is executed once PASCALMAIN returns).
More information about the fpc-devel