si_dll.inc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (C) 2022 Loongson Technology Corporation Limited.
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. {******************************************************************************
  11. Shared library start/halt
  12. ******************************************************************************}
  13. procedure _FPC_shared_lib_haltproc(e:longint); cdecl; forward;
  14. procedure __FPC_shared_lib_start(argc : dword;argv,envp : pointer); cdecl;
  15. begin
  16. {$ifdef FPC_HAS_INDIRECT_ENTRY_INFORMATION}
  17. SysInitEntryInformation.OS.argc:=argc;
  18. SysInitEntryInformation.OS.argv:=argv;
  19. SysInitEntryInformation.OS.envp:=envp;
  20. SysInitEntryInformation.OS.stkptr:=get_frame;
  21. SysInitEntryInformation.OS.stklen:=StackLength;
  22. SysInitEntryInformation.OS.haltproc:=@_FPC_shared_lib_haltproc;
  23. SysEntry(SysInitEntryInformation);
  24. {$else}
  25. operatingsystem_parameter_argc:=argc; { Copy the argument count }
  26. operatingsystem_parameter_argv:=argv; { Copy the argument pointer }
  27. operatingsystem_parameter_envp:=envp; { Copy the environment pointer }
  28. initialstkptr:=get_frame;
  29. PASCALMAIN;
  30. {$endif}
  31. end;
  32. procedure _FPC_shared_lib_start; assembler; nostackframe; public name 'FPC_SHARED_LIB_START'; public name '_start';
  33. asm
  34. .L_FPC_shared_lib_start:
  35. .section ".init_array","a"
  36. .dc.a .L_FPC_shared_lib_start
  37. .text
  38. b __FPC_shared_lib_start
  39. end;
  40. { this routine is only called when the halt() routine of the RTL embedded in
  41. the shared library is called }
  42. procedure _FPC_shared_lib_haltproc(e:longint); cdecl; assembler; nostackframe; public name '_haltproc';
  43. asm
  44. ori $a7, $zero, 94
  45. syscall 0
  46. b _FPC_shared_lib_haltproc
  47. end;