Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
/*-
|
1996-03-10 08:42:54 +00:00
|
|
|
|
* Copyright (c) 1994-1996 S<EFBFBD>ren Schmidt
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
|
* are met:
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer
|
|
|
|
|
* in this position and unchanged.
|
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
2002-06-02 20:05:59 +00:00
|
|
|
|
* derived from this software without specific prior written permission
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
2003-06-10 17:02:51 +00:00
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
/* XXX we use functions that might not exist. */
|
1997-12-16 17:40:42 +00:00
|
|
|
|
#include "opt_compat.h"
|
|
|
|
|
|
|
|
|
|
#ifndef COMPAT_43
|
|
|
|
|
#error "Unable to compile Linux-emulator due to missing COMPAT_43 option!"
|
|
|
|
|
#endif
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
1999-06-28 09:12:46 +00:00
|
|
|
|
#include <sys/systm.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
|
#include <sys/exec.h>
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
#include <sys/imgact.h>
|
1998-09-14 05:36:51 +00:00
|
|
|
|
#include <sys/imgact_aout.h>
|
1996-03-10 08:42:54 +00:00
|
|
|
|
#include <sys/imgact_elf.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
|
#include <sys/lock.h>
|
1996-03-10 08:42:54 +00:00
|
|
|
|
#include <sys/malloc.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
|
#include <sys/module.h>
|
|
|
|
|
#include <sys/mutex.h>
|
|
|
|
|
#include <sys/proc.h>
|
|
|
|
|
#include <sys/signalvar.h>
|
|
|
|
|
#include <sys/sysent.h>
|
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
#include <vm/vm.h>
|
|
|
|
|
#include <vm/vm_param.h>
|
|
|
|
|
#include <vm/vm_page.h>
|
|
|
|
|
#include <vm/vm_extern.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
#include <machine/cpu.h>
|
2000-09-06 19:26:17 +00:00
|
|
|
|
#include <machine/md_var.h>
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
2000-09-06 19:26:17 +00:00
|
|
|
|
#include <alpha/linux/linux.h>
|
2000-12-03 01:30:31 +00:00
|
|
|
|
#include <alpha/linux/linux_proto.h>
|
2003-03-27 18:18:35 +00:00
|
|
|
|
#include <compat/linux/linux_mib.h>
|
2000-08-22 05:57:55 +00:00
|
|
|
|
#include <compat/linux/linux_util.h>
|
2000-09-06 19:26:17 +00:00
|
|
|
|
#undef szsigcode
|
1996-03-10 08:42:54 +00:00
|
|
|
|
|
2000-05-06 01:36:04 +00:00
|
|
|
|
MODULE_VERSION(linux, 1);
|
2000-09-06 19:26:17 +00:00
|
|
|
|
MODULE_DEPEND(linux, osf1, 1, 1, 1);
|
2001-03-05 17:59:18 +00:00
|
|
|
|
MODULE_DEPEND(linux, sysvmsg, 1, 1, 1);
|
|
|
|
|
MODULE_DEPEND(linux, sysvsem, 1, 1, 1);
|
|
|
|
|
MODULE_DEPEND(linux, sysvshm, 1, 1, 1);
|
2000-05-06 01:36:04 +00:00
|
|
|
|
|
1999-12-04 11:10:22 +00:00
|
|
|
|
MALLOC_DEFINE(M_LINUX, "linux", "Linux mode structures");
|
|
|
|
|
|
2000-04-26 20:58:40 +00:00
|
|
|
|
#if BYTE_ORDER == LITTLE_ENDIAN
|
2000-10-23 08:46:25 +00:00
|
|
|
|
#define SHELLMAGIC 0x2123 /* #! */
|
2000-04-26 20:58:40 +00:00
|
|
|
|
#else
|
2000-10-23 08:46:25 +00:00
|
|
|
|
#define SHELLMAGIC 0x2321
|
2000-04-26 20:58:40 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2001-06-13 10:58:39 +00:00
|
|
|
|
SET_DECLARE(linux_ioctl_handler_set, struct linux_ioctl_handler);
|
1999-12-04 11:10:22 +00:00
|
|
|
|
|
2000-12-05 09:06:41 +00:00
|
|
|
|
void osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code);
|
|
|
|
|
|
2003-03-21 19:49:34 +00:00
|
|
|
|
static int elf_linux_fixup(register_t **stack_base,
|
2002-03-20 18:58:47 +00:00
|
|
|
|
struct image_params *iparams);
|
|
|
|
|
static int exec_linux_imgact_try(struct image_params *iparams);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
1998-04-28 18:15:08 +00:00
|
|
|
|
static int
|
2003-03-21 19:49:34 +00:00
|
|
|
|
elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
|
1998-04-28 18:15:08 +00:00
|
|
|
|
{
|
2000-10-23 08:46:25 +00:00
|
|
|
|
Elf64_Auxargs *args;
|
2003-03-21 19:49:34 +00:00
|
|
|
|
register_t *pos;
|
1998-04-28 18:15:08 +00:00
|
|
|
|
|
2003-03-21 19:49:34 +00:00
|
|
|
|
KASSERT(curthread->td_proc == imgp->proc &&
|
2003-06-15 00:31:24 +00:00
|
|
|
|
(curthread->td_proc->p_flag & P_SA) == 0,
|
2003-03-21 19:49:34 +00:00
|
|
|
|
("unsafe elf_linux_fixup(), should be curproc"));
|
2000-10-23 08:46:25 +00:00
|
|
|
|
args = (Elf64_Auxargs *)imgp->auxargs;
|
2000-09-06 19:26:17 +00:00
|
|
|
|
pos = *stack_base + (imgp->argc + imgp->envc + 2);
|
1996-03-10 08:42:54 +00:00
|
|
|
|
|
2003-03-21 19:49:34 +00:00
|
|
|
|
if (args->trace)
|
1996-03-10 08:42:54 +00:00
|
|
|
|
AUXARGS_ENTRY(pos, AT_DEBUG, 1);
|
2003-03-21 19:49:34 +00:00
|
|
|
|
if (args->execfd != -1)
|
1996-03-10 08:42:54 +00:00
|
|
|
|
AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_PHENT, args->phent);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_BASE, args->base);
|
2001-05-25 20:33:06 +00:00
|
|
|
|
AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_ucred->cr_ruid);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_ucred->cr_svuid);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_ucred->cr_rgid);
|
|
|
|
|
AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_ucred->cr_svgid);
|
1996-03-10 08:42:54 +00:00
|
|
|
|
AUXARGS_ENTRY(pos, AT_NULL, 0);
|
|
|
|
|
|
|
|
|
|
free(imgp->auxargs, M_TEMP);
|
|
|
|
|
imgp->auxargs = NULL;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
1996-03-10 08:42:54 +00:00
|
|
|
|
(*stack_base)--;
|
2003-03-21 19:49:34 +00:00
|
|
|
|
**stack_base = (register_t)imgp->argc;
|
1996-03-10 08:42:54 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
|
2000-04-26 20:58:40 +00:00
|
|
|
|
/*
|
|
|
|
|
* If a linux binary is exec'ing something, try this image activator
|
|
|
|
|
* first. We override standard shell script execution in order to
|
|
|
|
|
* be able to modify the interpreter path. We only do this if a linux
|
|
|
|
|
* binary is doing the exec, so we do not create an EXEC module for it.
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
exec_linux_imgact_try(imgp)
|
2000-10-23 08:46:25 +00:00
|
|
|
|
struct image_params *imgp;
|
2000-04-26 20:58:40 +00:00
|
|
|
|
{
|
2000-10-23 08:46:25 +00:00
|
|
|
|
const char *head;
|
|
|
|
|
int error;
|
|
|
|
|
|
|
|
|
|
head = (const char *)imgp->image_header;
|
|
|
|
|
error = -1;
|
2000-04-26 20:58:40 +00:00
|
|
|
|
|
2000-10-23 08:46:25 +00:00
|
|
|
|
/*
|
|
|
|
|
* The interpreter for shell scripts run from a linux binary needs
|
|
|
|
|
* to be located in /compat/linux if possible in order to recursively
|
|
|
|
|
* maintain linux path emulation.
|
|
|
|
|
*/
|
|
|
|
|
if (((const short *)head)[0] == SHELLMAGIC) {
|
|
|
|
|
/*
|
|
|
|
|
* Run our normal shell image activator. If it succeeds
|
|
|
|
|
* attempt to use the alternate path for the interpreter. If
|
|
|
|
|
* an alternate path is found, use our stringspace to store it.
|
|
|
|
|
*/
|
|
|
|
|
if ((error = exec_shell_imgact(imgp)) == 0) {
|
|
|
|
|
char *rpath = NULL;
|
2000-04-26 20:58:40 +00:00
|
|
|
|
|
2002-02-07 20:58:47 +00:00
|
|
|
|
linux_emul_find(FIRST_THREAD_IN_PROC(imgp->proc), NULL,
|
2001-10-27 11:15:19 +00:00
|
|
|
|
imgp->interpreter_name, &rpath, 0);
|
2000-10-23 08:46:25 +00:00
|
|
|
|
if (rpath != imgp->interpreter_name) {
|
|
|
|
|
int len = strlen(rpath) + 1;
|
2000-04-26 20:58:40 +00:00
|
|
|
|
|
2000-10-23 08:46:25 +00:00
|
|
|
|
if (len <= MAXSHELLCMDLEN) {
|
|
|
|
|
memcpy(imgp->interpreter_name, rpath,
|
|
|
|
|
len);
|
|
|
|
|
}
|
|
|
|
|
free(rpath, M_TEMP);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return(error);
|
2000-04-26 20:58:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-09-06 19:26:17 +00:00
|
|
|
|
/*
|
|
|
|
|
* To maintain OSF/1 compat, linux uses BSD signals & errnos on their
|
|
|
|
|
* alpha port. This greatly simplfies things for us.
|
|
|
|
|
*/
|
1996-03-10 08:42:54 +00:00
|
|
|
|
|
|
|
|
|
struct sysentvec elf_linux_sysvec = {
|
1999-09-29 15:12:18 +00:00
|
|
|
|
LINUX_SYS_MAXSYSCALL,
|
|
|
|
|
linux_sysent,
|
2000-09-06 19:26:17 +00:00
|
|
|
|
0,
|
|
|
|
|
0,
|
2002-09-01 21:41:24 +00:00
|
|
|
|
NULL,
|
2000-09-06 19:26:17 +00:00
|
|
|
|
0,
|
2002-09-01 21:41:24 +00:00
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
1999-09-29 15:12:18 +00:00
|
|
|
|
elf_linux_fixup,
|
2000-09-06 19:26:17 +00:00
|
|
|
|
osendsig,
|
1999-09-29 15:12:18 +00:00
|
|
|
|
linux_sigcode,
|
|
|
|
|
&linux_szsigcode,
|
2002-09-01 21:41:24 +00:00
|
|
|
|
NULL,
|
1998-09-14 05:36:51 +00:00
|
|
|
|
"Linux ELF",
|
2002-07-20 02:56:12 +00:00
|
|
|
|
elf64_coredump,
|
2000-11-09 08:25:48 +00:00
|
|
|
|
exec_linux_imgact_try,
|
2002-09-01 21:41:24 +00:00
|
|
|
|
LINUX_MINSIGSTKSZ,
|
|
|
|
|
PAGE_SIZE,
|
|
|
|
|
VM_MIN_ADDRESS,
|
|
|
|
|
VM_MAXUSER_ADDRESS,
|
|
|
|
|
USRSTACK,
|
|
|
|
|
PS_STRINGS,
|
|
|
|
|
VM_PROT_ALL,
|
|
|
|
|
exec_copyout_strings,
|
2003-09-25 01:10:26 +00:00
|
|
|
|
exec_setregs,
|
|
|
|
|
NULL
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
};
|
1996-03-10 08:42:54 +00:00
|
|
|
|
|
2000-09-06 19:26:17 +00:00
|
|
|
|
static Elf64_Brandinfo linux_brand = {
|
2000-04-18 02:39:26 +00:00
|
|
|
|
ELFOSABI_LINUX,
|
2002-07-20 02:56:12 +00:00
|
|
|
|
EM_ALPHA,
|
2001-03-05 17:56:58 +00:00
|
|
|
|
"Linux",
|
1996-10-16 17:51:08 +00:00
|
|
|
|
"/compat/linux",
|
1996-03-10 22:42:16 +00:00
|
|
|
|
"/lib/ld-linux.so.1",
|
1996-10-16 17:51:08 +00:00
|
|
|
|
&elf_linux_sysvec
|
1996-03-10 22:42:16 +00:00
|
|
|
|
};
|
|
|
|
|
|
2000-09-06 19:26:17 +00:00
|
|
|
|
static Elf64_Brandinfo linux_glibc2brand = {
|
2000-04-18 02:39:26 +00:00
|
|
|
|
ELFOSABI_LINUX,
|
2002-07-20 02:56:12 +00:00
|
|
|
|
EM_ALPHA,
|
2001-03-05 17:56:58 +00:00
|
|
|
|
"Linux",
|
1998-09-17 22:08:34 +00:00
|
|
|
|
"/compat/linux",
|
|
|
|
|
"/lib/ld-linux.so.2",
|
|
|
|
|
&elf_linux_sysvec
|
|
|
|
|
};
|
|
|
|
|
|
2000-09-06 19:26:17 +00:00
|
|
|
|
Elf64_Brandinfo *linux_brandlist[] = {
|
1998-10-11 21:08:02 +00:00
|
|
|
|
&linux_brand,
|
|
|
|
|
&linux_glibc2brand,
|
|
|
|
|
NULL
|
|
|
|
|
};
|
|
|
|
|
|
1998-10-16 03:55:01 +00:00
|
|
|
|
static int
|
1998-11-15 15:33:52 +00:00
|
|
|
|
linux_elf_modevent(module_t mod, int type, void *data)
|
1997-03-29 10:50:27 +00:00
|
|
|
|
{
|
2000-09-06 19:26:17 +00:00
|
|
|
|
Elf64_Brandinfo **brandinfo;
|
1998-10-11 21:08:02 +00:00
|
|
|
|
int error;
|
2001-06-13 10:58:39 +00:00
|
|
|
|
struct linux_ioctl_handler **lihp;
|
1998-10-11 21:08:02 +00:00
|
|
|
|
|
|
|
|
|
error = 0;
|
|
|
|
|
|
1998-10-16 03:55:01 +00:00
|
|
|
|
switch(type) {
|
|
|
|
|
case MOD_LOAD:
|
|
|
|
|
for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;
|
2000-10-23 08:46:25 +00:00
|
|
|
|
++brandinfo)
|
2002-07-20 02:56:12 +00:00
|
|
|
|
if (elf64_insert_brand_entry(*brandinfo) < 0)
|
1998-10-16 03:55:01 +00:00
|
|
|
|
error = EINVAL;
|
2000-11-23 03:21:58 +00:00
|
|
|
|
if (error == 0) {
|
2001-06-13 10:58:39 +00:00
|
|
|
|
SET_FOREACH(lihp, linux_ioctl_handler_set)
|
|
|
|
|
linux_ioctl_register_handler(*lihp);
|
1999-12-04 11:10:22 +00:00
|
|
|
|
if (bootverbose)
|
2000-11-23 03:21:58 +00:00
|
|
|
|
printf("Linux ELF exec handler installed\n");
|
|
|
|
|
} else
|
|
|
|
|
printf("cannot insert Linux ELF brand handler\n");
|
1998-10-16 03:55:01 +00:00
|
|
|
|
break;
|
|
|
|
|
case MOD_UNLOAD:
|
|
|
|
|
for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;
|
2000-10-23 08:46:25 +00:00
|
|
|
|
++brandinfo)
|
2002-07-20 02:56:12 +00:00
|
|
|
|
if (elf64_brand_inuse(*brandinfo))
|
1999-02-04 21:20:13 +00:00
|
|
|
|
error = EBUSY;
|
|
|
|
|
if (error == 0) {
|
|
|
|
|
for (brandinfo = &linux_brandlist[0];
|
2000-10-23 08:46:25 +00:00
|
|
|
|
*brandinfo != NULL; ++brandinfo)
|
2002-07-20 02:56:12 +00:00
|
|
|
|
if (elf64_remove_brand_entry(*brandinfo) < 0)
|
1999-02-04 21:20:13 +00:00
|
|
|
|
error = EINVAL;
|
|
|
|
|
}
|
2000-11-23 03:21:58 +00:00
|
|
|
|
if (error == 0) {
|
2001-06-13 10:58:39 +00:00
|
|
|
|
SET_FOREACH(lihp, linux_ioctl_handler_set)
|
|
|
|
|
linux_ioctl_unregister_handler(*lihp);
|
2000-11-23 03:21:58 +00:00
|
|
|
|
if (bootverbose)
|
|
|
|
|
printf("Linux ELF exec handler removed\n");
|
2003-03-26 18:29:44 +00:00
|
|
|
|
linux_mib_destroy();
|
2000-11-23 03:21:58 +00:00
|
|
|
|
} else
|
1998-10-16 03:55:01 +00:00
|
|
|
|
printf("Could not deinstall ELF interpreter entry\n");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return error;
|
1997-03-29 10:50:27 +00:00
|
|
|
|
}
|
2000-11-23 03:21:58 +00:00
|
|
|
|
|
1998-10-16 03:55:01 +00:00
|
|
|
|
static moduledata_t linux_elf_mod = {
|
|
|
|
|
"linuxelf",
|
|
|
|
|
linux_elf_modevent,
|
|
|
|
|
0
|
|
|
|
|
};
|
2000-11-01 08:52:24 +00:00
|
|
|
|
|
|
|
|
|
DUMMY(rt_sigreturn);
|
|
|
|
|
|
1998-10-16 03:55:01 +00:00
|
|
|
|
DECLARE_MODULE(linuxelf, linux_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY);
|