elf.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Copyright 2003 PathScale, Inc.
  3. * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  4. *
  5. * Licensed under the GPL
  6. */
  7. #ifndef __UM_ELF_X86_64_H
  8. #define __UM_ELF_X86_64_H
  9. #include <asm/user.h>
  10. #include "skas.h"
  11. /* x86-64 relocation types, taken from asm-x86_64/elf.h */
  12. #define R_X86_64_NONE 0 /* No reloc */
  13. #define R_X86_64_64 1 /* Direct 64 bit */
  14. #define R_X86_64_PC32 2 /* PC relative 32 bit signed */
  15. #define R_X86_64_GOT32 3 /* 32 bit GOT entry */
  16. #define R_X86_64_PLT32 4 /* 32 bit PLT address */
  17. #define R_X86_64_COPY 5 /* Copy symbol at runtime */
  18. #define R_X86_64_GLOB_DAT 6 /* Create GOT entry */
  19. #define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */
  20. #define R_X86_64_RELATIVE 8 /* Adjust by program base */
  21. #define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative
  22. offset to GOT */
  23. #define R_X86_64_32 10 /* Direct 32 bit zero extended */
  24. #define R_X86_64_32S 11 /* Direct 32 bit sign extended */
  25. #define R_X86_64_16 12 /* Direct 16 bit zero extended */
  26. #define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */
  27. #define R_X86_64_8 14 /* Direct 8 bit sign extended */
  28. #define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */
  29. #define R_X86_64_NUM 16
  30. typedef unsigned long elf_greg_t;
  31. #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
  32. typedef elf_greg_t elf_gregset_t[ELF_NGREG];
  33. typedef struct user_i387_struct elf_fpregset_t;
  34. /*
  35. * This is used to ensure we don't load something for the wrong architecture.
  36. */
  37. #define elf_check_arch(x) \
  38. ((x)->e_machine == EM_X86_64)
  39. #define ELF_CLASS ELFCLASS64
  40. #define ELF_DATA ELFDATA2LSB
  41. #define ELF_ARCH EM_X86_64
  42. #define ELF_PLAT_INIT(regs, load_addr) do { \
  43. PT_REGS_RBX(regs) = 0; \
  44. PT_REGS_RCX(regs) = 0; \
  45. PT_REGS_RDX(regs) = 0; \
  46. PT_REGS_RSI(regs) = 0; \
  47. PT_REGS_RDI(regs) = 0; \
  48. PT_REGS_RBP(regs) = 0; \
  49. PT_REGS_RAX(regs) = 0; \
  50. PT_REGS_R8(regs) = 0; \
  51. PT_REGS_R9(regs) = 0; \
  52. PT_REGS_R10(regs) = 0; \
  53. PT_REGS_R11(regs) = 0; \
  54. PT_REGS_R12(regs) = 0; \
  55. PT_REGS_R13(regs) = 0; \
  56. PT_REGS_R14(regs) = 0; \
  57. PT_REGS_R15(regs) = 0; \
  58. } while (0)
  59. #define ELF_CORE_COPY_REGS(pr_reg, _regs) \
  60. (pr_reg)[0] = (_regs)->regs.gp[0]; \
  61. (pr_reg)[1] = (_regs)->regs.gp[1]; \
  62. (pr_reg)[2] = (_regs)->regs.gp[2]; \
  63. (pr_reg)[3] = (_regs)->regs.gp[3]; \
  64. (pr_reg)[4] = (_regs)->regs.gp[4]; \
  65. (pr_reg)[5] = (_regs)->regs.gp[5]; \
  66. (pr_reg)[6] = (_regs)->regs.gp[6]; \
  67. (pr_reg)[7] = (_regs)->regs.gp[7]; \
  68. (pr_reg)[8] = (_regs)->regs.gp[8]; \
  69. (pr_reg)[9] = (_regs)->regs.gp[9]; \
  70. (pr_reg)[10] = (_regs)->regs.gp[10]; \
  71. (pr_reg)[11] = (_regs)->regs.gp[11]; \
  72. (pr_reg)[12] = (_regs)->regs.gp[12]; \
  73. (pr_reg)[13] = (_regs)->regs.gp[13]; \
  74. (pr_reg)[14] = (_regs)->regs.gp[14]; \
  75. (pr_reg)[15] = (_regs)->regs.gp[15]; \
  76. (pr_reg)[16] = (_regs)->regs.gp[16]; \
  77. (pr_reg)[17] = (_regs)->regs.gp[17]; \
  78. (pr_reg)[18] = (_regs)->regs.gp[18]; \
  79. (pr_reg)[19] = (_regs)->regs.gp[19]; \
  80. (pr_reg)[20] = (_regs)->regs.gp[20]; \
  81. (pr_reg)[21] = current->thread.arch.fs; \
  82. (pr_reg)[22] = 0; \
  83. (pr_reg)[23] = 0; \
  84. (pr_reg)[24] = 0; \
  85. (pr_reg)[25] = 0; \
  86. (pr_reg)[26] = 0;
  87. #define task_pt_regs(t) (&(t)->thread.regs)
  88. struct task_struct;
  89. extern int elf_core_copy_fpregs(struct task_struct *t, elf_fpregset_t *fpu);
  90. #define ELF_CORE_COPY_FPREGS(t, fpu) elf_core_copy_fpregs(t, fpu)
  91. #ifdef TIF_IA32 /* XXX */
  92. #error XXX, indeed
  93. clear_thread_flag(TIF_IA32);
  94. #endif
  95. #define ELF_EXEC_PAGESIZE 4096
  96. #define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
  97. extern long elf_aux_hwcap;
  98. #define ELF_HWCAP (elf_aux_hwcap)
  99. #define ELF_PLATFORM "x86_64"
  100. #define SET_PERSONALITY(ex) do ; while(0)
  101. #endif