elf.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 reserved[8+48];
  79. elf_greg_t a[64];
  80. } xtensa_gregset_t;
  81. #define ELF_NGREG (sizeof(xtensa_gregset_t) / sizeof(elf_greg_t))
  82. typedef elf_greg_t elf_gregset_t[ELF_NGREG];
  83. #define ELF_NFPREG 18
  84. typedef unsigned int elf_fpreg_t;
  85. typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
  86. #define ELF_CORE_COPY_REGS(_eregs, _pregs) \
  87. xtensa_elf_core_copy_regs ((xtensa_gregset_t*)&(_eregs), _pregs);
  88. extern void xtensa_elf_core_copy_regs (xtensa_gregset_t *, struct pt_regs *);
  89. /*
  90. * This is used to ensure we don't load something for the wrong architecture.
  91. */
  92. #define elf_check_arch(x) ( ( (x)->e_machine == EM_XTENSA ) || \
  93. ( (x)->e_machine == EM_XTENSA_OLD ) )
  94. /*
  95. * These are used to set parameters in the core dumps.
  96. */
  97. #ifdef __XTENSA_EL__
  98. # define ELF_DATA ELFDATA2LSB
  99. #elif defined(__XTENSA_EB__)
  100. # define ELF_DATA ELFDATA2MSB
  101. #else
  102. # error processor byte order undefined!
  103. #endif
  104. #define ELF_CLASS ELFCLASS32
  105. #define ELF_ARCH EM_XTENSA
  106. #define ELF_EXEC_PAGESIZE PAGE_SIZE
  107. /*
  108. * This is the location that an ET_DYN program is loaded if exec'ed. Typical
  109. * use of this is to invoke "./ld.so someprog" to test out a new version of
  110. * the loader. We need to make sure that it is out of the way of the program
  111. * that it will "exec", and that there is sufficient room for the brk.
  112. */
  113. #define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
  114. /*
  115. * This yields a mask that user programs can use to figure out what
  116. * instruction set this CPU supports. This could be done in user space,
  117. * but it's not easy, and we've already done it here.
  118. */
  119. #define ELF_HWCAP (0)
  120. /*
  121. * This yields a string that ld.so will use to load implementation
  122. * specific libraries for optimization. This is more specific in
  123. * intent than poking at uname or /proc/cpuinfo.
  124. * For the moment, we have only optimizations for the Intel generations,
  125. * but that could change...
  126. */
  127. #define ELF_PLATFORM (NULL)
  128. /*
  129. * The Xtensa processor ABI says that when the program starts, a2
  130. * contains a pointer to a function which might be registered using
  131. * `atexit'. This provides a mean for the dynamic linker to call
  132. * DT_FINI functions for shared libraries that have been loaded before
  133. * the code runs.
  134. *
  135. * A value of 0 tells we have no such handler.
  136. *
  137. * We might as well make sure everything else is cleared too (except
  138. * for the stack pointer in a1), just to make things more
  139. * deterministic. Also, clearing a0 terminates debugger backtraces.
  140. */
  141. #define ELF_PLAT_INIT(_r, load_addr) \
  142. do { _r->areg[0]=0; /*_r->areg[1]=0;*/ _r->areg[2]=0; _r->areg[3]=0; \
  143. _r->areg[4]=0; _r->areg[5]=0; _r->areg[6]=0; _r->areg[7]=0; \
  144. _r->areg[8]=0; _r->areg[9]=0; _r->areg[10]=0; _r->areg[11]=0; \
  145. _r->areg[12]=0; _r->areg[13]=0; _r->areg[14]=0; _r->areg[15]=0; \
  146. } while (0)
  147. typedef struct {
  148. xtregs_opt_t opt;
  149. xtregs_user_t user;
  150. #if XTENSA_HAVE_COPROCESSORS
  151. xtregs_cp0_t cp0;
  152. xtregs_cp1_t cp1;
  153. xtregs_cp2_t cp2;
  154. xtregs_cp3_t cp3;
  155. xtregs_cp4_t cp4;
  156. xtregs_cp5_t cp5;
  157. xtregs_cp6_t cp6;
  158. xtregs_cp7_t cp7;
  159. #endif
  160. } elf_xtregs_t;
  161. #define SET_PERSONALITY(ex) set_personality(PER_LINUX_32BIT)
  162. struct task_struct;
  163. extern void do_copy_regs (xtensa_gregset_t*, struct pt_regs*,
  164. struct task_struct*);
  165. extern void do_restore_regs (xtensa_gregset_t*, struct pt_regs*,
  166. struct task_struct*);
  167. extern void do_save_fpregs (elf_fpregset_t*, struct pt_regs*,
  168. struct task_struct*);
  169. extern int do_restore_fpregs (elf_fpregset_t*, struct pt_regs*,
  170. struct task_struct*);
  171. #endif /* _XTENSA_ELF_H */