binfmt_elfn32.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Support for n32 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 long 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 elfn32_check_arch
  30. #define TASK32_SIZE 0x7fff8000UL
  31. #undef ELF_ET_DYN_BASE
  32. #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
  33. #include <asm/processor.h>
  34. #include <linux/elfcore.h>
  35. #include <linux/compat.h>
  36. #include <linux/math64.h>
  37. #define elf_prstatus elf_prstatus32
  38. struct elf_prstatus32
  39. {
  40. struct elf_siginfo pr_info; /* Info associated with signal */
  41. short pr_cursig; /* Current signal */
  42. unsigned int pr_sigpend; /* Set of pending signals */
  43. unsigned int pr_sighold; /* Set of held signals */
  44. pid_t pr_pid;
  45. pid_t pr_ppid;
  46. pid_t pr_pgrp;
  47. pid_t pr_sid;
  48. struct compat_timeval pr_utime; /* User time */
  49. struct compat_timeval pr_stime; /* System time */
  50. struct compat_timeval pr_cutime;/* Cumulative user time */
  51. struct compat_timeval pr_cstime;/* Cumulative system time */
  52. elf_gregset_t pr_reg; /* GP registers */
  53. int pr_fpvalid; /* True if math co-processor being used. */
  54. };
  55. #define elf_prpsinfo elf_prpsinfo32
  56. struct elf_prpsinfo32
  57. {
  58. char pr_state; /* numeric process state */
  59. char pr_sname; /* char for pr_state */
  60. char pr_zomb; /* zombie */
  61. char pr_nice; /* nice val */
  62. unsigned int pr_flag; /* flags */
  63. __kernel_uid_t pr_uid;
  64. __kernel_gid_t pr_gid;
  65. pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
  66. /* Lots missing */
  67. char pr_fname[16]; /* filename of executable */
  68. char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
  69. };
  70. #define elf_caddr_t u32
  71. #define init_elf_binfmt init_elfn32_binfmt
  72. #define jiffies_to_timeval jiffies_to_compat_timeval
  73. static __inline__ void
  74. jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
  75. {
  76. /*
  77. * Convert jiffies to nanoseconds and separate with
  78. * one divide.
  79. */
  80. u64 nsec = (u64)jiffies * TICK_NSEC;
  81. u32 rem;
  82. value->tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
  83. value->tv_usec = rem / NSEC_PER_USEC;
  84. }
  85. #define ELF_CORE_EFLAGS EF_MIPS_ABI2
  86. #undef TASK_SIZE
  87. #define TASK_SIZE TASK_SIZE32
  88. #undef cputime_to_timeval
  89. #define cputime_to_timeval cputime_to_compat_timeval
  90. static __inline__ void
  91. cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
  92. {
  93. unsigned long jiffies = cputime_to_jiffies(cputime);
  94. value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
  95. value->tv_sec = jiffies / HZ;
  96. }
  97. #include "../../../fs/binfmt_elf.c"