si_dll.inc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 att}
  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; public name '_haltproc';
  32. var
  33. ExitCode: LongInt;
  34. begin
  35. ExitCode:=operatingsystem_result;
  36. asm
  37. .Lendless:
  38. pushl ExitCode
  39. mov $1,%eax
  40. call .Lactualsyscall
  41. jmp .Lendless
  42. .Lactualsyscall:
  43. int $0x80
  44. ret
  45. end;
  46. end;