* reverted the rtl patches from r14184, because they cause an endless

loop when attempting to terminate a process via the RTL compiled into
    a Linux shared library  (mantis )
  * 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  again after reverting r14184)

git-svn-id: trunk@16418 -
This commit is contained in:
Jonas Maebe 2010-11-24 15:33:29 +00:00
parent 1271c221f3
commit 1f61b5b30c
4 changed files with 32 additions and 8 deletions
compiler/systems
rtl/linux

View File

@ -1080,7 +1080,7 @@ begin
{ Create some replacements }
{ note: linux does not use exportlib.initname/fininame due to the custom startup code }
InitStr:='-init FPC_SHARED_LIB_START';
FiniStr:='-fini FPC_SHARED_LIB_EXIT';
FiniStr:='-fini FPC_LIB_EXIT';
SoNameStr:='-soname '+ExtractFileName(current_module.sharedlibfilename^);
{ Call linker }

View File

@ -70,10 +70,29 @@ begin
PASCALMAIN;
end;
Procedure lib_exit; external name 'FPC_LIB_EXIT';
{ this routine is only called when the halt() routine of the RTL embedded in
the shared library is called }
procedure _FPC_shared_lib_haltproc; assembler; nostackframe; public name 'FPC_SHARED_LIB_EXIT'; public name '_haltproc';
asm
.Lhaltproc:
call lib_exit
{$ifdef FPC_PIC}
call get1eipasebx
addl $_GLOBAL_OFFSET_TABLE_,%ebx
movl ExitCode@GOT(%ebx),%ebx
{$if sizeof(ExitCode)=2}
movzwl (%ebx),%ebx
{$else}
mov (%ebx),%ebx
{$endif}
{$else FPC_PIC}
{$if sizeof(ExitCode)=2}
movzwl ExitCode,%ebx
{$else}
mov ExitCode,%ebx
{$endif}
{$endif FPC_PIC}
xorl %eax,%eax
incl %eax { eax=1, exit call }
int $0x80
jmp .Lhaltproc
end;

View File

@ -356,10 +356,10 @@ FUNCTION_PROLOG FPC_SHARED_LIB_START
mtlr 0
blr
/* this routine is only called when the halt() routine of the RTL embedded in
the shared library is called */
FUNCTION_PROLOG _haltproc
FUNCTION_PROLOG FPC_SHARED_LIB_EXIT
bl FPC_LIB_EXIT
nop
/* exit_group call */
LOAD_64BIT_VAL 3, operatingsystem_result
lwz 3, 0(3)

View File

@ -65,14 +65,19 @@ _startlib:
popq %rbx
ret
/* this routine is only called when the halt() routine of the RTL embedded in
the shared library is called */
.globl _haltproc
.type _haltproc,@function
_haltproc:
.globl FPC_SHARED_LIB_EXIT
.type FPC_SHARED_LIB_EXIT,@function
FPC_SHARED_LIB_EXIT:
call FPC_LIB_EXIT@PLT
ret
movl $231,%eax /* exit_group call */
movq operatingsystem_result@GOTPCREL(%rip),%rbx
movzwl (%rbx),%edi
syscall
jmp _haltproc@PLT
/* Define a symbol for the first piece of initialized data. */
.data