elf.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /* $Id: elf.h,v 1.32 2002/02/09 19:49:31 davem Exp $ */
  2. #ifndef __ASM_SPARC64_ELF_H
  3. #define __ASM_SPARC64_ELF_H
  4. /*
  5. * ELF register definitions..
  6. */
  7. #include <asm/ptrace.h>
  8. #ifdef __KERNEL__
  9. #include <asm/processor.h>
  10. #include <asm/uaccess.h>
  11. #endif
  12. /*
  13. * Sparc section types
  14. */
  15. #define STT_REGISTER 13
  16. /*
  17. * Sparc ELF relocation types
  18. */
  19. #define R_SPARC_NONE 0
  20. #define R_SPARC_8 1
  21. #define R_SPARC_16 2
  22. #define R_SPARC_32 3
  23. #define R_SPARC_DISP8 4
  24. #define R_SPARC_DISP16 5
  25. #define R_SPARC_DISP32 6
  26. #define R_SPARC_WDISP30 7
  27. #define R_SPARC_WDISP22 8
  28. #define R_SPARC_HI22 9
  29. #define R_SPARC_22 10
  30. #define R_SPARC_13 11
  31. #define R_SPARC_LO10 12
  32. #define R_SPARC_GOT10 13
  33. #define R_SPARC_GOT13 14
  34. #define R_SPARC_GOT22 15
  35. #define R_SPARC_PC10 16
  36. #define R_SPARC_PC22 17
  37. #define R_SPARC_WPLT30 18
  38. #define R_SPARC_COPY 19
  39. #define R_SPARC_GLOB_DAT 20
  40. #define R_SPARC_JMP_SLOT 21
  41. #define R_SPARC_RELATIVE 22
  42. #define R_SPARC_UA32 23
  43. #define R_SPARC_PLT32 24
  44. #define R_SPARC_HIPLT22 25
  45. #define R_SPARC_LOPLT10 26
  46. #define R_SPARC_PCPLT32 27
  47. #define R_SPARC_PCPLT22 28
  48. #define R_SPARC_PCPLT10 29
  49. #define R_SPARC_10 30
  50. #define R_SPARC_11 31
  51. #define R_SPARC_64 32
  52. #define R_SPARC_OLO10 33
  53. #define R_SPARC_WDISP16 40
  54. #define R_SPARC_WDISP19 41
  55. #define R_SPARC_7 43
  56. #define R_SPARC_5 44
  57. #define R_SPARC_6 45
  58. /* Bits present in AT_HWCAP, primarily for Sparc32. */
  59. #define HWCAP_SPARC_FLUSH 1 /* CPU supports flush instruction. */
  60. #define HWCAP_SPARC_STBAR 2
  61. #define HWCAP_SPARC_SWAP 4
  62. #define HWCAP_SPARC_MULDIV 8
  63. #define HWCAP_SPARC_V9 16
  64. #define HWCAP_SPARC_ULTRA3 32
  65. /*
  66. * These are used to set parameters in the core dumps.
  67. */
  68. #ifndef ELF_ARCH
  69. #define ELF_ARCH EM_SPARCV9
  70. #define ELF_CLASS ELFCLASS64
  71. #define ELF_DATA ELFDATA2MSB
  72. typedef unsigned long elf_greg_t;
  73. #define ELF_NGREG 36
  74. typedef elf_greg_t elf_gregset_t[ELF_NGREG];
  75. /* Format of 64-bit elf_gregset_t is:
  76. * G0 --> G7
  77. * O0 --> O7
  78. * L0 --> L7
  79. * I0 --> I7
  80. * TSTATE
  81. * TPC
  82. * TNPC
  83. * Y
  84. */
  85. #define ELF_CORE_COPY_REGS(__elf_regs, __pt_regs) \
  86. do { unsigned long *dest = &(__elf_regs[0]); \
  87. struct pt_regs *src = (__pt_regs); \
  88. unsigned long __user *sp; \
  89. int i; \
  90. for(i = 0; i < 16; i++) \
  91. dest[i] = src->u_regs[i]; \
  92. /* Don't try this at home kids... */ \
  93. sp = (unsigned long __user *) \
  94. ((src->u_regs[14] + STACK_BIAS) \
  95. & 0xfffffffffffffff8UL); \
  96. for(i = 0; i < 16; i++) \
  97. __get_user(dest[i+16], &sp[i]); \
  98. dest[32] = src->tstate; \
  99. dest[33] = src->tpc; \
  100. dest[34] = src->tnpc; \
  101. dest[35] = src->y; \
  102. } while (0);
  103. typedef struct {
  104. unsigned long pr_regs[32];
  105. unsigned long pr_fsr;
  106. unsigned long pr_gsr;
  107. unsigned long pr_fprs;
  108. } elf_fpregset_t;
  109. #endif
  110. #define ELF_CORE_COPY_TASK_REGS(__tsk, __elf_regs) \
  111. ({ ELF_CORE_COPY_REGS((*(__elf_regs)), task_pt_regs(__tsk)); 1; })
  112. /*
  113. * This is used to ensure we don't load something for the wrong architecture.
  114. */
  115. #ifndef elf_check_arch
  116. #define elf_check_arch(x) ((x)->e_machine == ELF_ARCH) /* Might be EM_SPARCV9 or EM_SPARC */
  117. #endif
  118. #define USE_ELF_CORE_DUMP
  119. #define ELF_EXEC_PAGESIZE PAGE_SIZE
  120. /* This is the location that an ET_DYN program is loaded if exec'ed. Typical
  121. use of this is to invoke "./ld.so someprog" to test out a new version of
  122. the loader. We need to make sure that it is out of the way of the program
  123. that it will "exec", and that there is sufficient room for the brk. */
  124. #ifndef ELF_ET_DYN_BASE
  125. #define ELF_ET_DYN_BASE 0x0000010000000000UL
  126. #endif
  127. /* This yields a mask that user programs can use to figure out what
  128. instruction set this cpu supports. */
  129. /* On Ultra, we support all of the v8 capabilities. */
  130. #define ELF_HWCAP ((HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR | \
  131. HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV | \
  132. HWCAP_SPARC_V9) | \
  133. ((tlb_type == cheetah || tlb_type == cheetah_plus) ? \
  134. HWCAP_SPARC_ULTRA3 : 0))
  135. /* This yields a string that ld.so will use to load implementation
  136. specific libraries for optimization. This is more specific in
  137. intent than poking at uname or /proc/cpuinfo. */
  138. #define ELF_PLATFORM (NULL)
  139. #ifdef __KERNEL__
  140. #define SET_PERSONALITY(ex, ibcs2) \
  141. do { unsigned long new_flags = current_thread_info()->flags; \
  142. new_flags &= _TIF_32BIT; \
  143. if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
  144. new_flags |= _TIF_32BIT; \
  145. else \
  146. new_flags &= ~_TIF_32BIT; \
  147. if ((current_thread_info()->flags & _TIF_32BIT) \
  148. != new_flags) \
  149. set_thread_flag(TIF_ABI_PENDING); \
  150. else \
  151. clear_thread_flag(TIF_ABI_PENDING); \
  152. /* flush_thread will update pgd cache */ \
  153. if (ibcs2) \
  154. set_personality(PER_SVR4); \
  155. else if (current->personality != PER_LINUX32) \
  156. set_personality(PER_LINUX); \
  157. } while (0)
  158. #endif
  159. #endif /* !(__ASM_SPARC64_ELF_H) */