binfmt_elf32.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * binfmt_elf32.c: Support 32-bit PPC ELF binaries on Power3 and followons.
  3. * based on the SPARC64 version.
  4. * Copyright (C) 1995, 1996, 1997, 1998 David S. Miller (davem@redhat.com)
  5. * Copyright (C) 1995, 1996, 1997, 1998 Jakub Jelinek (jj@ultra.linux.cz)
  6. *
  7. * Copyright (C) 2000,2001 Ken Aaker (kdaaker@rchland.vnet.ibm.com), IBM Corp
  8. * Copyright (C) 2001 Anton Blanchard (anton@au.ibm.com), IBM
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version
  13. * 2 of the License, or (at your option) any later version.
  14. */
  15. #include <asm/processor.h>
  16. #include <linux/module.h>
  17. #include <linux/compat.h>
  18. #include <linux/elfcore-compat.h>
  19. #undef ELF_ARCH
  20. #undef ELF_CLASS
  21. #define ELF_CLASS ELFCLASS32
  22. #define ELF_ARCH EM_PPC
  23. #undef elfhdr
  24. #undef elf_phdr
  25. #undef elf_note
  26. #undef elf_addr_t
  27. #define elfhdr elf32_hdr
  28. #define elf_phdr elf32_phdr
  29. #define elf_note elf32_note
  30. #define elf_addr_t Elf32_Off
  31. #define elf_prstatus compat_elf_prstatus
  32. #define elf_prpsinfo compat_elf_prpsinfo
  33. #define elf_core_copy_regs compat_elf_core_copy_regs
  34. static inline void compat_elf_core_copy_regs(compat_elf_gregset_t *elf_regs,
  35. struct pt_regs *regs)
  36. {
  37. PPC_ELF_CORE_COPY_REGS((*elf_regs), regs);
  38. }
  39. #define elf_core_copy_task_regs compat_elf_core_copy_task_regs
  40. static int compat_elf_core_copy_task_regs(struct task_struct *tsk,
  41. compat_elf_gregset_t *elf_regs)
  42. {
  43. struct pt_regs *regs = tsk->thread.regs;
  44. if (regs)
  45. compat_elf_core_copy_regs(elf_regs, regs);
  46. return 1;
  47. }
  48. #include <linux/time.h>
  49. #undef cputime_to_timeval
  50. #define cputime_to_timeval cputime_to_compat_timeval
  51. static __inline__ void
  52. cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
  53. {
  54. unsigned long jiffies = cputime_to_jiffies(cputime);
  55. value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
  56. value->tv_sec = jiffies / HZ;
  57. }
  58. #define init_elf_binfmt init_elf32_binfmt
  59. #include "../../../fs/binfmt_elf.c"