dllprt0.as 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. # DragonFly standard (shared) ELF startup code for Free Pascal
  17. #
  18. # DragonFly 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. .section .note.ABI-tag,"a",@progbits
  28. .p2align 2
  29. .type abitag, @object
  30. .size abitag, 28
  31. abitag:
  32. .long 10
  33. .long 4
  34. .long 1
  35. .string "DragonFly"
  36. .align 4
  37. .long 400000
  38. .text
  39. .p2align 2,,3
  40. .globl FPC_LIB_START
  41. .type FPC_LIB_START,@function
  42. FPC_LIB_START:
  43. .globl FPC_SHARED_LIB_START
  44. .type FPC_SHARED_LIB_START,@function
  45. FPC_SHARED_LIB_START:
  46. # jmp _startlib@PLT
  47. movb $1,operatingsystem_islibrary(%rip)
  48. #movq operatingsystem_islibrary@GOTPCREL(%rip),%rax
  49. #movb $1,(%rax)
  50. call _init_tls@PLT
  51. call _rtld_call_init@PLT
  52. call PASCALMAIN@PLT
  53. ret
  54. .p2align 2,,3
  55. .globl _haltproc
  56. .type _haltproc,@function
  57. /* this routine is only called when the halt() routine of the RTL embedded in
  58. the shared library is called */
  59. _haltproc:
  60. call FPC_LIB_EXIT@PLT
  61. movl $1,%eax /* exit syscall */
  62. movq operatingsystem_result(%rip),%rbx
  63. movzwl (%rbx),%edi
  64. syscall
  65. jmp _haltproc@PLT
  66. /* Do not fail linkage if argc, argv and envp are not found. */
  67. .weak operatingsystem_parameter_argc
  68. .weak operatingsystem_parameter_argv
  69. .weak operatingsystem_parameter_envp