si_dll.inc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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; external name '_init';
  15. {$else VER3_0}
  16. procedure _init; 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. procedure _FPC_proc_haltproc; assembler; nostackframe; public name '_haltproc';
  30. asm
  31. movq $1,%rax
  32. movl operatingsystem_result(%rip),%ebx
  33. pushq %rbx
  34. call .Lactualsyscall
  35. addq $8,%rsp
  36. jmp _FPC_proc_haltproc
  37. .Lactualsyscall:
  38. int $0x80
  39. jb .LErrorcode
  40. xor %rbx,%rbx
  41. ret
  42. .LErrorcode:
  43. movq %rax,%rbx
  44. movq $-1,%rax
  45. end;