elf_64.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. #ifndef __ASM_SPARC64_ELF_H
  2. #define __ASM_SPARC64_ELF_H
  3. /*
  4. * ELF register definitions..
  5. */
  6. #include <asm/ptrace.h>
  7. #include <asm/processor.h>
  8. #include <asm/uaccess.h>
  9. #include <asm/spitfire.h>
  10. /*
  11. * Sparc section types
  12. */
  13. #define STT_REGISTER 13
  14. /*
  15. * Sparc ELF relocation types
  16. */
  17. #define R_SPARC_NONE 0
  18. #define R_SPARC_8 1
  19. #define R_SPARC_16 2
  20. #define R_SPARC_32 3
  21. #define R_SPARC_DISP8 4
  22. #define R_SPARC_DISP16 5
  23. #define R_SPARC_DISP32 6
  24. #define R_SPARC_WDISP30 7
  25. #define R_SPARC_WDISP22 8
  26. #define R_SPARC_HI22 9
  27. #define R_SPARC_22 10
  28. #define R_SPARC_13 11
  29. #define R_SPARC_LO10 12
  30. #define R_SPARC_GOT10 13
  31. #define R_SPARC_GOT13 14
  32. #define R_SPARC_GOT22 15
  33. #define R_SPARC_PC10 16
  34. #define R_SPARC_PC22 17
  35. #define R_SPARC_WPLT30 18
  36. #define R_SPARC_COPY 19
  37. #define R_SPARC_GLOB_DAT 20
  38. #define R_SPARC_JMP_SLOT 21
  39. #define R_SPARC_RELATIVE 22
  40. #define R_SPARC_UA32 23
  41. #define R_SPARC_PLT32 24
  42. #define R_SPARC_HIPLT22 25
  43. #define R_SPARC_LOPLT10 26
  44. #define R_SPARC_PCPLT32 27
  45. #define R_SPARC_PCPLT22 28
  46. #define R_SPARC_PCPLT10 29
  47. #define R_SPARC_10 30
  48. #define R_SPARC_11 31
  49. #define R_SPARC_64 32
  50. #define R_SPARC_OLO10 33
  51. #define R_SPARC_WDISP16 40
  52. #define R_SPARC_WDISP19 41
  53. #define R_SPARC_7 43
  54. #define R_SPARC_5 44
  55. #define R_SPARC_6 45
  56. /* Bits present in AT_HWCAP, primarily for Sparc32. */
  57. #define HWCAP_SPARC_FLUSH 1 /* CPU supports flush instruction. */
  58. #define HWCAP_SPARC_STBAR 2
  59. #define HWCAP_SPARC_SWAP 4
  60. #define HWCAP_SPARC_MULDIV 8
  61. #define HWCAP_SPARC_V9 16
  62. #define HWCAP_SPARC_ULTRA3 32
  63. #define HWCAP_SPARC_BLKINIT 64
  64. #define HWCAP_SPARC_N2 128
  65. #define CORE_DUMP_USE_REGSET
  66. /*
  67. * These are used to set parameters in the core dumps.
  68. */
  69. #define ELF_ARCH EM_SPARCV9
  70. #define ELF_CLASS ELFCLASS64
  71. #define ELF_DATA ELFDATA2MSB
  72. /* Format of 64-bit elf_gregset_t is:
  73. * G0 --> G7
  74. * O0 --> O7
  75. * L0 --> L7
  76. * I0 --> I7
  77. * TSTATE
  78. * TPC
  79. * TNPC
  80. * Y
  81. */
  82. typedef unsigned long elf_greg_t;
  83. #define ELF_NGREG 36
  84. typedef elf_greg_t elf_gregset_t[ELF_NGREG];
  85. typedef struct {
  86. unsigned long pr_regs[32];
  87. unsigned long pr_fsr;
  88. unsigned long pr_gsr;
  89. unsigned long pr_fprs;
  90. } elf_fpregset_t;
  91. /* Format of 32-bit elf_gregset_t is:
  92. * G0 --> G7
  93. * O0 --> O7
  94. * L0 --> L7
  95. * I0 --> I7
  96. * PSR, PC, nPC, Y, WIM, TBR
  97. */
  98. typedef unsigned int compat_elf_greg_t;
  99. #define COMPAT_ELF_NGREG 38
  100. typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
  101. typedef struct {
  102. union {
  103. unsigned int pr_regs[32];
  104. unsigned long pr_dregs[16];
  105. } pr_fr;
  106. unsigned int __unused;
  107. unsigned int pr_fsr;
  108. unsigned char pr_qcnt;
  109. unsigned char pr_q_entrysize;
  110. unsigned char pr_en;
  111. unsigned int pr_q[64];
  112. } compat_elf_fpregset_t;
  113. /* UltraSparc extensions. Still unused, but will be eventually. */
  114. typedef struct {
  115. unsigned int pr_type;
  116. unsigned int pr_align;
  117. union {
  118. struct {
  119. union {
  120. unsigned int pr_regs[32];
  121. unsigned long pr_dregs[16];
  122. long double pr_qregs[8];
  123. } pr_xfr;
  124. } pr_v8p;
  125. unsigned int pr_xfsr;
  126. unsigned int pr_fprs;
  127. unsigned int pr_xg[8];
  128. unsigned int pr_xo[8];
  129. unsigned long pr_tstate;
  130. unsigned int pr_filler[8];
  131. } pr_un;
  132. } elf_xregset_t;
  133. /*
  134. * This is used to ensure we don't load something for the wrong architecture.
  135. */
  136. #define elf_check_arch(x) ((x)->e_machine == ELF_ARCH)
  137. #define compat_elf_check_arch(x) ((x)->e_machine == EM_SPARC || \
  138. (x)->e_machine == EM_SPARC32PLUS)
  139. #define compat_start_thread start_thread32
  140. #define USE_ELF_CORE_DUMP
  141. #define ELF_EXEC_PAGESIZE PAGE_SIZE
  142. /* This is the location that an ET_DYN program is loaded if exec'ed. Typical
  143. use of this is to invoke "./ld.so someprog" to test out a new version of
  144. the loader. We need to make sure that it is out of the way of the program
  145. that it will "exec", and that there is sufficient room for the brk. */
  146. #define ELF_ET_DYN_BASE 0x0000010000000000UL
  147. #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
  148. /* This yields a mask that user programs can use to figure out what
  149. instruction set this cpu supports. */
  150. /* On Ultra, we support all of the v8 capabilities. */
  151. static inline unsigned int sparc64_elf_hwcap(void)
  152. {
  153. unsigned int cap = (HWCAP_SPARC_FLUSH | HWCAP_SPARC_STBAR |
  154. HWCAP_SPARC_SWAP | HWCAP_SPARC_MULDIV |
  155. HWCAP_SPARC_V9);
  156. if (tlb_type == cheetah || tlb_type == cheetah_plus)
  157. cap |= HWCAP_SPARC_ULTRA3;
  158. else if (tlb_type == hypervisor) {
  159. if (sun4v_chip_type == SUN4V_CHIP_NIAGARA1 ||
  160. sun4v_chip_type == SUN4V_CHIP_NIAGARA2)
  161. cap |= HWCAP_SPARC_BLKINIT;
  162. if (sun4v_chip_type == SUN4V_CHIP_NIAGARA2)
  163. cap |= HWCAP_SPARC_N2;
  164. }
  165. return cap;
  166. }
  167. #define ELF_HWCAP sparc64_elf_hwcap();
  168. /* This yields a string that ld.so will use to load implementation
  169. specific libraries for optimization. This is more specific in
  170. intent than poking at uname or /proc/cpuinfo. */
  171. #define ELF_PLATFORM (NULL)
  172. #define SET_PERSONALITY(ex) \
  173. do { unsigned long new_flags = current_thread_info()->flags; \
  174. new_flags &= _TIF_32BIT; \
  175. if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
  176. new_flags |= _TIF_32BIT; \
  177. else \
  178. new_flags &= ~_TIF_32BIT; \
  179. if ((current_thread_info()->flags & _TIF_32BIT) \
  180. != new_flags) \
  181. set_thread_flag(TIF_ABI_PENDING); \
  182. else \
  183. clear_thread_flag(TIF_ABI_PENDING); \
  184. /* flush_thread will update pgd cache */ \
  185. if (current->personality != PER_LINUX32) \
  186. set_personality(PER_LINUX); \
  187. } while (0)
  188. #endif /* !(__ASM_SPARC64_ELF_H) */