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 -
symbols in assembler sources.
Added to corresponding system variables or typed constants a
public name 'operatingsystem_XXX' alias and used that alias in assembler
source.
git-svn-id: trunk@18943 -
change in utils/fpcm/fpcmake.ini in prevous commit.
Adapt also other files to that change:
* compiler/globals.pas: Replace $FPCTARGET by os_string if
tf_use_8_3 flag is set for target_info also.
* tests/Makefile.fpc: Modify TEST_TARGETSUFFIX in the same way
as TARGETSUFFIX was modified in previous commit.
* tests/utils/dotest.pp:
+ New variable UseOSOnly, set to true if only target OS name
should be used for subdirectories.
git-svn-id: trunk@18228 -
- fixed a platform modifier in ipc.pp
- fixed different layout sigaction record in libc. (field order)
- fixed many bad use_libc fixes in linux. Most of these were only checked
for compilation, not linking. (e.g. futex doesn't link)
git-svn-id: trunk@18042 -
relocations for addr_pic_no_got references (do not go via the GOT)
* fixed code generator so that it generates addr_pic_no_got references
also for platforms that use the internal assembler (this will break linking
of some tests that check static data > 2GB on Linux/x86-64, but they were
already broken before as well because we don't use the "huge" x86-64
execution model)
* fixed x86-64 Linux syscall code to not expect GOT-based relocations for
the system unit's errno variable (it's an implementation-only variable)
git-svn-id: trunk@16717 -
loop when attempting to terminate a process via the RTL compiled into
a Linux shared library (mantis #17383)
* call FPC_LIB_EXIT (the internal/generic RTL finalisation routine) instead
of FPC_SHARED_LIB_EXIT (the Linux-specific "process exit" code for shared
libraries) as "fini" routine (fixes#14958 again after reverting r14184)
git-svn-id: trunk@16418 -
Pablo Alfaro (mantis #14075, also fixes#13363):
* ipc msgtyp is clong, not cint
* TIPC_Perm and TSEMid_ds are different on 64 bit systems
* fixed passing semun arguments (have to be passed by value, not reference)
* fixed the order of parameters to msg* syscalls, and don't use
TIPC_Kludge for msgrcv syscall (only for ipccall.inc variants)
* use new operation variants on 64 bit platforms in ipccall.inc
* introduced use kernel_mode/uid/gid_t types for use by the Linux ipc
records
* fixed type of TSEMid_ds.sem_base for Darwin
* added {$packrecords c} to ipc unit, and {$packrecords 4} around
certain structs for Darwin as in the C headers
* fixed passing semun argument to semctl for libc platforms (by
value, not reference)
git-svn-id: trunk@16336 -
* startup code in c/g/prt0.as does not contain .text references anymore
* fixed shared library startup code for ppc64: startup and shutdown code is properly called, making the tlibrary2 test succeed now
git-svn-id: trunk@16199 -
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 -
lacking "nostackframe" with branches to an exit label, because in that
case the compiler-generated exit code must be executed to balance the
stack (only done for EABI; should probably also be done for OABI, but
I can't test that)
git-svn-id: trunk@16073 -
later: the same as i386/darwin, except
a) uses the non-fragile Objective-C ABI/runtime
b) does not require stubs for direct calls/jumps (not required for
i386/darwin under 10.6 and later either, but still generated
there for backwards compatibility)
c) only the same packages are enabled as for ARM/Darwin
d) MacOSAll is compiled specifically for the iPhoneSimulator SDK
This target also defines the symbol "darwin" apart from the target
name "iphonesim" for source code compatibility reasons.
git-svn-id: trunk@16065 -
(mantis #17100)
* also use a syscall to call modify_ldt when FPC_USE_LIBC is defined,
because it's not exported as a function from libc
git-svn-id: trunk@15838 -
+ Add sched_yield to linux unit
- Remove clone for m68k from linux unit (unimplemented assembler section)
+ Add fpsigtimedwait to baseunix unit
git-svn-id: trunk@15602 -
This means it is not aliased in the body of the system unit (which causes
trouble with the delphi type of the same name), but baseunix/unix/unixtype
will containue to export the type.
git-svn-id: trunk@14584 -