elf.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. * Copyright (C) 2012 ARM Ltd.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef __ASM_ELF_H
  17. #define __ASM_ELF_H
  18. #include <asm/hwcap.h>
  19. /*
  20. * ELF register definitions..
  21. */
  22. #include <asm/ptrace.h>
  23. #include <asm/user.h>
  24. typedef unsigned long elf_greg_t;
  25. #define ELF_NGREG (sizeof(struct user_pt_regs) / sizeof(elf_greg_t))
  26. #define ELF_CORE_COPY_REGS(dest, regs) \
  27. *(struct user_pt_regs *)&(dest) = (regs)->user_regs;
  28. typedef elf_greg_t elf_gregset_t[ELF_NGREG];
  29. typedef struct user_fpsimd_state elf_fpregset_t;
  30. #define EM_AARCH64 183
  31. /*
  32. * AArch64 static relocation types.
  33. */
  34. /* Miscellaneous. */
  35. #define R_ARM_NONE 0
  36. #define R_AARCH64_NONE 256
  37. /* Data. */
  38. #define R_AARCH64_ABS64 257
  39. #define R_AARCH64_ABS32 258
  40. #define R_AARCH64_ABS16 259
  41. #define R_AARCH64_PREL64 260
  42. #define R_AARCH64_PREL32 261
  43. #define R_AARCH64_PREL16 262
  44. /* Instructions. */
  45. #define R_AARCH64_MOVW_UABS_G0 263
  46. #define R_AARCH64_MOVW_UABS_G0_NC 264
  47. #define R_AARCH64_MOVW_UABS_G1 265
  48. #define R_AARCH64_MOVW_UABS_G1_NC 266
  49. #define R_AARCH64_MOVW_UABS_G2 267
  50. #define R_AARCH64_MOVW_UABS_G2_NC 268
  51. #define R_AARCH64_MOVW_UABS_G3 269
  52. #define R_AARCH64_MOVW_SABS_G0 270
  53. #define R_AARCH64_MOVW_SABS_G1 271
  54. #define R_AARCH64_MOVW_SABS_G2 272
  55. #define R_AARCH64_LD_PREL_LO19 273
  56. #define R_AARCH64_ADR_PREL_LO21 274
  57. #define R_AARCH64_ADR_PREL_PG_HI21 275
  58. #define R_AARCH64_ADR_PREL_PG_HI21_NC 276
  59. #define R_AARCH64_ADD_ABS_LO12_NC 277
  60. #define R_AARCH64_LDST8_ABS_LO12_NC 278
  61. #define R_AARCH64_TSTBR14 279
  62. #define R_AARCH64_CONDBR19 280
  63. #define R_AARCH64_JUMP26 282
  64. #define R_AARCH64_CALL26 283
  65. #define R_AARCH64_LDST16_ABS_LO12_NC 284
  66. #define R_AARCH64_LDST32_ABS_LO12_NC 285
  67. #define R_AARCH64_LDST64_ABS_LO12_NC 286
  68. #define R_AARCH64_LDST128_ABS_LO12_NC 299
  69. #define R_AARCH64_MOVW_PREL_G0 287
  70. #define R_AARCH64_MOVW_PREL_G0_NC 288
  71. #define R_AARCH64_MOVW_PREL_G1 289
  72. #define R_AARCH64_MOVW_PREL_G1_NC 290
  73. #define R_AARCH64_MOVW_PREL_G2 291
  74. #define R_AARCH64_MOVW_PREL_G2_NC 292
  75. #define R_AARCH64_MOVW_PREL_G3 293
  76. /*
  77. * These are used to set parameters in the core dumps.
  78. */
  79. #define ELF_CLASS ELFCLASS64
  80. #define ELF_DATA ELFDATA2LSB
  81. #define ELF_ARCH EM_AARCH64
  82. #define ELF_PLATFORM_SIZE 16
  83. #define ELF_PLATFORM ("aarch64")
  84. /*
  85. * This is used to ensure we don't load something for the wrong architecture.
  86. */
  87. #define elf_check_arch(x) ((x)->e_machine == EM_AARCH64)
  88. #define elf_read_implies_exec(ex,stk) (stk != EXSTACK_DISABLE_X)
  89. #define CORE_DUMP_USE_REGSET
  90. #define ELF_EXEC_PAGESIZE PAGE_SIZE
  91. /*
  92. * This is the location that an ET_DYN program is loaded if exec'ed. Typical
  93. * use of this is to invoke "./ld.so someprog" to test out a new version of
  94. * the loader. We need to make sure that it is out of the way of the program
  95. * that it will "exec", and that there is sufficient room for the brk.
  96. */
  97. extern unsigned long randomize_et_dyn(unsigned long base);
  98. #define ELF_ET_DYN_BASE (randomize_et_dyn(2 * TASK_SIZE_64 / 3))
  99. /*
  100. * When the program starts, a1 contains a pointer to a function to be
  101. * registered with atexit, as per the SVR4 ABI. A value of 0 means we have no
  102. * such handler.
  103. */
  104. #define ELF_PLAT_INIT(_r, load_addr) (_r)->regs[0] = 0
  105. #define SET_PERSONALITY(ex) clear_thread_flag(TIF_32BIT);
  106. #define ARCH_DLINFO \
  107. do { \
  108. NEW_AUX_ENT(AT_SYSINFO_EHDR, \
  109. (elf_addr_t)current->mm->context.vdso); \
  110. } while (0)
  111. #define ARCH_HAS_SETUP_ADDITIONAL_PAGES
  112. struct linux_binprm;
  113. extern int arch_setup_additional_pages(struct linux_binprm *bprm,
  114. int uses_interp);
  115. /* 1GB of VA */
  116. #ifdef CONFIG_COMPAT
  117. #define STACK_RND_MASK (test_thread_flag(TIF_32BIT) ? \
  118. 0x7ff >> (PAGE_SHIFT - 12) : \
  119. 0x3ffff >> (PAGE_SHIFT - 12))
  120. #else
  121. #define STACK_RND_MASK (0x3ffff >> (PAGE_SHIFT - 12))
  122. #endif
  123. struct mm_struct;
  124. extern unsigned long arch_randomize_brk(struct mm_struct *mm);
  125. #define arch_randomize_brk arch_randomize_brk
  126. #ifdef CONFIG_COMPAT
  127. #define EM_ARM 40
  128. #define COMPAT_ELF_PLATFORM ("v8l")
  129. #define COMPAT_ELF_ET_DYN_BASE (randomize_et_dyn(2 * TASK_SIZE_32 / 3))
  130. /* AArch32 registers. */
  131. #define COMPAT_ELF_NGREG 18
  132. typedef unsigned int compat_elf_greg_t;
  133. typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
  134. /* AArch32 EABI. */
  135. #define EF_ARM_EABI_MASK 0xff000000
  136. #define compat_elf_check_arch(x) (((x)->e_machine == EM_ARM) && \
  137. ((x)->e_flags & EF_ARM_EABI_MASK))
  138. #define compat_start_thread compat_start_thread
  139. #define COMPAT_SET_PERSONALITY(ex) set_thread_flag(TIF_32BIT);
  140. #define COMPAT_ARCH_DLINFO
  141. extern int aarch32_setup_vectors_page(struct linux_binprm *bprm,
  142. int uses_interp);
  143. #define compat_arch_setup_additional_pages \
  144. aarch32_setup_vectors_page
  145. #endif /* CONFIG_COMPAT */
  146. #endif