binfmt_elfo32.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Support for o32 Linux/MIPS ELF binaries.
  3. * Author: Ralf Baechle (ralf@linux-mips.org)
  4. *
  5. * Copyright (C) 1999, 2001 Ralf Baechle
  6. * Copyright (C) 1999, 2001 Silicon Graphics, Inc.
  7. *
  8. * Heavily inspired by the 32-bit Sparc compat code which is
  9. * Copyright (C) 1995, 1996, 1997, 1998 David S. Miller (davem@redhat.com)
  10. * Copyright (C) 1995, 1996, 1997, 1998 Jakub Jelinek (jj@ultra.linux.cz)
  11. */
  12. #define ELF_ARCH EM_MIPS
  13. #define ELF_CLASS ELFCLASS32
  14. #ifdef __MIPSEB__
  15. #define ELF_DATA ELFDATA2MSB;
  16. #else /* __MIPSEL__ */
  17. #define ELF_DATA ELFDATA2LSB;
  18. #endif
  19. /* ELF register definitions */
  20. #define ELF_NGREG 45
  21. #define ELF_NFPREG 33
  22. typedef unsigned int elf_greg_t;
  23. typedef elf_greg_t elf_gregset_t[ELF_NGREG];
  24. typedef double elf_fpreg_t;
  25. typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
  26. /*
  27. * This is used to ensure we don't load something for the wrong architecture.
  28. */
  29. #define elf_check_arch elfo32_check_arch
  30. #ifdef CONFIG_KVM_GUEST
  31. #define TASK32_SIZE 0x3fff8000UL
  32. #else
  33. #define TASK32_SIZE 0x7fff8000UL
  34. #endif
  35. #undef ELF_ET_DYN_BASE
  36. #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
  37. #include <asm/processor.h>
  38. #include <linux/elfcore.h>
  39. #include <linux/compat.h>
  40. #include <linux/math64.h>
  41. #define elf_prstatus elf_prstatus32
  42. struct elf_prstatus32
  43. {
  44. struct elf_siginfo pr_info; /* Info associated with signal */
  45. short pr_cursig; /* Current signal */
  46. unsigned int pr_sigpend; /* Set of pending signals */
  47. unsigned int pr_sighold; /* Set of held signals */
  48. pid_t pr_pid;
  49. pid_t pr_ppid;
  50. pid_t pr_pgrp;
  51. pid_t pr_sid;
  52. struct compat_timeval pr_utime; /* User time */
  53. struct compat_timeval pr_stime; /* System time */
  54. struct compat_timeval pr_cutime;/* Cumulative user time */
  55. struct compat_timeval pr_cstime;/* Cumulative system time */
  56. elf_gregset_t pr_reg; /* GP registers */
  57. int pr_fpvalid; /* True if math co-processor being used. */
  58. };
  59. #define elf_prpsinfo elf_prpsinfo32
  60. struct elf_prpsinfo32
  61. {
  62. char pr_state; /* numeric process state */
  63. char pr_sname; /* char for pr_state */
  64. char pr_zomb; /* zombie */
  65. char pr_nice; /* nice val */
  66. unsigned int pr_flag; /* flags */
  67. __kernel_uid_t pr_uid;
  68. __kernel_gid_t pr_gid;
  69. pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
  70. /* Lots missing */
  71. char pr_fname[16]; /* filename of executable */
  72. char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
  73. };
  74. #define elf_caddr_t u32
  75. #define init_elf_binfmt init_elf32_binfmt
  76. #define jiffies_to_timeval jiffies_to_compat_timeval
  77. static inline void
  78. jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
  79. {
  80. /*
  81. * Convert jiffies to nanoseconds and separate with
  82. * one divide.
  83. */
  84. u64 nsec = (u64)jiffies * TICK_NSEC;
  85. u32 rem;
  86. value->tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
  87. value->tv_usec = rem / NSEC_PER_USEC;
  88. }
  89. #undef TASK_SIZE
  90. #define TASK_SIZE TASK_SIZE32
  91. #undef cputime_to_timeval
  92. #define cputime_to_timeval cputime_to_compat_timeval
  93. static __inline__ void
  94. cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
  95. {
  96. unsigned long jiffies = cputime_to_jiffies(cputime);
  97. value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
  98. value->tv_sec = jiffies / HZ;
  99. }
  100. #include "../../../fs/binfmt_elf.c"