elf.h 5.4 KB

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