crt0-efi-ia64.S 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* crt0-efi-ia64.S - IA-64 EFI startup code.
  2. Copyright (C) 1999 Hewlett-Packard Co.
  3. Contributed by David Mosberger <[email protected]>.
  4. All rights reserved.
  5. Redistribution and use in source and binary forms, with or without
  6. modification, are permitted provided that the following conditions
  7. are met:
  8. * Redistributions of source code must retain the above copyright
  9. notice, this list of conditions and the following disclaimer.
  10. * Redistributions in binary form must reproduce the above
  11. copyright notice, this list of conditions and the following
  12. disclaimer in the documentation and/or other materials
  13. provided with the distribution.
  14. * Neither the name of Hewlett-Packard Co. nor the names of its
  15. contributors may be used to endorse or promote products derived
  16. from this software without specific prior written permission.
  17. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  18. CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  19. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  20. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  22. BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  23. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  27. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  28. THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. SUCH DAMAGE.
  30. */
  31. .text
  32. .psr abi64
  33. .psr lsb
  34. .lsb
  35. .proc _start
  36. _start:
  37. alloc loc0=ar.pfs,2,2,2,0
  38. mov loc1=rp
  39. movl out0=@gprel(ImageBase) // out0 <- ImageBase (ldbase)
  40. ;;
  41. add out0=out0,gp
  42. movl out1=@gprel(_DYNAMIC) // out1 <- _DYNAMIC
  43. ;; // avoid WAW on CFM
  44. add out1=out1,gp
  45. br.call.sptk.few rp=_relocate
  46. .Lret0:
  47. cmp.ne p6,p0=r0,r8 // r8 == EFI_SUCCESS?
  48. (p6) br.cond.sptk.few .exit // no ->
  49. .Lret1:
  50. mov out0=in0 // image handle
  51. mov out1=in1 // systab
  52. br.call.sptk.few rp=_entry
  53. .Lret2:
  54. .exit:
  55. mov ar.pfs=loc0
  56. mov rp=loc1
  57. ;;
  58. br.ret.sptk.few rp
  59. .endp _start
  60. // PE32+ wants a PLABEL, not the code address of the entry point:
  61. .align 16
  62. .global _start_plabel
  63. .section .plabel, "a"
  64. _start_plabel:
  65. data8 _start
  66. data8 __gp
  67. // hand-craft a .reloc section for the plabel:
  68. #define IMAGE_REL_BASED_DIR64 10
  69. .section .reloc, "a"
  70. data4 _start_plabel // Page RVA
  71. data4 12 // Block Size (2*4+2*2), must be aligned by 32 Bits
  72. data2 (IMAGE_REL_BASED_DIR64<<12) + 0 // reloc for plabel's entry point
  73. data2 (IMAGE_REL_BASED_DIR64<<12) + 8 // reloc for plabel's global pointer
  74. #if defined(__ELF__) && defined(__linux__)
  75. .section .note.GNU-stack,"",%progbits
  76. #endif