elf-i386.h 5.0 KB

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