elf.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. #ifndef _ASM_TILE_ELF_H
  15. #define _ASM_TILE_ELF_H
  16. /*
  17. * ELF register definitions.
  18. */
  19. #include <arch/chip.h>
  20. #include <linux/ptrace.h>
  21. #include <linux/elf-em.h>
  22. #include <asm/byteorder.h>
  23. #include <asm/page.h>
  24. typedef unsigned long elf_greg_t;
  25. #define ELF_NGREG (sizeof(struct pt_regs) / sizeof(elf_greg_t))
  26. typedef elf_greg_t elf_gregset_t[ELF_NGREG];
  27. /* Provide a nominal data structure. */
  28. #define ELF_NFPREG 0
  29. typedef double elf_fpreg_t;
  30. typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
  31. #ifdef __tilegx__
  32. #define ELF_CLASS ELFCLASS64
  33. #else
  34. #define ELF_CLASS ELFCLASS32
  35. #endif
  36. #ifdef __BIG_ENDIAN__
  37. #define ELF_DATA ELFDATA2MSB
  38. #else
  39. #define ELF_DATA ELFDATA2LSB
  40. #endif
  41. /*
  42. * There seems to be a bug in how compat_binfmt_elf.c works: it
  43. * #undefs ELF_ARCH, but it is then used in binfmt_elf.c for fill_note_info().
  44. * Hack around this by providing an enum value of ELF_ARCH.
  45. */
  46. enum { ELF_ARCH = CHIP_ELF_TYPE() };
  47. #define ELF_ARCH ELF_ARCH
  48. /*
  49. * This is used to ensure we don't load something for the wrong architecture.
  50. */
  51. #define elf_check_arch(x) \
  52. ((x)->e_ident[EI_CLASS] == ELF_CLASS && \
  53. (x)->e_ident[EI_DATA] == ELF_DATA && \
  54. (x)->e_machine == CHIP_ELF_TYPE())
  55. /* The module loader only handles a few relocation types. */
  56. #ifndef __tilegx__
  57. #define R_TILE_32 1
  58. #define R_TILE_JOFFLONG_X1 15
  59. #define R_TILE_IMM16_X0_LO 25
  60. #define R_TILE_IMM16_X1_LO 26
  61. #define R_TILE_IMM16_X0_HA 29
  62. #define R_TILE_IMM16_X1_HA 30
  63. #else
  64. #define R_TILEGX_64 1
  65. #define R_TILEGX_JUMPOFF_X1 21
  66. #define R_TILEGX_IMM16_X0_HW0 36
  67. #define R_TILEGX_IMM16_X1_HW0 37
  68. #define R_TILEGX_IMM16_X0_HW1 38
  69. #define R_TILEGX_IMM16_X1_HW1 39
  70. #define R_TILEGX_IMM16_X0_HW2_LAST 48
  71. #define R_TILEGX_IMM16_X1_HW2_LAST 49
  72. #endif
  73. /* Use standard page size for core dumps. */
  74. #define ELF_EXEC_PAGESIZE PAGE_SIZE
  75. /*
  76. * This is the location that an ET_DYN program is loaded if exec'ed. Typical
  77. * use of this is to invoke "./ld.so someprog" to test out a new version of
  78. * the loader. We need to make sure that it is out of the way of the program
  79. * that it will "exec", and that there is sufficient room for the brk.
  80. */
  81. #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
  82. #define ELF_CORE_COPY_REGS(_dest, _regs) \
  83. memcpy((char *) &_dest, (char *) _regs, \
  84. sizeof(struct pt_regs));
  85. /* No additional FP registers to copy. */
  86. #define ELF_CORE_COPY_FPREGS(t, fpu) 0
  87. /*
  88. * This yields a mask that user programs can use to figure out what
  89. * instruction set this CPU supports. This could be done in user space,
  90. * but it's not easy, and we've already done it here.
  91. */
  92. #define ELF_HWCAP (0)
  93. /*
  94. * This yields a string that ld.so will use to load implementation
  95. * specific libraries for optimization. This is more specific in
  96. * intent than poking at uname or /proc/cpuinfo.
  97. */
  98. #define ELF_PLATFORM (NULL)
  99. extern void elf_plat_init(struct pt_regs *regs, unsigned long load_addr);
  100. #define ELF_PLAT_INIT(_r, load_addr) elf_plat_init(_r, load_addr)
  101. extern int dump_task_regs(struct task_struct *, elf_gregset_t *);
  102. #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
  103. /* Tilera Linux has no personalities currently, so no need to do anything. */
  104. #define SET_PERSONALITY(ex) do { } while (0)
  105. #define ARCH_HAS_SETUP_ADDITIONAL_PAGES
  106. /* Support auto-mapping of the user interrupt vectors. */
  107. struct linux_binprm;
  108. extern int arch_setup_additional_pages(struct linux_binprm *bprm,
  109. int executable_stack);
  110. /* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
  111. #define ARCH_DLINFO \
  112. do { \
  113. NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_BASE); \
  114. } while (0)
  115. struct mm_struct;
  116. extern unsigned long arch_randomize_brk(struct mm_struct *mm);
  117. #define arch_randomize_brk arch_randomize_brk
  118. #ifdef CONFIG_COMPAT
  119. #define COMPAT_ELF_PLATFORM "tilegx-m32"
  120. /*
  121. * "Compat" binaries have the same machine type, but 32-bit class,
  122. * since they're not a separate machine type, but just a 32-bit
  123. * variant of the standard 64-bit architecture.
  124. */
  125. #define compat_elf_check_arch(x) \
  126. ((x)->e_ident[EI_CLASS] == ELFCLASS32 && \
  127. (x)->e_machine == CHIP_ELF_TYPE())
  128. #define compat_start_thread(regs, ip, usp) do { \
  129. regs->pc = ptr_to_compat_reg((void *)(ip)); \
  130. regs->sp = ptr_to_compat_reg((void *)(usp)); \
  131. single_step_execve(); \
  132. } while (0)
  133. /*
  134. * Use SET_PERSONALITY to indicate compatibility via TS_COMPAT.
  135. */
  136. #undef SET_PERSONALITY
  137. #define SET_PERSONALITY(ex) \
  138. do { \
  139. set_personality(PER_LINUX | (current->personality & (~PER_MASK))); \
  140. current_thread_info()->status &= ~TS_COMPAT; \
  141. } while (0)
  142. #define COMPAT_SET_PERSONALITY(ex) \
  143. do { \
  144. set_personality(PER_LINUX | (current->personality & (~PER_MASK))); \
  145. current_thread_info()->status |= TS_COMPAT; \
  146. } while (0)
  147. #define COMPAT_ELF_ET_DYN_BASE (0xffffffff / 3 * 2)
  148. #endif /* CONFIG_COMPAT */
  149. #define CORE_DUMP_USE_REGSET
  150. #endif /* _ASM_TILE_ELF_H */