elf-i386.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
  3. * Licensed under the GPL
  4. */
  5. #ifndef __UM_ELF_I386_H
  6. #define __UM_ELF_I386_H
  7. #include <linux/sched.h>
  8. #include "skas.h"
  9. #define R_386_NONE 0
  10. #define R_386_32 1
  11. #define R_386_PC32 2
  12. #define R_386_GOT32 3
  13. #define R_386_PLT32 4
  14. #define R_386_COPY 5
  15. #define R_386_GLOB_DAT 6
  16. #define R_386_JMP_SLOT 7
  17. #define R_386_RELATIVE 8
  18. #define R_386_GOTOFF 9
  19. #define R_386_GOTPC 10
  20. #define R_386_NUM 11
  21. typedef unsigned long elf_greg_t;
  22. #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
  23. typedef elf_greg_t elf_gregset_t[ELF_NGREG];
  24. typedef struct user_i387_struct elf_fpregset_t;
  25. /*
  26. * This is used to ensure we don't load something for the wrong architecture.
  27. */
  28. #define elf_check_arch(x) \
  29. (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486))
  30. #define ELF_CLASS ELFCLASS32
  31. #define ELF_DATA ELFDATA2LSB
  32. #define ELF_ARCH EM_386
  33. #define ELF_PLAT_INIT(regs, load_addr) do { \
  34. PT_REGS_EBX(regs) = 0; \
  35. PT_REGS_ECX(regs) = 0; \
  36. PT_REGS_EDX(regs) = 0; \
  37. PT_REGS_ESI(regs) = 0; \
  38. PT_REGS_EDI(regs) = 0; \
  39. PT_REGS_EBP(regs) = 0; \
  40. PT_REGS_EAX(regs) = 0; \
  41. } while(0)
  42. #define USE_ELF_CORE_DUMP
  43. #define ELF_EXEC_PAGESIZE 4096
  44. #define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
  45. /* Shamelessly stolen from include/asm-i386/elf.h */
  46. #define ELF_CORE_COPY_REGS(pr_reg, regs) do { \
  47. pr_reg[0] = PT_REGS_EBX(regs); \
  48. pr_reg[1] = PT_REGS_ECX(regs); \
  49. pr_reg[2] = PT_REGS_EDX(regs); \
  50. pr_reg[3] = PT_REGS_ESI(regs); \
  51. pr_reg[4] = PT_REGS_EDI(regs); \
  52. pr_reg[5] = PT_REGS_EBP(regs); \
  53. pr_reg[6] = PT_REGS_EAX(regs); \
  54. pr_reg[7] = PT_REGS_DS(regs); \
  55. pr_reg[8] = PT_REGS_ES(regs); \
  56. /* fake once used fs and gs selectors? */ \
  57. pr_reg[9] = PT_REGS_DS(regs); \
  58. pr_reg[10] = PT_REGS_DS(regs); \
  59. pr_reg[11] = PT_REGS_SYSCALL_NR(regs); \
  60. pr_reg[12] = PT_REGS_IP(regs); \
  61. pr_reg[13] = PT_REGS_CS(regs); \
  62. pr_reg[14] = PT_REGS_EFLAGS(regs); \
  63. pr_reg[15] = PT_REGS_SP(regs); \
  64. pr_reg[16] = PT_REGS_SS(regs); \
  65. } while(0);
  66. static inline int elf_core_copy_fpregs(struct task_struct *t,
  67. elf_fpregset_t *fpu)
  68. {
  69. int cpu = ((struct thread_info *) t->stack)->cpu;
  70. return save_fp_registers(userspace_pid[cpu], (unsigned long *) fpu);
  71. }
  72. #define ELF_CORE_COPY_FPREGS(t, fpu) elf_core_copy_fpregs(t, fpu)
  73. extern long elf_aux_hwcap;
  74. #define ELF_HWCAP (elf_aux_hwcap)
  75. extern char * elf_aux_platform;
  76. #define ELF_PLATFORM (elf_aux_platform)
  77. #define SET_PERSONALITY(ex, ibcs2) do ; while(0)
  78. extern unsigned long vsyscall_ehdr;
  79. extern unsigned long vsyscall_end;
  80. extern unsigned long __kernel_vsyscall;
  81. #define VSYSCALL_BASE vsyscall_ehdr
  82. #define VSYSCALL_END vsyscall_end
  83. /*
  84. * This is the range that is readable by user mode, and things
  85. * acting like user mode such as get_user_pages.
  86. */
  87. #define FIXADDR_USER_START VSYSCALL_BASE
  88. #define FIXADDR_USER_END VSYSCALL_END
  89. /*
  90. * Architecture-neutral AT_ values in 0-17, leave some room
  91. * for more of them, start the x86-specific ones at 32.
  92. */
  93. #define AT_SYSINFO 32
  94. #define AT_SYSINFO_EHDR 33
  95. #define ARCH_DLINFO \
  96. do { \
  97. if ( vsyscall_ehdr ) { \
  98. NEW_AUX_ENT(AT_SYSINFO, __kernel_vsyscall); \
  99. NEW_AUX_ENT(AT_SYSINFO_EHDR, vsyscall_ehdr); \
  100. } \
  101. } while (0)
  102. /*
  103. * These macros parameterize elf_core_dump in fs/binfmt_elf.c to write out
  104. * extra segments containing the vsyscall DSO contents. Dumping its
  105. * contents makes post-mortem fully interpretable later without matching up
  106. * the same kernel and hardware config to see what PC values meant.
  107. * Dumping its extra ELF program headers includes all the other information
  108. * a debugger needs to easily find how the vsyscall DSO was being used.
  109. */
  110. #define ELF_CORE_EXTRA_PHDRS \
  111. (vsyscall_ehdr ? (((struct elfhdr *)vsyscall_ehdr)->e_phnum) : 0 )
  112. #define ELF_CORE_WRITE_EXTRA_PHDRS \
  113. if ( vsyscall_ehdr ) { \
  114. const struct elfhdr *const ehdrp = (struct elfhdr *)vsyscall_ehdr; \
  115. const struct elf_phdr *const phdrp = \
  116. (const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff); \
  117. int i; \
  118. Elf32_Off ofs = 0; \
  119. for (i = 0; i < ehdrp->e_phnum; ++i) { \
  120. struct elf_phdr phdr = phdrp[i]; \
  121. if (phdr.p_type == PT_LOAD) { \
  122. ofs = phdr.p_offset = offset; \
  123. offset += phdr.p_filesz; \
  124. } \
  125. else \
  126. phdr.p_offset += ofs; \
  127. phdr.p_paddr = 0; /* match other core phdrs */ \
  128. DUMP_WRITE(&phdr, sizeof(phdr)); \
  129. } \
  130. }
  131. #define ELF_CORE_WRITE_EXTRA_DATA \
  132. if ( vsyscall_ehdr ) { \
  133. const struct elfhdr *const ehdrp = (struct elfhdr *)vsyscall_ehdr; \
  134. const struct elf_phdr *const phdrp = \
  135. (const struct elf_phdr *) (vsyscall_ehdr + ehdrp->e_phoff); \
  136. int i; \
  137. for (i = 0; i < ehdrp->e_phnum; ++i) { \
  138. if (phdrp[i].p_type == PT_LOAD) \
  139. DUMP_WRITE((void *) phdrp[i].p_vaddr, \
  140. phdrp[i].p_filesz); \
  141. } \
  142. }
  143. #endif
  144. /*
  145. * Overrides for Emacs so that we follow Linus's tabbing style.
  146. * Emacs will notice this stuff at the end of the file and automatically
  147. * adjust the settings for this buffer only. This must remain at the end
  148. * of the file.
  149. * ---------------------------------------------------------------------------
  150. * Local variables:
  151. * c-file-style: "linux"
  152. * End:
  153. */