binfmt_elf32.c 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Support for 32-bit Linux/Parisc ELF binaries on 64 bit kernels
  4. *
  5. * Copyright (C) 2000 John Marvin
  6. * Copyright (C) 2000 Hewlett Packard Co.
  7. *
  8. * Heavily inspired from various other efforts to do the same thing
  9. * (ia64,sparc64/mips64)
  10. */
  11. /* Make sure include/asm-parisc/elf.h does the right thing */
  12. #define ELF_CLASS ELFCLASS32
  13. #define ELF_CORE_COPY_REGS(dst, pt) \
  14. memset(dst, 0, sizeof(dst)); /* don't leak any "random" bits */ \
  15. { int i; \
  16. for (i = 0; i < 32; i++) dst[i] = (elf_greg_t) pt->gr[i]; \
  17. for (i = 0; i < 8; i++) dst[32 + i] = (elf_greg_t) pt->sr[i]; \
  18. } \
  19. dst[40] = (elf_greg_t) pt->iaoq[0]; dst[41] = (elf_greg_t) pt->iaoq[1]; \
  20. dst[42] = (elf_greg_t) pt->iasq[0]; dst[43] = (elf_greg_t) pt->iasq[1]; \
  21. dst[44] = (elf_greg_t) pt->sar; dst[45] = (elf_greg_t) pt->iir; \
  22. dst[46] = (elf_greg_t) pt->isr; dst[47] = (elf_greg_t) pt->ior; \
  23. dst[48] = (elf_greg_t) mfctl(22); dst[49] = (elf_greg_t) mfctl(0); \
  24. dst[50] = (elf_greg_t) mfctl(24); dst[51] = (elf_greg_t) mfctl(25); \
  25. dst[52] = (elf_greg_t) mfctl(26); dst[53] = (elf_greg_t) mfctl(27); \
  26. dst[54] = (elf_greg_t) mfctl(28); dst[55] = (elf_greg_t) mfctl(29); \
  27. dst[56] = (elf_greg_t) mfctl(30); dst[57] = (elf_greg_t) mfctl(31); \
  28. dst[58] = (elf_greg_t) mfctl( 8); dst[59] = (elf_greg_t) mfctl( 9); \
  29. dst[60] = (elf_greg_t) mfctl(12); dst[61] = (elf_greg_t) mfctl(13); \
  30. dst[62] = (elf_greg_t) mfctl(10); dst[63] = (elf_greg_t) mfctl(15);
  31. typedef unsigned int elf_greg_t;
  32. #include <linux/spinlock.h>
  33. #include <asm/processor.h>
  34. #include <linux/module.h>
  35. #include <linux/elfcore.h>
  36. #include <linux/compat.h> /* struct compat_timeval */
  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. u16 pr_uid;
  64. u16 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 init_elf_binfmt init_elf32_binfmt
  71. #define ELF_PLATFORM ("PARISC32\0")
  72. /*
  73. * We should probably use this macro to set a flag somewhere to indicate
  74. * this is a 32 on 64 process. We could use PER_LINUX_32BIT, or we
  75. * could set a processor dependent flag in the thread_struct.
  76. */
  77. #undef SET_PERSONALITY
  78. #define SET_PERSONALITY(ex) \
  79. set_thread_flag(TIF_32BIT); \
  80. current->thread.map_base = DEFAULT_MAP_BASE32; \
  81. current->thread.task_size = DEFAULT_TASK_SIZE32 \
  82. #undef ns_to_timeval
  83. #define ns_to_timeval ns_to_compat_timeval
  84. #include "../../../fs/binfmt_elf.c"