mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 21:48:09 +02:00
* don't exit the program in the exit code of shared libraries under Linux
(mantis #14958) git-svn-id: trunk@14184 -
This commit is contained in:
parent
b9f07ff1fb
commit
38c09952a3
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -10025,6 +10025,8 @@ tests/webtbs/tw14798.pp svneol=native#text/plain
|
||||
tests/webtbs/tw14812.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1485.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1489.pp svneol=native#text/plain
|
||||
tests/webtbs/tw14958a.pp svneol=native#text/plain
|
||||
tests/webtbs/tw14958b.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1501.pp svneol=native#text/plain
|
||||
tests/webtbs/tw15088.pp svneol=native#text/plain
|
||||
tests/webtbs/tw1532.pp svneol=native#text/plain
|
||||
@ -10896,6 +10898,7 @@ tests/webtbs/uw13345c.pp svneol=native#text/plain
|
||||
tests/webtbs/uw13345y.pp svneol=native#text/plain
|
||||
tests/webtbs/uw13583.pp svneol=native#text/plain
|
||||
tests/webtbs/uw14124.pp svneol=native#text/plain
|
||||
tests/webtbs/uw14958.pp svneol=native#text/plain
|
||||
tests/webtbs/uw2004.inc svneol=native#text/plain
|
||||
tests/webtbs/uw2040.pp svneol=native#text/plain
|
||||
tests/webtbs/uw2266a.inc svneol=native#text/plain
|
||||
|
@ -76,24 +76,4 @@ procedure _FPC_shared_lib_haltproc; assembler; nostackframe; public name 'FPC_SH
|
||||
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;
|
||||
|
@ -72,11 +72,7 @@ _haltproc:
|
||||
.type FPC_SHARED_LIB_EXIT,@function
|
||||
FPC_SHARED_LIB_EXIT:
|
||||
call FPC_LIB_EXIT@PLT
|
||||
movl $231,%eax /* exit_group call */
|
||||
movq operatingsystem_result@GOTPCREL(%rip),%rbx
|
||||
movzwl (%rbx),%edi
|
||||
syscall
|
||||
jmp _haltproc@PLT
|
||||
ret
|
||||
|
||||
/* Define a symbol for the first piece of initialized data. */
|
||||
.data
|
||||
|
14
tests/webtbs/tw14958a.pp
Normal file
14
tests/webtbs/tw14958a.pp
Normal file
@ -0,0 +1,14 @@
|
||||
{ %target=linux }
|
||||
{ %norun }
|
||||
library tw14958a;
|
||||
|
||||
uses
|
||||
uw14958;
|
||||
|
||||
exports
|
||||
Fun;
|
||||
|
||||
begin
|
||||
Writeln(' ExLib Main');
|
||||
end.
|
||||
|
36
tests/webtbs/tw14958b.pp
Normal file
36
tests/webtbs/tw14958b.pp
Normal file
@ -0,0 +1,36 @@
|
||||
{ %target=linux }
|
||||
{ %needlibrary }
|
||||
{ %result=182 }
|
||||
program loadlib;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
dl,dynlibs;
|
||||
|
||||
var
|
||||
p: Pointer;
|
||||
s: Longint;
|
||||
begin
|
||||
Writeln('Opening ', ParamStr(1));
|
||||
p := dlopen('./libtw14958a.so', RTLD_LAZY);
|
||||
if Assigned(p) then
|
||||
begin
|
||||
Writeln('OK. Now closing.');
|
||||
s := dlclose(p);
|
||||
Writeln('After close.');
|
||||
if s = 0 then
|
||||
begin
|
||||
Writeln('Close OK.');
|
||||
halt(182);
|
||||
end
|
||||
else
|
||||
Writeln('Failed close. Status: ', s);
|
||||
end
|
||||
else
|
||||
begin
|
||||
Writeln('Failed open.');
|
||||
halt(1);
|
||||
end;
|
||||
end.
|
||||
|
20
tests/webtbs/uw14958.pp
Normal file
20
tests/webtbs/uw14958.pp
Normal file
@ -0,0 +1,20 @@
|
||||
unit uw14958;
|
||||
|
||||
interface
|
||||
|
||||
function Fun: Boolean; stdcall;
|
||||
|
||||
implementation
|
||||
|
||||
function Fun: Boolean; stdcall;
|
||||
begin
|
||||
Fun := False;
|
||||
end;
|
||||
|
||||
initialization
|
||||
Writeln(' ExLib Init');
|
||||
|
||||
finalization
|
||||
Writeln(' ExLib Final');
|
||||
|
||||
end.
|
Loading…
Reference in New Issue
Block a user