Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/imgact_aout.c
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | struct sysentvec aout_sysvec = { | ||||
.sv_trap = NULL, | .sv_trap = NULL, | ||||
.sv_onexec_old = exec_onexec_old, | .sv_onexec_old = exec_onexec_old, | ||||
.sv_onexit = exit_onexit, | .sv_onexit = exit_onexit, | ||||
.sv_set_fork_retval = x86_set_fork_retval, | .sv_set_fork_retval = x86_set_fork_retval, | ||||
}; | }; | ||||
#elif defined(__amd64__) | #elif defined(__amd64__) | ||||
#include "vdso_ia32_offsets.h" | |||||
extern const char _binary_elf_vdso32_so_1_start[]; | |||||
extern const char _binary_elf_vdso32_so_1_end[]; | |||||
extern char _binary_elf_vdso32_so_1_size; | |||||
#define AOUT32_PS_STRINGS \ | #define AOUT32_PS_STRINGS \ | ||||
(AOUT32_USRSTACK - sizeof(struct freebsd32_ps_strings)) | (AOUT32_USRSTACK - sizeof(struct freebsd32_ps_strings)) | ||||
#define AOUT32_MINUSER FREEBSD32_MINUSER | #define AOUT32_MINUSER FREEBSD32_MINUSER | ||||
extern const char *freebsd32_syscallnames[]; | extern const char *freebsd32_syscallnames[]; | ||||
extern u_long ia32_maxssiz; | extern u_long ia32_maxssiz; | ||||
static int aout_szsigcode; | |||||
struct sysentvec aout_sysvec = { | struct sysentvec aout_sysvec = { | ||||
.sv_size = FREEBSD32_SYS_MAXSYSCALL, | .sv_size = FREEBSD32_SYS_MAXSYSCALL, | ||||
.sv_table = freebsd32_sysent, | .sv_table = freebsd32_sysent, | ||||
.sv_transtrap = NULL, | .sv_transtrap = NULL, | ||||
.sv_fixup = aout_fixup, | .sv_fixup = aout_fixup, | ||||
.sv_sendsig = ia32_sendsig, | .sv_sendsig = ia32_sendsig, | ||||
.sv_sigcode = ia32_sigcode, | .sv_sigcode = _binary_elf_vdso32_so_1_start, | ||||
.sv_szsigcode = &sz_ia32_sigcode, | .sv_szsigcode = &aout_szsigcode, | ||||
.sv_name = "FreeBSD a.out", | .sv_name = "FreeBSD a.out", | ||||
.sv_coredump = NULL, | .sv_coredump = NULL, | ||||
.sv_imgact_try = NULL, | .sv_imgact_try = NULL, | ||||
.sv_minsigstksz = MINSIGSTKSZ, | .sv_minsigstksz = MINSIGSTKSZ, | ||||
.sv_minuser = AOUT32_MINUSER, | .sv_minuser = AOUT32_MINUSER, | ||||
.sv_maxuser = AOUT32_USRSTACK, | .sv_maxuser = AOUT32_USRSTACK, | ||||
.sv_usrstack = AOUT32_USRSTACK, | .sv_usrstack = AOUT32_USRSTACK, | ||||
.sv_psstrings = AOUT32_PS_STRINGS, | .sv_psstrings = AOUT32_PS_STRINGS, | ||||
.sv_stackprot = VM_PROT_ALL, | .sv_stackprot = VM_PROT_ALL, | ||||
.sv_copyout_strings = freebsd32_copyout_strings, | .sv_copyout_strings = freebsd32_copyout_strings, | ||||
.sv_setregs = ia32_setregs, | .sv_setregs = ia32_setregs, | ||||
.sv_fixlimit = ia32_fixlimit, | .sv_fixlimit = ia32_fixlimit, | ||||
.sv_maxssiz = &ia32_maxssiz, | .sv_maxssiz = &ia32_maxssiz, | ||||
.sv_flags = SV_ABI_FREEBSD | SV_AOUT | SV_IA32 | SV_ILP32, | .sv_flags = SV_ABI_FREEBSD | SV_AOUT | SV_IA32 | SV_ILP32, | ||||
.sv_set_syscall_retval = ia32_set_syscall_retval, | .sv_set_syscall_retval = ia32_set_syscall_retval, | ||||
.sv_fetch_syscall_args = ia32_fetch_syscall_args, | .sv_fetch_syscall_args = ia32_fetch_syscall_args, | ||||
.sv_syscallnames = freebsd32_syscallnames, | .sv_syscallnames = freebsd32_syscallnames, | ||||
.sv_onexec_old = exec_onexec_old, | .sv_onexec_old = exec_onexec_old, | ||||
.sv_onexit = exit_onexit, | .sv_onexit = exit_onexit, | ||||
.sv_set_fork_retval = x86_set_fork_retval, | .sv_set_fork_retval = x86_set_fork_retval, | ||||
}; | }; | ||||
static void | |||||
aout_sysent(void *arg __unused) | |||||
{ | |||||
aout_szsigcode = (int)(uintptr_t)&_binary_elf_vdso32_so_1_size; | |||||
} | |||||
SYSINIT(aout_sysent, SI_SUB_EXEC, SI_ORDER_ANY, aout_sysent, NULL); | |||||
#else | #else | ||||
#error "Port me" | #error "Only ia32 arch is supported" | ||||
emaste: I guess this comment is not really applicable anymore (we're not going to add new arch a.out… | |||||
Done Inline ActionsIt is same as it was in the time the line was written. I want something to plug if people add imgact_aout.c to their files.<arch>. If you suggest to change the message to something else, I do not object. kib: It is same as it was in the time the line was written. I want something to plug if people add… | |||||
Done Inline ActionsYeah just something I noticed in passing and not related to your work. emaste: Yeah just something I noticed in passing and not related to your work. | |||||
#endif | #endif | ||||
static int | static int | ||||
aout_fixup(uintptr_t *stack_base, struct image_params *imgp) | aout_fixup(uintptr_t *stack_base, struct image_params *imgp) | ||||
{ | { | ||||
*stack_base -= sizeof(uint32_t); | *stack_base -= sizeof(uint32_t); | ||||
if (suword32((void *)*stack_base, imgp->args->argc) != 0) | if (suword32((void *)*stack_base, imgp->args->argc) != 0) | ||||
return (EFAULT); | return (EFAULT); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
exec_aout_imgact(struct image_params *imgp) | exec_aout_imgact(struct image_params *imgp) | ||||
{ | { | ||||
const struct exec *a_out = (const struct exec *) imgp->image_header; | const struct exec *a_out; | ||||
struct vmspace *vmspace; | struct vmspace *vmspace; | ||||
vm_map_t map; | vm_map_t map; | ||||
vm_object_t object; | vm_object_t object; | ||||
vm_offset_t text_end, data_end; | vm_offset_t text_end, data_end; | ||||
unsigned long virtual_offset; | unsigned long virtual_offset; | ||||
unsigned long file_offset; | unsigned long file_offset; | ||||
unsigned long bss_size; | unsigned long bss_size; | ||||
int error; | int error; | ||||
a_out = (const struct exec *)imgp->image_header; | |||||
/* | /* | ||||
* Linux and *BSD binaries look very much alike, | * Linux and *BSD binaries look very much alike, | ||||
* only the machine id is different: | * only the machine id is different: | ||||
* 0x64 for Linux, 0x86 for *BSD, 0x00 for BSDI. | * 0x64 for Linux, 0x86 for *BSD, 0x00 for BSDI. | ||||
* NetBSD is in network byte order.. ugh. | * NetBSD is in network byte order.. ugh. | ||||
*/ | */ | ||||
if (((a_out->a_midmag >> 16) & 0xff) != 0x86 && | if (((a_out->a_midmag >> 16) & 0xff) != 0x86 && | ||||
((a_out->a_midmag >> 16) & 0xff) != 0 && | ((a_out->a_midmag >> 16) & 0xff) != 0 && | ||||
((((int)ntohl(a_out->a_midmag)) >> 16) & 0xff) != 0x86) | ((((int)ntohl(a_out->a_midmag)) >> 16) & 0xff) != 0x86) | ||||
return -1; | return (-1); | ||||
/* | /* | ||||
* Set file/virtual offset based on a.out variant. | * Set file/virtual offset based on a.out variant. | ||||
* We do two cases: host byte order and network byte order | * We do two cases: host byte order and network byte order | ||||
* (for NetBSD compatibility) | * (for NetBSD compatibility) | ||||
*/ | */ | ||||
switch ((int)(a_out->a_midmag & 0xffff)) { | switch ((int)(a_out->a_midmag & 0xffff)) { | ||||
case ZMAGIC: | case ZMAGIC: | ||||
▲ Show 20 Lines • Show All 159 Lines • Show Last 20 Lines |
I guess this comment is not really applicable anymore (we're not going to add new arch a.out support)