binfmt_elf32.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * Support for 32-bit Linux/MIPS ELF binaries.
  3.  *
  4.  * Copyright (C) 1999, 2001 Ralf Baechle
  5.  * Copyright (C) 1999, 2001 Silicon Graphics, Inc.
  6.  *
  7.  * Heavily inspired by the 32-bit Sparc compat code which is
  8.  * Copyright (C) 1995, 1996, 1997, 1998 David S. Miller (davem@redhat.com)
  9.  * Copyright (C) 1995, 1996, 1997, 1998 Jakub Jelinek   (jj@ultra.linux.cz)
  10.  */
  11. #define ELF_ARCH EM_MIPS
  12. #define ELF_CLASS ELFCLASS32
  13. #ifdef __MIPSEB__
  14. #define ELF_DATA ELFDATA2MSB;
  15. #else /* __MIPSEL__ */
  16. #define ELF_DATA ELFDATA2LSB;
  17. #endif
  18. /* ELF register definitions */
  19. #define ELF_NGREG 45
  20. #define ELF_NFPREG 33
  21. typedef unsigned int elf_greg_t;
  22. typedef elf_greg_t elf_gregset_t[ELF_NGREG];
  23. typedef double elf_fpreg_t;
  24. typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
  25. /*
  26.  * This is used to ensure we don't load something for the wrong architecture.
  27.  */
  28. #define elf_check_arch(hdr)
  29. ({
  30. int __res = 1;
  31. struct elfhdr *__h = (hdr);
  32. if (__h->e_machine != EM_MIPS)
  33. __res = 0;
  34. if (__h->e_ident[EI_CLASS] != ELFCLASS32)
  35. __res = 0;
  36. if ((__h->e_flags & EF_MIPS_ABI2) != 0)
  37. __res = 0;
  38. if (((__h->e_flags & EF_MIPS_ABI) != 0) &&
  39.     ((__h->e_flags & EF_MIPS_ABI) != EF_MIPS_ABI_O32))
  40. __res = 0;
  41. __res;
  42. })
  43. #define TASK32_SIZE 0x80000000UL
  44. #undef ELF_ET_DYN_BASE
  45. #define ELF_ET_DYN_BASE         (TASK32_SIZE / 3 * 2)
  46. #include <asm/processor.h>
  47. #include <linux/module.h>
  48. #include <linux/config.h>
  49. #include <linux/elfcore.h>
  50. struct timeval32
  51. {
  52. int tv_sec, tv_usec;
  53. };
  54. #define elf_prstatus elf_prstatus32
  55. struct elf_prstatus32
  56. {
  57. struct elf_siginfo pr_info; /* Info associated with signal */
  58. short pr_cursig; /* Current signal */
  59. unsigned int pr_sigpend; /* Set of pending signals */
  60. unsigned int pr_sighold; /* Set of held signals */
  61. pid_t pr_pid;
  62. pid_t pr_ppid;
  63. pid_t pr_pgrp;
  64. pid_t pr_sid;
  65. struct timeval32 pr_utime; /* User time */
  66. struct timeval32 pr_stime; /* System time */
  67. struct timeval32 pr_cutime; /* Cumulative user time */
  68. struct timeval32 pr_cstime; /* Cumulative system time */
  69. elf_gregset_t pr_reg; /* GP registers */
  70. int pr_fpvalid; /* True if math co-processor being used.  */
  71. };
  72. #define elf_prpsinfo elf_prpsinfo32
  73. struct elf_prpsinfo32
  74. {
  75. char pr_state; /* numeric process state */
  76. char pr_sname; /* char for pr_state */
  77. char pr_zomb; /* zombie */
  78. char pr_nice; /* nice val */
  79. unsigned int pr_flag; /* flags */
  80. u16 pr_uid;
  81. u16 pr_gid;
  82. pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
  83. /* Lots missing */
  84. char pr_fname[16]; /* filename of executable */
  85. char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
  86. };
  87. #define elf_addr_t u32
  88. #define elf_caddr_t u32
  89. #define init_elf_binfmt init_elf32_binfmt
  90. #undef CONFIG_BINFMT_ELF
  91. #ifdef CONFIG_BINFMT_ELF32
  92. #define CONFIG_BINFMT_ELF CONFIG_BINFMT_ELF32
  93. #endif
  94. #undef CONFIG_BINFMT_ELF_MODULE
  95. #ifdef CONFIG_BINFMT_ELF32_MODULE
  96. #define CONFIG_BINFMT_ELF_MODULE CONFIG_BINFMT_ELF32_MODULE
  97. #endif
  98. MODULE_DESCRIPTION("Binary format loader for compatibility with 32bit Linux/MIPS binaries");
  99. MODULE_AUTHOR("Ralf Baechle (ralf@oss.sgi.com)");
  100. #undef MODULE_DESCRIPTION
  101. #undef MODULE_AUTHOR
  102. #include "../../../fs/binfmt_elf.c"