si_dll.inc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2006 by Florian Klaempfl
  4. members of the Free Pascal development team.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY;without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$asmmode gas}
  12. procedure _FPC_shared_lib_haltproc(e:longint); cdecl; forward;
  13. procedure _FPC_shared_lib_start(argc:dword; argv,envp:pointer); cdecl; public name 'FPC_SHARED_LIB_START'; public name '_start';
  14. begin
  15. {$ifdef FPC_HAS_INDIRECT_ENTRY_INFORMATION}
  16. SysInitEntryInformation.OS.argc:=argc;
  17. SysInitEntryInformation.OS.argv:=argv;
  18. SysInitEntryInformation.OS.envp:=envp;
  19. SysInitEntryInformation.OS.stkptr:=get_frame;
  20. SysInitEntryInformation.OS.stklen:=StackLength;
  21. SysInitEntryInformation.OS.haltproc:=@_FPC_shared_lib_haltproc;
  22. SysEntry(SysInitEntryInformation);
  23. {$else FPC_HAS_INDIRECT_ENTRY_INFORMATION}
  24. operatingsystem_parameter_argc:=argc;
  25. operatingsystem_parameter_argv:=argv;
  26. operatingsystem_parameter_envp:=envp;
  27. InitialStkPtr:=get_frame;
  28. PASCALMAIN;
  29. {$endif FPC_HAS_INDIRECT_ENTRY_INFORMATION}
  30. end;
  31. { this routine is only called when the halt() routine of the RTL embedded in
  32. the shared library is called }
  33. procedure _FPC_shared_lib_haltproc(e:longint); cdecl; assembler; nostackframe; public name '_haltproc';
  34. asm
  35. movl e,%edi
  36. movl $231,%eax { exit_group call }
  37. syscall
  38. jmp _FPC_shared_lib_haltproc
  39. end;
  40. { Define a symbol for the first piece of initialized data. }
  41. (* .data
  42. .globl __data_start
  43. __data_start:
  44. .long 0
  45. .weak data_start
  46. data_start = __data_start *)
  47. (* We need this stuff to make gdb behave itself, otherwise
  48. gdb will chokes with SIGILL when trying to debug apps.
  49. Makes ld choke:
  50. .section ".note.ABI-tag", "a"
  51. .align 4
  52. .long 1f - 0f
  53. .long 3f - 2f
  54. .long 1
  55. 0: .asciz "GNU"
  56. 1: .align 4
  57. 2: .long 0
  58. .long 2,4,0
  59. 3: .align 4
  60. *)