2 * Support for 32-bit Linux for S390 ELF binaries.
4 * Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
5 * Author(s): Gerhard Tonn (ton@de.ibm.com)
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)
12 #define __ASMS390_ELF_H
14 #include <linux/time.h>
17 * These are used to set parameters in the core dumps.
19 #define ELF_CLASS ELFCLASS32
20 #define ELF_DATA ELFDATA2MSB
21 #define ELF_ARCH EM_S390
24 * This is used to ensure we don't load something for the wrong architecture.
26 #define elf_check_arch(x) \
27 (((x)->e_machine == EM_S390 || (x)->e_machine == EM_S390_OLD) \
28 && (x)->e_ident[EI_CLASS] == ELF_CLASS)
30 /* ELF register definitions */
35 /* For SVR4/S390 the function pointer to be registered with `atexit` is
37 #define ELF_PLAT_INIT(_r, load_addr) \
42 #define USE_ELF_CORE_DUMP
43 #define ELF_EXEC_PAGESIZE 4096
45 /* This is the location that an ET_DYN program is loaded if exec'ed. Typical
46 use of this is to invoke "./ld.so someprog" to test out a new version of
47 the loader. We need to make sure that it is out of the way of the program
48 that it will "exec", and that there is sufficient room for the brk. */
50 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
52 /* Wow, the "main" arch needs arch dependent functions too.. :) */
54 /* regs is struct pt_regs, pr_reg is elf_gregset_t (which is
55 now struct_user_regs, they are different) */
57 #define ELF_CORE_COPY_REGS(pr_reg, regs) dump_regs32(regs, &pr_reg);
60 /* This yields a mask that user programs can use to figure out what
61 instruction set this CPU supports. */
65 /* This yields a string that ld.so will use to load implementation
66 specific libraries for optimization. This is more specific in
67 intent than poking at uname or /proc/cpuinfo.
69 For the moment, we have only optimizations for the Intel generations,
70 but that could change... */
72 #define ELF_PLATFORM (NULL)
74 #define SET_PERSONALITY(ex, ibcs2) \
77 set_personality(PER_SVR4); \
78 else if (current->personality != PER_LINUX32) \
79 set_personality(PER_LINUX); \
80 set_thread_flag(TIF_31BIT); \
83 #include "compat_linux.h"
85 typedef _s390_fp_regs32 elf_fpregset_t;
91 __u32 gprs[__NUM_GPRS];
92 __u32 acrs[__NUM_ACRS];
95 typedef s390_regs32 elf_gregset_t;
97 static inline int dump_regs32(struct pt_regs *ptregs, elf_gregset_t *regs)
101 memcpy(®s->psw.mask, &ptregs->psw.mask, 4);
102 memcpy(®s->psw.addr, &ptregs->psw.addr, 4);
103 for (i = 0; i < NUM_GPRS; i++)
104 regs->gprs[i] = ptregs->gprs[i];
105 regs->orig_gpr2 = ptregs->orig_gpr2;
109 #include <asm/processor.h>
110 #include <linux/module.h>
111 #include <linux/config.h>
112 #include <linux/elfcore.h>
113 #include <linux/binfmts.h>
114 #include <linux/compat.h>
116 int setup_arg_pages32(struct linux_binprm *bprm, int executable_stack);
118 #define elf_prstatus elf_prstatus32
119 struct elf_prstatus32
121 struct elf_siginfo pr_info; /* Info associated with signal */
122 short pr_cursig; /* Current signal */
123 u32 pr_sigpend; /* Set of pending signals */
124 u32 pr_sighold; /* Set of held signals */
129 struct compat_timeval pr_utime; /* User time */
130 struct compat_timeval pr_stime; /* System time */
131 struct compat_timeval pr_cutime; /* Cumulative user time */
132 struct compat_timeval pr_cstime; /* Cumulative system time */
133 elf_gregset_t pr_reg; /* GP registers */
134 int pr_fpvalid; /* True if math co-processor being used. */
137 #define elf_prpsinfo elf_prpsinfo32
138 struct elf_prpsinfo32
140 char pr_state; /* numeric process state */
141 char pr_sname; /* char for pr_state */
142 char pr_zomb; /* zombie */
143 char pr_nice; /* nice val */
144 u32 pr_flag; /* flags */
147 pid_t pr_pid, pr_ppid, pr_pgrp, pr_sid;
149 char pr_fname[16]; /* filename of executable */
150 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
153 #include <linux/highuid.h>
155 #undef NEW_TO_OLD_UID
156 #undef NEW_TO_OLD_GID
157 #define NEW_TO_OLD_UID(uid) ((uid) > 65535) ? (u16)overflowuid : (u16)(uid)
158 #define NEW_TO_OLD_GID(gid) ((gid) > 65535) ? (u16)overflowgid : (u16)(gid)
160 #define elf_addr_t u32
162 #define init_elf_binfmt init_elf32_binfmt
166 #define start_thread start_thread31
167 #define setup_arg_pages(bprm, exec) setup_arg_pages32(bprm, exec)
169 MODULE_DESCRIPTION("Binary format loader for compatibility with 32bit Linux for S390 binaries,"
170 " Copyright 2000 IBM Corporation");
171 MODULE_AUTHOR("Gerhard Tonn <ton@de.ibm.com>");
173 #undef MODULE_DESCRIPTION
176 #define jiffies_to_timeval jiffies_to_compat_timeval
177 static __inline__ void
178 jiffies_to_compat_timeval(unsigned long jiffies, struct compat_timeval *value)
180 value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
181 value->tv_sec = jiffies / HZ;
184 #include "../../../fs/binfmt_elf.c"