elf.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*
  2. * include/asm-xtensa/elf.h
  3. *
  4. * ELF register definitions
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. *
  10. * Copyright (C) 2001 - 2005 Tensilica Inc.
  11. */
  12. #ifndef _XTENSA_ELF_H
  13. #define _XTENSA_ELF_H
  14. #include <asm/ptrace.h>
  15. #include <asm/coprocessor.h>
  16. /* Xtensa processor ELF architecture-magic number */
  17. #define EM_XTENSA 94
  18. #define EM_XTENSA_OLD 0xABC7
  19. /* Xtensa relocations defined by the ABIs */
  20. #define R_XTENSA_NONE 0
  21. #define R_XTENSA_32 1
  22. #define R_XTENSA_RTLD 2
  23. #define R_XTENSA_GLOB_DAT 3
  24. #define R_XTENSA_JMP_SLOT 4
  25. #define R_XTENSA_RELATIVE 5
  26. #define R_XTENSA_PLT 6
  27. #define R_XTENSA_OP0 8
  28. #define R_XTENSA_OP1 9
  29. #define R_XTENSA_OP2 10
  30. #define R_XTENSA_ASM_EXPAND 11
  31. #define R_XTENSA_ASM_SIMPLIFY 12
  32. #define R_XTENSA_GNU_VTINHERIT 15
  33. #define R_XTENSA_GNU_VTENTRY 16
  34. #define R_XTENSA_DIFF8 17
  35. #define R_XTENSA_DIFF16 18
  36. #define R_XTENSA_DIFF32 19
  37. #define R_XTENSA_SLOT0_OP 20
  38. #define R_XTENSA_SLOT1_OP 21
  39. #define R_XTENSA_SLOT2_OP 22
  40. #define R_XTENSA_SLOT3_OP 23
  41. #define R_XTENSA_SLOT4_OP 24
  42. #define R_XTENSA_SLOT5_OP 25
  43. #define R_XTENSA_SLOT6_OP 26
  44. #define R_XTENSA_SLOT7_OP 27
  45. #define R_XTENSA_SLOT8_OP 28
  46. #define R_XTENSA_SLOT9_OP 29
  47. #define R_XTENSA_SLOT10_OP 30
  48. #define R_XTENSA_SLOT11_OP 31
  49. #define R_XTENSA_SLOT12_OP 32
  50. #define R_XTENSA_SLOT13_OP 33
  51. #define R_XTENSA_SLOT14_OP 34
  52. #define R_XTENSA_SLOT0_ALT 35
  53. #define R_XTENSA_SLOT1_ALT 36
  54. #define R_XTENSA_SLOT2_ALT 37
  55. #define R_XTENSA_SLOT3_ALT 38
  56. #define R_XTENSA_SLOT4_ALT 39
  57. #define R_XTENSA_SLOT5_ALT 40
  58. #define R_XTENSA_SLOT6_ALT 41
  59. #define R_XTENSA_SLOT7_ALT 42
  60. #define R_XTENSA_SLOT8_ALT 43
  61. #define R_XTENSA_SLOT9_ALT 44
  62. #define R_XTENSA_SLOT10_ALT 45
  63. #define R_XTENSA_SLOT11_ALT 46
  64. #define R_XTENSA_SLOT12_ALT 47
  65. #define R_XTENSA_SLOT13_ALT 48
  66. #define R_XTENSA_SLOT14_ALT 49
  67. /* ELF register definitions. This is needed for core dump support. */
  68. typedef unsigned long elf_greg_t;
  69. typedef struct {
  70. elf_greg_t pc;
  71. elf_greg_t ps;
  72. elf_greg_t lbeg;
  73. elf_greg_t lend;
  74. elf_greg_t lcount;
  75. elf_greg_t sar;
  76. elf_greg_t windowstart;
  77. elf_greg_t windowbase;
  78. elf_greg_t threadptr;
  79. elf_greg_t reserved[7+48];
  80. elf_greg_t a[64];
  81. } xtensa_gregset_t;
  82. #define ELF_NGREG (sizeof(xtensa_gregset_t) / sizeof(elf_greg_t))
  83. typedef elf_greg_t elf_gregset_t[ELF_NGREG];
  84. #define ELF_NFPREG 18
  85. typedef unsigned int elf_fpreg_t;
  86. typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
  87. #define ELF_CORE_COPY_REGS(_eregs, _pregs) \
  88. xtensa_elf_core_copy_regs ((xtensa_gregset_t*)&(_eregs), _pregs);
  89. extern void xtensa_elf_core_copy_regs (xtensa_gregset_t *, struct pt_regs *);
  90. /*
  91. * This is used to ensure we don't load something for the wrong architecture.
  92. */
  93. #define elf_check_arch(x) ( ( (x)->e_machine == EM_XTENSA ) || \
  94. ( (x)->e_machine == EM_XTENSA_OLD ) )
  95. /*
  96. * These are used to set parameters in the core dumps.
  97. */
  98. #ifdef __XTENSA_EL__
  99. # define ELF_DATA ELFDATA2LSB
  100. #elif defined(__XTENSA_EB__)
  101. # define ELF_DATA ELFDATA2MSB
  102. #else
  103. # error processor byte order undefined!
  104. #endif
  105. #define ELF_CLASS ELFCLASS32
  106. #define ELF_ARCH EM_XTENSA
  107. #define ELF_EXEC_PAGESIZE PAGE_SIZE
  108. /*
  109. * This is the location that an ET_DYN program is loaded if exec'ed. Typical
  110. * use of this is to invoke "./ld.so someprog" to test out a new version of
  111. * the loader. We need to make sure that it is out of the way of the program
  112. * that it will "exec", and that there is sufficient room for the brk.
  113. */
  114. #define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
  115. /*
  116. * This yields a mask that user programs can use to figure out what
  117. * instruction set this CPU supports. This could be done in user space,
  118. * but it's not easy, and we've already done it here.
  119. */
  120. #define ELF_HWCAP (0)
  121. /*
  122. * This yields a string that ld.so will use to load implementation
  123. * specific libraries for optimization. This is more specific in
  124. * intent than poking at uname or /proc/cpuinfo.
  125. * For the moment, we have only optimizations for the Intel generations,
  126. * but that could change...
  127. */
  128. #define ELF_PLATFORM (NULL)
  129. /*
  130. * The Xtensa processor ABI says that when the program starts, a2
  131. * contains a pointer to a function which might be registered using
  132. * `atexit'. This provides a mean for the dynamic linker to call
  133. * DT_FINI functions for shared libraries that have been loaded before
  134. * the code runs.
  135. *
  136. * A value of 0 tells we have no such handler.
  137. *
  138. * We might as well make sure everything else is cleared too (except
  139. * for the stack pointer in a1), just to make things more
  140. * deterministic. Also, clearing a0 terminates debugger backtraces.
  141. */
  142. #define ELF_PLAT_INIT(_r, load_addr) \
  143. do { _r->areg[0]=0; /*_r->areg[1]=0;*/ _r->areg[2]=0; _r->areg[3]=0; \
  144. _r->areg[4]=0; _r->areg[5]=0; _r->areg[6]=0; _r->areg[7]=0; \
  145. _r->areg[8]=0; _r->areg[9]=0; _r->areg[10]=0; _r->areg[11]=0; \
  146. _r->areg[12]=0; _r->areg[13]=0; _r->areg[14]=0; _r->areg[15]=0; \
  147. } while (0)
  148. typedef struct {
  149. xtregs_opt_t opt;
  150. xtregs_user_t user;
  151. #if XTENSA_HAVE_COPROCESSORS
  152. xtregs_cp0_t cp0;
  153. xtregs_cp1_t cp1;
  154. xtregs_cp2_t cp2;
  155. xtregs_cp3_t cp3;
  156. xtregs_cp4_t cp4;
  157. xtregs_cp5_t cp5;
  158. xtregs_cp6_t cp6;
  159. xtregs_cp7_t cp7;
  160. #endif
  161. } elf_xtregs_t;
  162. #define SET_PERSONALITY(ex) \
  163. set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK)))
  164. struct task_struct;
  165. extern void do_copy_regs (xtensa_gregset_t*, struct pt_regs*,
  166. struct task_struct*);
  167. extern void do_restore_regs (xtensa_gregset_t*, struct pt_regs*,
  168. struct task_struct*);
  169. extern void do_save_fpregs (elf_fpregset_t*, struct pt_regs*,
  170. struct task_struct*);
  171. extern int do_restore_fpregs (elf_fpregset_t*, struct pt_regs*,
  172. struct task_struct*);
  173. #endif /* _XTENSA_ELF_H */