dllprt0.as 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 "dllprt0.as"
  27. .version "01.01"
  28. gcc2_compiled.:
  29. .section .rodata
  30. .LC0:
  31. .ascii "\0"
  32. .data
  33. .p2align 2
  34. .globl __progname
  35. .type __progname,@object
  36. .size __progname,4
  37. __progname:
  38. .long .LC0
  39. .align 4
  40. .type __fpucw,@object
  41. .size __fpucw,4
  42. .global __fpucw
  43. ___fpucw:
  44. .long 0x1332
  45. .globl ___fpc_brk_addr /* heap management */
  46. .type ___fpc_brk_addr,@object
  47. .size ___fpc_brk_addr,4
  48. .text
  49. .p2align 2,,3
  50. .globl FPC_LIB_START
  51. .type FPC_LIB_START,@function
  52. FPC_LIB_START:
  53. .globl FPC_SHARED_LIB_START
  54. .type FPC_SHARED_LIB_START,@function
  55. FPC_SHARED_LIB_START:
  56. movb $1,operatingsystem_islibrary
  57. finit /* initialize fpu */
  58. fwait
  59. fldcw ___fpucw
  60. /* xorl %ebp,%ebp */
  61. call PASCALMAIN@PLT
  62. ret
  63. pushl %eax
  64. jmp _haltproc
  65. .p2align 2,0x90
  66. .globl _haltproc
  67. .type _haltproc,@function
  68. _haltproc:
  69. .globl FPC_SHARED_LIB_EXIT
  70. .type FPC_SHARED_LIB_EXIT,@function
  71. FPC_SHARED_LIB_EXIT:
  72. call FPC_LIB_EXIT@PLT
  73. mov $1,%eax
  74. movzwl operatingsystem_result,%ebx
  75. pushl %ebx
  76. call _actualsyscall
  77. addl $4,%esp
  78. jmp _haltproc
  79. _actualsyscall:
  80. int $0x80
  81. jb .LErrorcode
  82. xor %ebx,%ebx
  83. ret
  84. .LErrorcode:
  85. mov %eax,%ebx
  86. mov $-1,%eax
  87. ret
  88. .comm environ,4,4
  89. .weak _DYNAMIC
  90. .ident "GCC: (GNU) 2.7.2.1"
  91. __stkptr:
  92. .skip 4
  93. .comm operatingsystem_parameter_envp,4
  94. .comm operatingsystem_parameter_argc,4
  95. .comm operatingsystem_parameter_argv,4
  96. //.section .threadvar,"aw",@nobits
  97. .comm ___fpc_threadvar_offset,4