From 6b51bdf38c86a9dfc5cd597963045ea738d9bdd5 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Fri, 15 Nov 2019 19:00:20 +0000 Subject: [PATCH] Combine ELF sysvecs for MIPS to reduce code duplication. Reviewed by: brooks, kevans Tested on: mips, mips64 Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D22357 --- sys/mips/mips/elf_machdep.c | 91 +++++++++---------------------------- 1 file changed, 21 insertions(+), 70 deletions(-) diff --git a/sys/mips/mips/elf_machdep.c b/sys/mips/mips/elf_machdep.c index fbc0c1ba15d0..ddd03b99de9a 100644 --- a/sys/mips/mips/elf_machdep.c +++ b/sys/mips/mips/elf_machdep.c @@ -51,73 +51,21 @@ __FBSDID("$FreeBSD$"); #include #include +static struct sysentvec elf_freebsd_sysvec = { + .sv_size = SYS_MAXSYSCALL, + .sv_table = sysent, + .sv_errsize = 0, + .sv_errtbl = NULL, + .sv_transtrap = NULL, + .sv_fixup = __elfN(freebsd_fixup), + .sv_sendsig = sendsig, + .sv_sigcode = sigcode, + .sv_szsigcode = &szsigcode, #ifdef __mips_n64 -struct sysentvec elf64_freebsd_sysvec = { - .sv_size = SYS_MAXSYSCALL, - .sv_table = sysent, - .sv_errsize = 0, - .sv_errtbl = NULL, - .sv_transtrap = NULL, - .sv_fixup = __elfN(freebsd_fixup), - .sv_sendsig = sendsig, - .sv_sigcode = sigcode, - .sv_szsigcode = &szsigcode, .sv_name = "FreeBSD ELF64", - .sv_coredump = __elfN(coredump), - .sv_imgact_try = NULL, - .sv_minsigstksz = MINSIGSTKSZ, - .sv_minuser = VM_MIN_ADDRESS, - .sv_maxuser = VM_MAXUSER_ADDRESS, - .sv_usrstack = USRSTACK, - .sv_psstrings = PS_STRINGS, - .sv_stackprot = VM_PROT_ALL, - .sv_copyout_auxargs = __elfN(freebsd_copyout_auxargs), - .sv_copyout_strings = exec_copyout_strings, - .sv_setregs = exec_setregs, - .sv_fixlimit = NULL, - .sv_maxssiz = NULL, - .sv_flags = SV_ABI_FREEBSD | SV_LP64 | SV_ASLR, - .sv_set_syscall_retval = cpu_set_syscall_retval, - .sv_fetch_syscall_args = cpu_fetch_syscall_args, - .sv_syscallnames = syscallnames, - .sv_schedtail = NULL, - .sv_thread_detach = NULL, - .sv_trap = NULL, -}; - -static Elf64_Brandinfo freebsd_brand_info = { - .brand = ELFOSABI_FREEBSD, - .machine = EM_MIPS, - .compat_3_brand = "FreeBSD", - .emul_path = NULL, - .interp_path = "/libexec/ld-elf.so.1", - .sysvec = &elf64_freebsd_sysvec, - .interp_newpath = NULL, - .brand_note = &elf64_freebsd_brandnote, - .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE -}; - -SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY, - (sysinit_cfunc_t) elf64_insert_brand_entry, - &freebsd_brand_info); - -void -elf64_dump_thread(struct thread *td __unused, void *dst __unused, - size_t *off __unused) -{ -} #else -struct sysentvec elf32_freebsd_sysvec = { - .sv_size = SYS_MAXSYSCALL, - .sv_table = sysent, - .sv_errsize = 0, - .sv_errtbl = NULL, - .sv_transtrap = NULL, - .sv_fixup = __elfN(freebsd_fixup), - .sv_sendsig = sendsig, - .sv_sigcode = sigcode, - .sv_szsigcode = &szsigcode, .sv_name = "FreeBSD ELF32", +#endif .sv_coredump = __elfN(coredump), .sv_imgact_try = NULL, .sv_minsigstksz = MINSIGSTKSZ, @@ -131,7 +79,11 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_setregs = exec_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, +#ifdef __mips_n64 + .sv_flags = SV_ABI_FREEBSD | SV_LP64 | SV_ASLR, +#else .sv_flags = SV_ABI_FREEBSD | SV_ILP32 | SV_ASLR, +#endif .sv_set_syscall_retval = cpu_set_syscall_retval, .sv_fetch_syscall_args = cpu_fetch_syscall_args, .sv_syscallnames = syscallnames, @@ -140,28 +92,27 @@ struct sysentvec elf32_freebsd_sysvec = { .sv_trap = NULL, }; -static Elf32_Brandinfo freebsd_brand_info = { +static __ElfN(Brandinfo) freebsd_brand_info = { .brand = ELFOSABI_FREEBSD, .machine = EM_MIPS, .compat_3_brand = "FreeBSD", .emul_path = NULL, .interp_path = "/libexec/ld-elf.so.1", - .sysvec = &elf32_freebsd_sysvec, + .sysvec = &elf_freebsd_sysvec, .interp_newpath = NULL, - .brand_note = &elf32_freebsd_brandnote, + .brand_note = &__elfN(freebsd_brandnote), .flags = BI_CAN_EXEC_DYN | BI_BRAND_NOTE }; -SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_FIRST, - (sysinit_cfunc_t) elf32_insert_brand_entry, +SYSINIT(elf, SI_SUB_EXEC, SI_ORDER_ANY, + (sysinit_cfunc_t) __elfN(insert_brand_entry), &freebsd_brand_info); void -elf32_dump_thread(struct thread *td __unused, void *dst __unused, +__elfN(dump_thread)(struct thread *td __unused, void *dst __unused, size_t *off __unused) { } -#endif /* * The following MIPS relocation code for tracking multiple