fpc/rtl/linux
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
..
arm 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. 2011-09-08 21:17:35 +00:00
i386 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. 2011-09-08 21:17:35 +00:00
m68k - Revert micro-exe mode for now. 2010-10-15 16:49:48 +00:00
mips 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. 2011-09-08 21:17:35 +00:00
mipsel 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. 2011-09-08 21:17:35 +00:00
powerpc 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. 2011-09-08 21:17:35 +00:00
powerpc64 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. 2011-09-08 21:17:35 +00:00
sparc 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. 2011-09-08 21:17:35 +00:00
x86_64 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. 2011-09-08 21:17:35 +00:00
buildrtl.lpi
buildrtl.pp
bunxsysc.inc
errno.inc
errnostr.inc
fpcylix.pp
fpmake.inc
gpm.pp
ipccall.inc + semtimedop() for Linux, marked as "platform" (last part of patch from 2010-11-13 18:37:43 +00:00
ipcsys.inc + semtimedop() for Linux, marked as "platform" (last part of patch from 2010-11-13 18:37:43 +00:00
linux.pp * fixed FPC_USE_LIBC building for Linux and exception handling (mantis #13450) 2011-07-31 23:36:17 +00:00
linuxvcs.pp
Makefile + Update all Makefile's modified by 2011-08-16 20:10:19 +00:00
Makefile.fpc + cpu unit for x86-64 containing a CAS128 implementation 2010-11-01 08:20:31 +00:00
oldlinux.pp * Fixed spell error revealed by lintian. 2010-10-06 20:33:57 +00:00
osdefs.inc
osmacro.inc
ossysc.inc
ostypes.inc o fixed several Linux ipc bugs, based on patch by Ruben Chaer/ 2010-11-13 16:58:23 +00:00
pthread.inc
ptypes.inc
si_c21.pp
si_c21g.pp
si_c.pp
si_dll.pp
si_g.pp
si_intf.inc
si_prc.pp
si_uc.pp
signal.inc * fixed FPC_USE_LIBC building for Linux and exception handling (mantis #13450) 2011-07-31 23:36:17 +00:00
suuid.inc
sysos.inc
sysosh.inc
system.pp * use generic first_int_to_real 64 bit values on sparc 2011-09-03 19:58:32 +00:00
termio.pp
termios.inc
termiosproc.inc
unixsock.inc
unixsockets.inc
unixsocketsh.inc
unxconst.inc
unxfunc.inc
unxsockh.inc
unxsysc.inc
unxsysch.inc