Commit Graph

68 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
pierre
958425157f * Try to implement dllprt0 for linux powerpc processor
git-svn-id: trunk@19009 -
2011-09-07 12:53:50 +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
daniel
3307d98c40 - Revert micro-exe mode for now.
git-svn-id: trunk@16170 -
2010-10-15 16:49:48 +00:00
daniel
2139a229d3 + If no unit is used, no symbol inside the system unit is used,
and no language features requiring initialization are used,
    do not initialize units, but just configure the fpu and
    signal handlers.

git-svn-id: trunk@16124 -
2010-10-10 17:40:39 +00:00
Jonas Maebe
f6d452c2c0 * remove the RTL's installed signal handlers at the end of the system
unit's initialization code in case we're in a library
  + implemented InquireSignal(), AbandonSignalHandler(), HookSignal() and
    UnhookSignal() in the sysutils unit
  * for Kylix compatibility, these routines support operating on
    SIGINT and SIGQUIT as well, although they are not hooked by default
    by FPC. The run time errors/exception codes for these signals are
    resp. 217 and 233 (same as in Kylix; I changed ENoWideStringSupport
    to 234).
  * changed the BSD syscall version of fpsigaction to use pointer
    rather than "var" arguments (compatible with other targets, and
    required to be able to pass nil arguments inside the system unit)
  -> together fixes mantis #12704

git-svn-id: trunk@13077 -
2009-05-02 09:40:44 +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
micha
341cec908d * update linux syscall numbers (merge powerpc64 to powerpc)
git-svn-id: trunk@12106 -
2008-11-15 15:42:12 +00:00
micha
83b7f81f81 + add no-fpu support to compiler/rtl for powerpc-linux (-Cfnone)
git-svn-id: trunk@10422 -
2008-03-02 12:59:02 +00:00
florian
065b187c26 * properties set
git-svn-id: trunk@8209 -
2007-08-02 07:38:09 +00:00
tom_at_work
b62ede20d6 * fix stat record when compiling for ppc/linux using -dFPC_USE_LIBC
git-svn-id: trunk@8021 -
2007-07-11 21:05:23 +00:00
marco
a123ec0d14 * More deprecated.
git-svn-id: trunk@7566 -
2007-06-03 18:55:36 +00:00
daniel
d030103742 + Restore "stat" data structure in backward compatible state
git-svn-id: trunk@6963 -
2007-03-23 22:23:24 +00:00
marco
57cfd89fbd * Linux 64-bit FS patch from neli for FPC_USE_LIBC
git-svn-id: trunk@6517 -
2007-02-16 22:16:54 +00:00
tom_at_work
479143a63e * fixed stat record for stat64 syscall
git-svn-id: trunk@5234 -
2006-11-05 10:21:43 +00:00
micha
b14c83a7e1 * stat records differ too much: use stat include file
git-svn-id: trunk@5126 -
2006-10-31 15:45:22 +00:00
marco
05bb11b2ba * syscalls regenerated by Neli.
git-svn-id: trunk@2552 -
2006-02-12 21:45:34 +00:00
tom_at_work
64c8d25dcf * added __stkptr global in cprt0 for powerpc/linux
git-svn-id: trunk@2377 -
2006-01-29 17:54:04 +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
tom_at_work
99ed1d009b * ppc32/linux: cprt0 update, fixing linking to libc
* ppc32/linux: stat update, making the compiler cycle with -dFPC_USE_LIBC again
* fixed typo in ugetrlimit libc function name

git-svn-id: trunk@1756 -
2005-11-15 17:27:42 +00:00
tom_at_work
745cafdc70 * signal handler update, uses uc_mcontext instead of sigcontext_struct in later Linux versions
* syscalls update

git-svn-id: trunk@1711 -
2005-11-10 15:01:00 +00:00
florian
d4bb99a5fb + runerror 214: bus error/data misaligment
git-svn-id: trunk@1263 -
2005-10-03 08:25:20 +00:00
peter
4ace790492 * remove $Log
git-svn-id: trunk@231 -
2005-06-07 09:47:55 +00:00
fpc
790a4fe2d3 * log and id tags removed
git-svn-id: trunk@42 -
2005-05-21 09:42:41 +00:00
fpc
50778076c3 initial import
git-svn-id: trunk@1 -
2005-05-16 18:37:41 +00:00
peter
16b121f8c4 * unblock signal in signalhandler, remove the sigprocmask call
from setjmp
2005-04-24 21:19:22 +00:00
florian
314fe14247 + routines in baseunix can be overriden by processor specifics in bsyscall.inc 2005-03-03 20:58:38 +00:00
peter
e417e34496 * truncate log 2005-02-14 17:13:06 +00:00
peter
7fb8c3dfbd * signal cleanup for linux
* sigactionhandler instead of tsigaction for bsds
  * sigcontext moved to cpu dir
2005-01-30 18:01:15 +00:00
marco
4fb68a7f0e * fixed argc<->argv 2004-09-02 18:57:37 +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
peter
c0d3ba3a67 * only i386 needs cprt21 to link with glibc 2.1+ 2004-03-10 20:38:59 +00:00
florian
3f4d98624f - killed tsyscallregs 2004-02-06 23:06:16 +00:00
florian
bc1c6a2c10 * clean up 2004-01-04 17:28:03 +00:00
florian
654fc0e272 + haeder added 2004-01-04 17:23:57 +00:00
florian
ae6e54fb38 * arg* and envp handling fixed 2004-01-04 17:12:28 +00:00
Jonas Maebe
fd1ae67764 * re-enable fpu exceptions in signal handler, they're turned off by the
kernel
2004-01-02 17:57:16 +00:00
Jonas Maebe
0ab36d6e91 * fixed signal handling 2004-01-01 16:28:16 +00:00
Jonas Maebe
4eb1eb94d1 * fixed result of failed syscalls (no extra neg is needed)
+ support multi-threaded programs
2003-12-28 20:55:10 +00:00
florian
0f5fa6973b * initial code 2003-12-28 20:08:53 +00:00
Jonas Maebe
8ad6133ea3 * more ppc fixes, hello world works again under linuxppc 2003-11-29 22:54:32 +00:00
Jonas Maebe
bc010e026f * fixed syscacll for new assembler reader 2003-11-29 18:18:11 +00:00
florian
b9376da0aa * some arm issues fixed 2003-11-21 00:40:06 +00:00
florian
4ff69f3905 * fixed rtl to work with the integrated fpc ppc assembler reader 2003-11-15 19:01:27 +00:00
Jonas Maebe
26daf920f2 + sighand and associated record definitions for ppc. Untested. 2003-11-02 14:53:06 +00:00
peter
eea01b6b7f * Syscall number is architecture dependent 2003-07-06 21:12:30 +00:00
Jonas Maebe
52e51dddb1 * fixed old syscall handling for ppc 2003-06-17 16:39:58 +00:00
Jonas Maebe
b6088901a6 * fixed storing to errno for single threaded programs 2003-05-23 21:58:30 +00:00