elf.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. #include <linux/elf-em.h>
  17. /* Xtensa processor ELF architecture-magic number */
  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 user_pt_regs xtensa_gregset_t;
  70. #define ELF_NGREG (sizeof(xtensa_gregset_t) / sizeof(elf_greg_t))
  71. typedef elf_greg_t elf_gregset_t[ELF_NGREG];
  72. #define ELF_NFPREG 18
  73. typedef unsigned int elf_fpreg_t;
  74. typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
  75. /*
  76. * This is used to ensure we don't load something for the wrong architecture.
  77. */
  78. #define elf_check_arch(x) ( ( (x)->e_machine == EM_XTENSA ) || \
  79. ( (x)->e_machine == EM_XTENSA_OLD ) )
  80. #define ELFOSABI_XTENSA_FDPIC 65
  81. #define elf_check_fdpic(x) ((x)->e_ident[EI_OSABI] == ELFOSABI_XTENSA_FDPIC)
  82. #define ELF_FDPIC_CORE_EFLAGS 0
  83. /*
  84. * These are used to set parameters in the core dumps.
  85. */
  86. #ifdef __XTENSA_EL__
  87. # define ELF_DATA ELFDATA2LSB
  88. #elif defined(__XTENSA_EB__)
  89. # define ELF_DATA ELFDATA2MSB
  90. #else
  91. # error processor byte order undefined!
  92. #endif
  93. #define ELF_CLASS ELFCLASS32
  94. #define ELF_ARCH EM_XTENSA
  95. #define ELF_EXEC_PAGESIZE PAGE_SIZE
  96. #define CORE_DUMP_USE_REGSET
  97. /*
  98. * This is the location that an ET_DYN program is loaded if exec'ed. Typical
  99. * use of this is to invoke "./ld.so someprog" to test out a new version of
  100. * the loader. We need to make sure that it is out of the way of the program
  101. * that it will "exec", and that there is sufficient room for the brk.
  102. */
  103. #define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
  104. /*
  105. * This yields a mask that user programs can use to figure out what
  106. * instruction set this CPU supports. This could be done in user space,
  107. * but it's not easy, and we've already done it here.
  108. */
  109. #define ELF_HWCAP (0)
  110. /*
  111. * This yields a string that ld.so will use to load implementation
  112. * specific libraries for optimization. This is more specific in
  113. * intent than poking at uname or /proc/cpuinfo.
  114. * For the moment, we have only optimizations for the Intel generations,
  115. * but that could change...
  116. */
  117. #define ELF_PLATFORM (NULL)
  118. /*
  119. * The Xtensa processor ABI says that when the program starts, a2
  120. * contains a pointer to a function which might be registered using
  121. * `atexit'. This provides a mean for the dynamic linker to call
  122. * DT_FINI functions for shared libraries that have been loaded before
  123. * the code runs.
  124. *
  125. * A value of 0 tells we have no such handler.
  126. *
  127. * We might as well make sure everything else is cleared too (except
  128. * for the stack pointer in a1), just to make things more
  129. * deterministic. Also, clearing a0 terminates debugger backtraces.
  130. */
  131. #define ELF_PLAT_INIT(_r, load_addr) \
  132. do { \
  133. (_r)->areg[0] = 0; /*(_r)->areg[1] = 0;*/ \
  134. (_r)->areg[2] = 0; (_r)->areg[3] = 0; \
  135. (_r)->areg[4] = 0; (_r)->areg[5] = 0; \
  136. (_r)->areg[6] = 0; (_r)->areg[7] = 0; \
  137. (_r)->areg[8] = 0; (_r)->areg[9] = 0; \
  138. (_r)->areg[10] = 0; (_r)->areg[11] = 0; \
  139. (_r)->areg[12] = 0; (_r)->areg[13] = 0; \
  140. (_r)->areg[14] = 0; (_r)->areg[15] = 0; \
  141. } while (0)
  142. #define ELF_FDPIC_PLAT_INIT(_r, _exec_map_addr, _interp_map_addr, dynamic_addr) \
  143. do { \
  144. (_r)->areg[4] = _exec_map_addr; \
  145. (_r)->areg[5] = _interp_map_addr; \
  146. (_r)->areg[6] = dynamic_addr; \
  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. #endif /* _XTENSA_ELF_H */