1/*-
2 * Copyright (c) 2004 Tim J. Robbins
3 * Copyright (c) 2003 Peter Wemm
4 * Copyright (c) 2002 Doug Rabson
5 * Copyright (c) 1998-1999 Andrew Gallatin
6 * Copyright (c) 1994-1996 S�ren Schmidt
7 * All rights reserved.
8 *
--- 17 unchanged lines hidden (view full) ---
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/amd64/linux32/linux32_sysvec.c 196512 2009-08-24 16:19:47Z bz $");
35#include "opt_compat.h"
36
37#ifndef COMPAT_IA32
38#error "Unable to compile Linux-emulator due to missing COMPAT_IA32 option!"
39#endif
40
41#define __ELF_WORD_SIZE 32
42
--- 79 unchanged lines hidden (view full) ---
122 struct image_params *iparams);
123static register_t *linux_copyout_strings(struct image_params *imgp);
124static void linux_prepsyscall(struct trapframe *tf, int *args, u_int *code,
125 caddr_t *params);
126static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
127static void exec_linux_setregs(struct thread *td, u_long entry,
128 u_long stack, u_long ps_strings);
129static void linux32_fixlimit(struct rlimit *rl, int which);
130static boolean_t linux32_trans_osrel(const Elf_Note *note, int32_t *osrel);
131
132static eventhandler_tag linux_exit_tag;
133static eventhandler_tag linux_schedtail_tag;
134static eventhandler_tag linux_exec_tag;
135
136/*
137 * Linux syscalls return negative errno's, we do positive and map them
138 * Reference:
--- 923 unchanged lines hidden (view full) ---
1062 .sv_stackprot = VM_PROT_ALL,
1063 .sv_copyout_strings = linux_copyout_strings,
1064 .sv_setregs = exec_linux_setregs,
1065 .sv_fixlimit = linux32_fixlimit,
1066 .sv_maxssiz = &linux32_maxssiz,
1067 .sv_flags = SV_ABI_LINUX | SV_ILP32 | SV_IA32
1068};
1069
1070static char GNU_ABI_VENDOR[] = "GNU";
1071static int GNULINUX_ABI_DESC = 0;
1072
1073static boolean_t
1074linux32_trans_osrel(const Elf_Note *note, int32_t *osrel)
1075{
1076 const Elf32_Word *desc;
1077 uintptr_t p;
1078
1079 p = (uintptr_t)(note + 1);
1080 p += roundup2(note->n_namesz, sizeof(Elf32_Addr));
1081
1082 desc = (const Elf32_Word *)p;
1083 if (desc[0] != GNULINUX_ABI_DESC)
1084 return (FALSE);
1085
1086 /*
1087 * For linux we encode osrel as follows (see linux_mib.c):
1088 * VVVMMMIII (version, major, minor), see linux_mib.c.
1089 */
1090 *osrel = desc[1] * 1000000 + desc[2] * 1000 + desc[3];
1091
1092 return (TRUE);
1093}
1094
1095static Elf_Brandnote linux32_brandnote = {
1096 .hdr.n_namesz = sizeof(GNU_ABI_VENDOR),
1097 .hdr.n_descsz = 16, /* XXX at least 16 */
1098 .hdr.n_type = 1,
1099 .vendor = GNU_ABI_VENDOR,
1100 .flags = BN_TRANSLATE_OSREL,
1101 .trans_osrel = linux32_trans_osrel
1102};
1103
1104static Elf32_Brandinfo linux_brand = {
1105 .brand = ELFOSABI_LINUX,
1106 .machine = EM_386,
1107 .compat_3_brand = "Linux",
1108 .emul_path = "/compat/linux",
1109 .interp_path = "/lib/ld-linux.so.1",
--- 105 unchanged lines hidden ---
2 * Copyright (c) 2004 Tim J. Robbins
3 * Copyright (c) 2003 Peter Wemm
4 * Copyright (c) 2002 Doug Rabson
5 * Copyright (c) 1998-1999 Andrew Gallatin
6 * Copyright (c) 1994-1996 S�ren Schmidt
7 * All rights reserved.
8 *
--- 17 unchanged lines hidden (view full) ---
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/amd64/linux32/linux32_sysvec.c 196512 2009-08-24 16:19:47Z bz $");
35#include "opt_compat.h"
36
37#ifndef COMPAT_IA32
38#error "Unable to compile Linux-emulator due to missing COMPAT_IA32 option!"
39#endif
40
41#define __ELF_WORD_SIZE 32
42
--- 79 unchanged lines hidden (view full) ---
122 struct image_params *iparams);
123static register_t *linux_copyout_strings(struct image_params *imgp);
124static void linux_prepsyscall(struct trapframe *tf, int *args, u_int *code,
125 caddr_t *params);
126static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
127static void exec_linux_setregs(struct thread *td, u_long entry,
128 u_long stack, u_long ps_strings);
129static void linux32_fixlimit(struct rlimit *rl, int which);
130static boolean_t linux32_trans_osrel(const Elf_Note *note, int32_t *osrel);
131
132static eventhandler_tag linux_exit_tag;
133static eventhandler_tag linux_schedtail_tag;
134static eventhandler_tag linux_exec_tag;
135
136/*
137 * Linux syscalls return negative errno's, we do positive and map them
138 * Reference:
--- 923 unchanged lines hidden (view full) ---
1062 .sv_stackprot = VM_PROT_ALL,
1063 .sv_copyout_strings = linux_copyout_strings,
1064 .sv_setregs = exec_linux_setregs,
1065 .sv_fixlimit = linux32_fixlimit,
1066 .sv_maxssiz = &linux32_maxssiz,
1067 .sv_flags = SV_ABI_LINUX | SV_ILP32 | SV_IA32
1068};
1069
1070static char GNU_ABI_VENDOR[] = "GNU";
1071static int GNULINUX_ABI_DESC = 0;
1072
1073static boolean_t
1074linux32_trans_osrel(const Elf_Note *note, int32_t *osrel)
1075{
1076 const Elf32_Word *desc;
1077 uintptr_t p;
1078
1079 p = (uintptr_t)(note + 1);
1080 p += roundup2(note->n_namesz, sizeof(Elf32_Addr));
1081
1082 desc = (const Elf32_Word *)p;
1083 if (desc[0] != GNULINUX_ABI_DESC)
1084 return (FALSE);
1085
1086 /*
1087 * For linux we encode osrel as follows (see linux_mib.c):
1088 * VVVMMMIII (version, major, minor), see linux_mib.c.
1089 */
1090 *osrel = desc[1] * 1000000 + desc[2] * 1000 + desc[3];
1091
1092 return (TRUE);
1093}
1094
1095static Elf_Brandnote linux32_brandnote = {
1096 .hdr.n_namesz = sizeof(GNU_ABI_VENDOR),
1097 .hdr.n_descsz = 16, /* XXX at least 16 */
1098 .hdr.n_type = 1,
1099 .vendor = GNU_ABI_VENDOR,
1100 .flags = BN_TRANSLATE_OSREL,
1101 .trans_osrel = linux32_trans_osrel
1102};
1103
1104static Elf32_Brandinfo linux_brand = {
1105 .brand = ELFOSABI_LINUX,
1106 .machine = EM_386,
1107 .compat_3_brand = "Linux",
1108 .emul_path = "/compat/linux",
1109 .interp_path = "/lib/ld-linux.so.1",
--- 105 unchanged lines hidden ---