dllprt0.as 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #
  2. # This file is part of the Free Pascal run time library.
  3. # Copyright (c) 1999-2000 by Marco van de Voort, Michael Van Canneyt
  4. # and Peter Vreman
  5. # members of the Free Pascal development team.
  6. #
  7. # See the file COPYING.FPC, included in this distribution,
  8. # for details about the copyright.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY;without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. #
  14. #**********************************************************************}
  15. #
  16. # FreeBSD standard (shared) ELF startup code for Free Pascal
  17. #
  18. # FreeBSD RunTime dynamic loader only
  19. # calls the functions specified by -init
  20. # as functions without parameters
  21. # Thus, it is not possible to retrieve argc, argv and envp
  22. # for libraries.
  23. # On x86_64 CPU, using weak for the operatingsystem_parameter_XXX
  24. # allows to bind to main program parameters,
  25. # but this does not seem to work for i386 loader.
  26. .file "crt1.c"
  27. #APP
  28. .ident "$FreeBSD: src/lib/csu/common/crtbrand.c,v 1.4 2003/10/17 15:43:13 peter Exp $"
  29. #NO_APP
  30. .section .note.ABI-tag,"a",@progbits
  31. .p2align 2
  32. .type abitag, @object
  33. .size abitag, 24
  34. abitag:
  35. .long 8
  36. .long 4
  37. .long 1
  38. .string "FreeBSD"
  39. .long 700055
  40. .text
  41. #APP
  42. .ident "$FreeBSD: src/lib/csu/amd64/crt1.c,v 1.13 2003/04/30 19:27:07 peter Exp $"
  43. #NO_APP
  44. .p2align 2,,3
  45. .globl FPC_LIB_START
  46. .type FPC_LIB_START,@function
  47. FPC_LIB_START:
  48. .globl FPC_SHARED_LIB_START
  49. .type FPC_SHARED_LIB_START,@function
  50. FPC_SHARED_LIB_START:
  51. # jmp _startlib@PLT
  52. movb $1,operatingsystem_islibrary(%rip)
  53. #movq operatingsystem_islibrary@GOTPCREL(%rip),%rax
  54. #movb $1,(%rax)
  55. call PASCALMAIN@PLT
  56. ret
  57. .p2align 2,,3
  58. .globl _haltproc
  59. .type _haltproc,@function
  60. /* this routine is only called when the halt() routine of the RTL embedded in
  61. the shared library is called */
  62. _haltproc:
  63. .globl FPC_SHARED_LIB_EXIT
  64. .type FPC_SHARED_LIB_EXIT,@function
  65. FPC_SHARED_LIB_EXIT:
  66. call FPC_LIB_EXIT@PLT
  67. movl $1,%eax /* exit syscall */
  68. movq operatingsystem_result(%rip),%rbx
  69. movzwl (%rbx),%edi
  70. syscall
  71. jmp _haltproc@PLT
  72. /* Do not fail linkage if argc, argv and envp are not found. */
  73. .weak operatingsystem_parameter_argc
  74. .weak operatingsystem_parameter_argv
  75. .weak operatingsystem_parameter_envp