si_dll.inc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2019 by Free Pascal development team
  4. This file implements parts of the startup code for OpenBSD
  5. shared object (.so) libraries.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$asmmode gas}
  13. {$ifdef VER3_0}
  14. procedure _init; cdecl; external name '_init';
  15. {$else VER3_0}
  16. procedure _init; cdecl; weakexternal name '_init';
  17. {$endif VER3_0}
  18. procedure _FPC_shared_lib_start; cdecl; public name 'FPC_LIB_START';
  19. begin
  20. { todo: figure out if there's any way to obtain these in OpenBSD shared libraries }
  21. environ:=nil;
  22. operatingsystem_parameter_envp:=nil;
  23. operatingsystem_parameter_argc:=0;
  24. operatingsystem_parameter_argv:=nil;
  25. if Assigned(@_init) then
  26. _init;
  27. PascalMain;
  28. end;
  29. { this routine is only called when the halt() routine of the RTL embedded in
  30. the shared library is called }
  31. procedure _FPC_shared_lib_haltproc; cdecl; assembler; nostackframe; public name '_haltproc';
  32. asm
  33. movq $1,%rax
  34. movl operatingsystem_result(%rip),%edi
  35. syscall
  36. jmp _FPC_shared_lib_haltproc
  37. end;