Commit Graph

20 Commits

Author SHA1 Message Date
tom_at_work
9ce34c63c9 Fix shared library loading and unloading for Linux platforms. Shared library initialization and finalization are now called correctly at program startup for compile-time linked dynamic libraries on powerpc-/powerpc64-/arm-/i386- and x86_64-linux.
Every startup code must now provide an additional entry point called "_dynamic_start" that is set as new the entry point if the program links to a Pascal shared library. Its purpose is to set up an exit hook usually passed via a register, which should be called during program finalization if non-nil.

We use this additional entry point because this register only has meaningful content when there are any compile-time linked shared libraries, otherwise it often contains random garbage. The difference between the _dynamic_start and the original code is minimal; actually in all implementations the _dynamic_start code passes on control to the old startup code, so we use an additional entry point instead of an additional startup file.

Detailed changes and fixes list:
compiler:
  always link to the dynamic loader (ld.so) when compiling shared libraries. Fixes crashes in the loader during shared library finalization on some Linuxes
  remove additional ENTRY() section in arm linker script
  select either _dynamic_start or _start as entry point depending on whether this is a static or dynamic executable
powerpc*:
  do not set System.isLibrary in startup code, it will be set during library initialization anyway
  trap in case of reaching code locations that should not be reached instead of looping (possibly endlessly)
powerpc:
  register atexit() function pointer if supplied to the executable and call it during shutdown
  correctly set argc/argv/envp in shared library code and return correctly to the caller after initialization
  pass on exitcode in shared library haltproc
  use the more recent exit_group system call if available for shutdown
powerpc64
  fix .ptrgl stub, do not set the environment register to the value of the GOT entry in the function descriptor
arm
  do not set System.isLibrary in startup code, it will be set during library initialization anyway
  reload exitcode to pass to shutdown
mips,mipsel,sparc
  added stubs to allow correct linking

git-svn-id: trunk@19036 -
2011-09-08 21:17:35 +00:00
tom_at_work
7f9dedec99 Moved global variables from .text section to .bss in ppc/linux startup code, improves position independency
git-svn-id: trunk@16210 -
2010-10-23 20:07:36 +00:00
Jonas Maebe
3216e8c7bc * mark produced object files as "does not require executable stack" by
default for Linux (overridable using -WX switch) (mantis #11563)

git-svn-id: trunk@12356 -
2008-12-12 16:26:25 +00:00
peter
94f2b1d941 * add initialstkptr to get the stackpointer at startup before
PASCALMAIN is called so the main body framepointer is seen as
    a valid pointer with backtracing

git-svn-id: trunk@2266 -
2006-01-12 09:29:57 +00:00
peter
4ace790492 * remove $Log
git-svn-id: trunk@231 -
2005-06-07 09:47:55 +00:00
fpc
50778076c3 initial import
git-svn-id: trunk@1 -
2005-05-16 18:37:41 +00:00
Károly Balogh
b7ae54715c * quick fix to make it compile 2004-08-18 14:26:50 +00:00
daniel
a1229ff8fe * Modified bootstrap code so separate prt0.as/prt0_10.as files are no
longer necessary
2004-07-03 21:50:30 +00:00
florian
935201e75c * _haltproc fixed 2004-05-26 20:48:17 +00:00
florian
654fc0e272 + haeder added 2004-01-04 17:23:57 +00:00
florian
149d986f5f + added setup of argv, argc and envp 2003-05-12 22:36:45 +00:00
peter
9f31783a0a * old logs removed and tabs fixed 2002-09-07 16:01:16 +00:00
florian
c8a3171dc9 * several PC related fixes 2002-08-31 21:29:57 +00:00
florian
2290ef3c9c * made _start global 2002-08-31 16:13:12 +00:00
florian
85a0692ee5 * r3 renamed to 3 2002-08-31 14:02:23 +00:00
florian
8b1fd424de * _haltproc to prt0.as added (Linux/PPC) 2002-08-31 14:01:28 +00:00
florian
44ad4027b7 * several fixes for Linux/PPC compilation 2002-08-31 13:11:11 +00:00
florian
785527904e * small fixes 2002-08-19 21:19:15 +00:00
florian
6fa8512bd4 * log fixed 2002-07-26 17:09:44 +00:00
florian
8c4fe22423 + initial version, plain copy from glibc/sysdeps/powerpc/elf/start.S 2002-07-26 16:57:40 +00:00