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

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * Support for 32-bit Linux/Parisc ELF binaries on 64 bit kernels
  3.  *
  4.  * Copyright (C) 2000 John Marvin
  5.  * Copyright (C) 2000 Hewlett Packard Co.
  6.  *
  7.  * Heavily inspired from various other efforts to do the same thing
  8.  * (ia64,sparc64/mips64)
  9.  */
  10. /* Make sure include/asm-parisc/elf.h does the right thing */
  11. #define ELF_CLASS ELFCLASS32
  12. typedef unsigned int elf_greg_t;
  13. #include <linux/spinlock.h>
  14. #include <asm/processor.h>
  15. #include <linux/module.h>
  16. #include <linux/config.h>
  17. #include <linux/elfcore.h>
  18. #include "sys32.h" /* struct timeval32 */
  19. #define elf_prstatus elf_prstatus32
  20. struct elf_prstatus32
  21. {
  22. struct elf_siginfo pr_info; /* Info associated with signal */
  23. short pr_cursig; /* Current signal */
  24. unsigned int pr_sigpend; /* Set of pending signals */
  25. unsigned int pr_sighold; /* Set of held signals */
  26. pid_t pr_pid;
  27. pid_t pr_ppid;
  28. pid_t pr_pgrp;
  29. pid_t pr_sid;
  30. struct timeval32 pr_utime; /* User time */
  31. struct timeval32 pr_stime; /* System time */
  32. struct timeval32 pr_cutime; /* Cumulative user time */
  33. struct timeval32 pr_cstime; /* Cumulative system time */
  34. elf_gregset_t pr_reg; /* GP registers */
  35. int pr_fpvalid; /* True if math co-processor being used.  */
  36. };
  37. #define elf_prpsinfo elf_prpsinfo32
  38. struct elf_prpsinfo32
  39. {
  40. char pr_state; /* numeric process state */
  41. char pr_sname; /* char for pr_state */
  42. char pr_zomb; /* zombie */
  43. char pr_nice; /* nice val */
  44. unsigned int pr_flag; /* flags */
  45. u16 pr_uid;
  46. u16 pr_gid;
  47. pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
  48. /* Lots missing */
  49. char pr_fname[16]; /* filename of executable */
  50. char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
  51. };
  52. #define elf_addr_t unsigned int
  53. typedef unsigned int elf_caddr_t;
  54. #define init_elf_binfmt init_elf32_binfmt
  55. #define ELF_PLATFORM  ("PARISC32")
  56. #define ELF_CORE_COPY_REGS(dst, pt)
  57. memset(dst, 0, sizeof(dst)); /* don't leak any "random" bits */ 
  58. { int i; 
  59. for (i = 0; i < 32; i++) dst[i] = (elf_greg_t) pt->gr[i]; 
  60. for (i = 0; i < 8; i++) dst[32 + i] = (elf_greg_t) pt->sr[i]; 
  61. dst[40] = (elf_greg_t) pt->iaoq[0]; dst[41] = (elf_greg_t) pt->iaoq[1]; 
  62. dst[42] = (elf_greg_t) pt->iasq[0]; dst[43] = (elf_greg_t) pt->iasq[1]; 
  63. dst[44] = (elf_greg_t) pt->sar;   dst[45] = (elf_greg_t) pt->iir; 
  64. dst[46] = (elf_greg_t) pt->isr;   dst[47] = (elf_greg_t) pt->ior; 
  65. dst[48] = (elf_greg_t) mfctl(22); dst[49] = (elf_greg_t) mfctl(0); 
  66. dst[50] = (elf_greg_t) mfctl(24); dst[51] = (elf_greg_t) mfctl(25); 
  67. dst[52] = (elf_greg_t) mfctl(26); dst[53] = (elf_greg_t) mfctl(27); 
  68. dst[54] = (elf_greg_t) mfctl(28); dst[55] = (elf_greg_t) mfctl(29); 
  69. dst[56] = (elf_greg_t) mfctl(30); dst[57] = (elf_greg_t) mfctl(31); 
  70. dst[58] = (elf_greg_t) mfctl( 8); dst[59] = (elf_greg_t) mfctl( 9); 
  71. dst[60] = (elf_greg_t) mfctl(12); dst[61] = (elf_greg_t) mfctl(13); 
  72. dst[62] = (elf_greg_t) mfctl(10); dst[63] = (elf_greg_t) mfctl(15);
  73. /*
  74.  * We should probably use this macro to set a flag somewhere to indicate
  75.  * this is a 32 on 64 process. We could use PER_LINUX_32BIT, or we
  76.  * could set a processor dependent flag in the thread_struct.
  77.  */
  78. #define SET_PERSONALITY(ex, ibcs2) 
  79. current->personality = PER_LINUX_32BIT
  80. #include "../../../fs/binfmt_elf.c"