elf.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /*
  2. * ELF definitions for the Hexagon architecture
  3. *
  4. * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 and
  8. * only version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. * 02110-1301, USA.
  19. */
  20. #ifndef __ASM_ELF_H
  21. #define __ASM_ELF_H
  22. #include <asm/ptrace.h>
  23. #include <asm/user.h>
  24. /*
  25. * This should really be in linux/elf-em.h.
  26. */
  27. #define EM_HEXAGON 164 /* QUALCOMM Hexagon */
  28. struct elf32_hdr;
  29. /*
  30. * ELF header e_flags defines.
  31. */
  32. /* should have stuff like "CPU type" and maybe "ABI version", etc */
  33. /* Hexagon relocations */
  34. /* V2 */
  35. #define R_HEXAGON_NONE 0
  36. #define R_HEXAGON_B22_PCREL 1
  37. #define R_HEXAGON_B15_PCREL 2
  38. #define R_HEXAGON_B7_PCREL 3
  39. #define R_HEXAGON_LO16 4
  40. #define R_HEXAGON_HI16 5
  41. #define R_HEXAGON_32 6
  42. #define R_HEXAGON_16 7
  43. #define R_HEXAGON_8 8
  44. #define R_HEXAGON_GPREL16_0 9
  45. #define R_HEXAGON_GPREL16_1 10
  46. #define R_HEXAGON_GPREL16_2 11
  47. #define R_HEXAGON_GPREL16_3 12
  48. #define R_HEXAGON_HL16 13
  49. /* V3 */
  50. #define R_HEXAGON_B13_PCREL 14
  51. /* V4 */
  52. #define R_HEXAGON_B9_PCREL 15
  53. /* V4 (extenders) */
  54. #define R_HEXAGON_B32_PCREL_X 16
  55. #define R_HEXAGON_32_6_X 17
  56. /* V4 (extended) */
  57. #define R_HEXAGON_B22_PCREL_X 18
  58. #define R_HEXAGON_B15_PCREL_X 19
  59. #define R_HEXAGON_B13_PCREL_X 20
  60. #define R_HEXAGON_B9_PCREL_X 21
  61. #define R_HEXAGON_B7_PCREL_X 22
  62. #define R_HEXAGON_16_X 23
  63. #define R_HEXAGON_12_X 24
  64. #define R_HEXAGON_11_X 25
  65. #define R_HEXAGON_10_X 26
  66. #define R_HEXAGON_9_X 27
  67. #define R_HEXAGON_8_X 28
  68. #define R_HEXAGON_7_X 29
  69. #define R_HEXAGON_6_X 30
  70. /* V2 PIC */
  71. #define R_HEXAGON_32_PCREL 31
  72. #define R_HEXAGON_COPY 32
  73. #define R_HEXAGON_GLOB_DAT 33
  74. #define R_HEXAGON_JMP_SLOT 34
  75. #define R_HEXAGON_RELATIVE 35
  76. #define R_HEXAGON_PLT_B22_PCREL 36
  77. #define R_HEXAGON_GOTOFF_LO16 37
  78. #define R_HEXAGON_GOTOFF_HI16 38
  79. #define R_HEXAGON_GOTOFF_32 39
  80. #define R_HEXAGON_GOT_LO16 40
  81. #define R_HEXAGON_GOT_HI16 41
  82. #define R_HEXAGON_GOT_32 42
  83. #define R_HEXAGON_GOT_16 43
  84. /*
  85. * ELF register definitions..
  86. */
  87. typedef unsigned long elf_greg_t;
  88. typedef struct user_regs_struct elf_gregset_t;
  89. #define ELF_NGREG (sizeof(elf_gregset_t)/sizeof(unsigned long))
  90. /* Placeholder */
  91. typedef unsigned long elf_fpregset_t;
  92. /*
  93. * Bypass the whole "regsets" thing for now and use the define.
  94. */
  95. #if CONFIG_HEXAGON_ARCH_VERSION >= 4
  96. #define CS_COPYREGS(DEST,REGS) \
  97. do {\
  98. DEST.cs0 = REGS->cs0;\
  99. DEST.cs1 = REGS->cs1;\
  100. } while (0)
  101. #else
  102. #define CS_COPYREGS(DEST,REGS)
  103. #endif
  104. #define ELF_CORE_COPY_REGS(DEST, REGS) \
  105. do { \
  106. DEST.r0 = REGS->r00; \
  107. DEST.r1 = REGS->r01; \
  108. DEST.r2 = REGS->r02; \
  109. DEST.r3 = REGS->r03; \
  110. DEST.r4 = REGS->r04; \
  111. DEST.r5 = REGS->r05; \
  112. DEST.r6 = REGS->r06; \
  113. DEST.r7 = REGS->r07; \
  114. DEST.r8 = REGS->r08; \
  115. DEST.r9 = REGS->r09; \
  116. DEST.r10 = REGS->r10; \
  117. DEST.r11 = REGS->r11; \
  118. DEST.r12 = REGS->r12; \
  119. DEST.r13 = REGS->r13; \
  120. DEST.r14 = REGS->r14; \
  121. DEST.r15 = REGS->r15; \
  122. DEST.r16 = REGS->r16; \
  123. DEST.r17 = REGS->r17; \
  124. DEST.r18 = REGS->r18; \
  125. DEST.r19 = REGS->r19; \
  126. DEST.r20 = REGS->r20; \
  127. DEST.r21 = REGS->r21; \
  128. DEST.r22 = REGS->r22; \
  129. DEST.r23 = REGS->r23; \
  130. DEST.r24 = REGS->r24; \
  131. DEST.r25 = REGS->r25; \
  132. DEST.r26 = REGS->r26; \
  133. DEST.r27 = REGS->r27; \
  134. DEST.r28 = REGS->r28; \
  135. DEST.r29 = pt_psp(REGS); \
  136. DEST.r30 = REGS->r30; \
  137. DEST.r31 = REGS->r31; \
  138. DEST.sa0 = REGS->sa0; \
  139. DEST.lc0 = REGS->lc0; \
  140. DEST.sa1 = REGS->sa1; \
  141. DEST.lc1 = REGS->lc1; \
  142. DEST.m0 = REGS->m0; \
  143. DEST.m1 = REGS->m1; \
  144. DEST.usr = REGS->usr; \
  145. DEST.p3_0 = REGS->preds; \
  146. DEST.gp = REGS->gp; \
  147. DEST.ugp = REGS->ugp; \
  148. CS_COPYREGS(DEST,REGS); \
  149. DEST.pc = pt_elr(REGS); \
  150. DEST.cause = pt_cause(REGS); \
  151. DEST.badva = pt_badva(REGS); \
  152. } while (0);
  153. /*
  154. * This is used to ensure we don't load something for the wrong architecture.
  155. * Checks the machine and ABI type.
  156. */
  157. #define elf_check_arch(hdr) ((hdr)->e_machine == EM_HEXAGON)
  158. /*
  159. * These are used to set parameters in the core dumps.
  160. */
  161. #define ELF_CLASS ELFCLASS32
  162. #define ELF_DATA ELFDATA2LSB
  163. #define ELF_ARCH EM_HEXAGON
  164. #if CONFIG_HEXAGON_ARCH_VERSION == 2
  165. #define ELF_CORE_EFLAGS 0x1
  166. #endif
  167. #if CONFIG_HEXAGON_ARCH_VERSION == 3
  168. #define ELF_CORE_EFLAGS 0x2
  169. #endif
  170. #if CONFIG_HEXAGON_ARCH_VERSION == 4
  171. #define ELF_CORE_EFLAGS 0x3
  172. #endif
  173. /*
  174. * Some architectures have ld.so set up a pointer to a function
  175. * to be registered using atexit, to facilitate cleanup. So that
  176. * static executables will be well-behaved, we would null the register
  177. * in question here, in the pt_regs structure passed. For now,
  178. * leave it a null macro.
  179. */
  180. #define ELF_PLAT_INIT(regs, load_addr) do { } while (0)
  181. #define USE_ELF_CORE_DUMP
  182. #define CORE_DUMP_USE_REGSET
  183. /* Hrm is this going to cause problems for changing PAGE_SIZE? */
  184. #define ELF_EXEC_PAGESIZE PAGE_SIZE
  185. /*
  186. * This is the location that an ET_DYN program is loaded if exec'ed. Typical
  187. * use of this is to invoke "./ld.so someprog" to test out a new version of
  188. * the loader. We need to make sure that it is out of the way of the program
  189. * that it will "exec", and that there is sufficient room for the brk.
  190. */
  191. #define ELF_ET_DYN_BASE 0x08000000UL
  192. /*
  193. * This yields a mask that user programs can use to figure out what
  194. * instruction set this cpu supports.
  195. */
  196. #define ELF_HWCAP (0)
  197. /*
  198. * This yields a string that ld.so will use to load implementation
  199. * specific libraries for optimization. This is more specific in
  200. * intent than poking at uname or /proc/cpuinfo.
  201. */
  202. #define ELF_PLATFORM (NULL)
  203. #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
  204. struct linux_binprm;
  205. extern int arch_setup_additional_pages(struct linux_binprm *bprm,
  206. int uses_interp);
  207. #endif