si_dll.inc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. procedure _init; cdecl; weakexternal name '_init';
  14. procedure _FPC_shared_lib_start; cdecl; public name 'FPC_LIB_START';
  15. begin
  16. { todo: figure out if there's any way to obtain these in OpenBSD shared libraries }
  17. environ:=nil;
  18. operatingsystem_parameter_envp:=nil;
  19. operatingsystem_parameter_argc:=0;
  20. operatingsystem_parameter_argv:=nil;
  21. if Assigned(@_init) then
  22. _init;
  23. PascalMain;
  24. end;
  25. { this routine is only called when the halt() routine of the RTL embedded in
  26. the shared library is called }
  27. procedure _FPC_shared_lib_haltproc; cdecl; public name '_haltproc';
  28. var
  29. ExitCode: LongInt;
  30. begin
  31. ExitCode:=operatingsystem_result;
  32. asm
  33. .Lendless:
  34. pushl ExitCode
  35. mov $1,%eax
  36. call .Lactualsyscall
  37. jmp .Lendless
  38. .Lactualsyscall:
  39. int $0x80
  40. ret
  41. end;
  42. end;