elf.h 5.1 KB

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